OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef MOJO_SHELL_CONTEXT_H_ | 5 #ifndef MOJO_SHELL_CONTEXT_H_ |
6 #define MOJO_SHELL_CONTEXT_H_ | 6 #define MOJO_SHELL_CONTEXT_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "build/build_config.h" | |
10 #include "mojo/service_manager/service_manager.h" | 11 #include "mojo/service_manager/service_manager.h" |
12 #include "mojo/services/native_viewport/native_viewport_context.h" | |
11 #include "mojo/shell/keep_alive.h" | 13 #include "mojo/shell/keep_alive.h" |
12 #include "mojo/shell/mojo_url_resolver.h" | 14 #include "mojo/shell/mojo_url_resolver.h" |
13 #include "mojo/shell/task_runners.h" | 15 #include "mojo/shell/task_runners.h" |
14 | 16 |
15 #if defined(OS_ANDROID) | 17 #if defined(OS_ANDROID) |
16 #include "base/android/scoped_java_ref.h" | 18 #include "base/android/scoped_java_ref.h" |
17 #endif // defined(OS_ANDROID) | 19 #endif // defined(OS_ANDROID) |
18 | 20 |
19 namespace mojo { | 21 namespace mojo { |
20 | 22 |
21 class Spy; | 23 class Spy; |
22 | 24 |
23 namespace shell { | 25 namespace shell { |
24 | 26 |
25 class DynamicServiceLoader; | 27 class DynamicServiceLoader; |
26 | 28 |
27 // The "global" context for the shell's main process. | 29 // The "global" context for the shell's main process. |
28 class Context { | 30 class Context : public services::NativeViewportContext { |
darin (slow to review)
2014/07/19 04:26:29
Maybe instead of subclassing NativeViewportContext
| |
29 public: | 31 public: |
30 Context(); | 32 Context(); |
31 ~Context(); | 33 virtual ~Context(); |
32 | 34 |
33 TaskRunners* task_runners() { return &task_runners_; } | 35 TaskRunners* task_runners() { return &task_runners_; } |
34 ServiceManager* service_manager() { return &service_manager_; } | 36 ServiceManager* service_manager() { return &service_manager_; } |
35 KeepAliveCounter* keep_alive_counter() { return &keep_alive_counter_; } | 37 KeepAliveCounter* keep_alive_counter() { return &keep_alive_counter_; } |
36 MojoURLResolver* mojo_url_resolver() { return &mojo_url_resolver_; } | 38 MojoURLResolver* mojo_url_resolver() { return &mojo_url_resolver_; } |
37 | 39 |
38 #if defined(OS_ANDROID) | 40 #if defined(OS_ANDROID) |
39 jobject activity() const { return activity_.obj(); } | 41 // services::NativeViewportContext override. |
42 virtual jobject GetActivity() OVERRIDE; | |
43 | |
40 void set_activity(jobject activity) { activity_.Reset(NULL, activity); } | 44 void set_activity(jobject activity) { activity_.Reset(NULL, activity); } |
41 base::MessageLoop* ui_loop() const { return ui_loop_; } | 45 base::MessageLoop* ui_loop() const { return ui_loop_; } |
42 void set_ui_loop(base::MessageLoop* ui_loop) { ui_loop_ = ui_loop; } | 46 void set_ui_loop(base::MessageLoop* ui_loop) { ui_loop_ = ui_loop; } |
43 #endif // defined(OS_ANDROID) | 47 #endif // defined(OS_ANDROID) |
44 | 48 |
45 private: | 49 private: |
46 class NativeViewportServiceLoader; | 50 class NativeViewportServiceLoader; |
47 | 51 |
48 TaskRunners task_runners_; | 52 TaskRunners task_runners_; |
49 ServiceManager service_manager_; | 53 ServiceManager service_manager_; |
50 MojoURLResolver mojo_url_resolver_; | 54 MojoURLResolver mojo_url_resolver_; |
51 scoped_ptr<Spy> spy_; | 55 scoped_ptr<Spy> spy_; |
52 #if defined(OS_ANDROID) | 56 #if defined(OS_ANDROID) |
53 base::android::ScopedJavaGlobalRef<jobject> activity_; | 57 base::android::ScopedJavaGlobalRef<jobject> activity_; |
54 base::MessageLoop* ui_loop_; | 58 base::MessageLoop* ui_loop_; |
55 #endif // defined(OS_ANDROID) | 59 #endif // defined(OS_ANDROID) |
56 | 60 |
57 KeepAliveCounter keep_alive_counter_; | 61 KeepAliveCounter keep_alive_counter_; |
58 | 62 |
59 DISALLOW_COPY_AND_ASSIGN(Context); | 63 DISALLOW_COPY_AND_ASSIGN(Context); |
60 }; | 64 }; |
61 | 65 |
62 } // namespace shell | 66 } // namespace shell |
63 } // namespace mojo | 67 } // namespace mojo |
64 | 68 |
65 #endif // MOJO_SHELL_CONTEXT_H_ | 69 #endif // MOJO_SHELL_CONTEXT_H_ |
OLD | NEW |