• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef MOJO_SHELL_CONTEXT_H_
6 #define MOJO_SHELL_CONTEXT_H_
7 
8 #include <string>
9 
10 #include "mojo/service_manager/service_manager.h"
11 #include "mojo/shell/keep_alive.h"
12 #include "mojo/shell/mojo_url_resolver.h"
13 #include "mojo/shell/task_runners.h"
14 
15 #if defined(OS_ANDROID)
16 #include "base/android/scoped_java_ref.h"
17 #endif  // defined(OS_ANDROID)
18 
19 namespace mojo {
20 
21 class Spy;
22 
23 namespace shell {
24 
25 class DynamicServiceLoader;
26 
27 // The "global" context for the shell's main process.
28 class Context {
29  public:
30   Context();
31   ~Context();
32 
task_runners()33   TaskRunners* task_runners() { return &task_runners_; }
service_manager()34   ServiceManager* service_manager() { return &service_manager_; }
keep_alive_counter()35   KeepAliveCounter* keep_alive_counter() { return &keep_alive_counter_; }
mojo_url_resolver()36   MojoURLResolver* mojo_url_resolver() { return &mojo_url_resolver_; }
37 
38 #if defined(OS_ANDROID)
activity()39   jobject activity() const { return activity_.obj(); }
set_activity(jobject activity)40   void set_activity(jobject activity) { activity_.Reset(NULL, activity); }
41 #endif  // defined(OS_ANDROID)
42 
43  private:
44   class NativeViewportServiceLoader;
45 
46   TaskRunners task_runners_;
47   ServiceManager service_manager_;
48   MojoURLResolver mojo_url_resolver_;
49   scoped_ptr<Spy> spy_;
50 #if defined(OS_ANDROID)
51   base::android::ScopedJavaGlobalRef<jobject> activity_;
52 #endif  // defined(OS_ANDROID)
53 
54   KeepAliveCounter keep_alive_counter_;
55 
56   DISALLOW_COPY_AND_ASSIGN(Context);
57 };
58 
59 }  // namespace shell
60 }  // namespace mojo
61 
62 #endif  // MOJO_SHELL_CONTEXT_H_
63