Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(288)

Side by Side Diff: mojo/shell/context.cc

Issue 256133002: Changes view manager test to connect via shell (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge to trunk Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « mojo/services/view_manager/view_manager_connection_unittest.cc ('k') | mojo/shell/run.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "mojo/shell/context.h" 5 #include "mojo/shell/context.h"
6 6
7 #include "build/build_config.h"
7 #include "base/command_line.h" 8 #include "base/command_line.h"
8 #include "build/build_config.h" 9 #include "base/lazy_instance.h"
10 #include "base/memory/scoped_vector.h"
9 #include "mojo/embedder/embedder.h" 11 #include "mojo/embedder/embedder.h"
10 #include "mojo/gles2/gles2_support_impl.h" 12 #include "mojo/gles2/gles2_support_impl.h"
13 #include "mojo/public/cpp/shell/application.h"
11 #include "mojo/service_manager/service_loader.h" 14 #include "mojo/service_manager/service_loader.h"
12 #include "mojo/service_manager/service_manager.h" 15 #include "mojo/service_manager/service_manager.h"
13 #include "mojo/services/native_viewport/native_viewport_service.h" 16 #include "mojo/services/native_viewport/native_viewport_service.h"
14 #include "mojo/shell/dynamic_service_loader.h" 17 #include "mojo/shell/dynamic_service_loader.h"
15 #include "mojo/shell/in_process_dynamic_service_runner.h" 18 #include "mojo/shell/in_process_dynamic_service_runner.h"
16 #include "mojo/shell/network_delegate.h" 19 #include "mojo/shell/network_delegate.h"
17 #include "mojo/shell/out_of_process_dynamic_service_runner.h" 20 #include "mojo/shell/out_of_process_dynamic_service_runner.h"
18 #include "mojo/shell/switches.h" 21 #include "mojo/shell/switches.h"
19 #include "mojo/spy/spy.h" 22 #include "mojo/spy/spy.h"
20 23
21 #if defined(OS_LINUX) 24 #if defined(OS_LINUX)
22 #include "mojo/shell/dbus_service_loader_linux.h" 25 #include "mojo/shell/dbus_service_loader_linux.h"
23 #endif // defined(OS_LINUX) 26 #endif // defined(OS_LINUX)
24 27
28 #if defined(USE_AURA)
29 #include "mojo/services/view_manager/root_node_manager.h"
30 #include "mojo/services/view_manager/view_manager_connection.h"
31 #endif
32
25 namespace mojo { 33 namespace mojo {
26 namespace shell { 34 namespace shell {
35 namespace {
36
37 // Used to ensure we only init once.
38 class Setup {
39 public:
40 Setup() {
41 embedder::Init();
42 gles2::GLES2SupportImpl::Init();
43 }
44
45 ~Setup() {
46 }
47
48 private:
49 DISALLOW_COPY_AND_ASSIGN(Setup);
50 };
51
52 static base::LazyInstance<Setup> setup = LAZY_INSTANCE_INITIALIZER;
53
54 #if defined(USE_AURA)
55 class ViewManagerLoader : public ServiceLoader {
56 public:
57 ViewManagerLoader() {}
58 virtual ~ViewManagerLoader() {}
59
60 private:
61 virtual void LoadService(ServiceManager* manager,
62 const GURL& url,
63 ScopedShellHandle shell_handle) OVERRIDE {
64 scoped_ptr<Application> app(new Application(shell_handle.Pass()));
65 app->AddServiceConnector(
66 new ServiceConnector<services::view_manager::ViewManagerConnection,
67 services::view_manager::RootNodeManager>(
68 &root_node_manager_));
69 apps_.push_back(app.release());
70 }
71
72 virtual void OnServiceError(ServiceManager* manager,
73 const GURL& url) OVERRIDE {
74 }
75
76 services::view_manager::RootNodeManager root_node_manager_;
77 ScopedVector<Application> apps_;
78
79 DISALLOW_COPY_AND_ASSIGN(ViewManagerLoader);
80 };
81 #endif
82
83 } // namespace
27 84
28 class Context::NativeViewportServiceLoader : public ServiceLoader { 85 class Context::NativeViewportServiceLoader : public ServiceLoader {
29 public: 86 public:
30 explicit NativeViewportServiceLoader(Context* context) : context_(context) {} 87 explicit NativeViewportServiceLoader(Context* context) : context_(context) {}
31 virtual ~NativeViewportServiceLoader() {} 88 virtual ~NativeViewportServiceLoader() {}
32 89
33 private: 90 private:
34 virtual void LoadService(ServiceManager* manager, 91 virtual void LoadService(ServiceManager* manager,
35 const GURL& url, 92 const GURL& url,
36 ScopedShellHandle service_handle) OVERRIDE { 93 ScopedShellHandle service_handle) OVERRIDE {
(...skipping 10 matching lines...) Expand all
47 }; 104 };
48 105
49 Context::Context() 106 Context::Context()
50 : task_runners_(base::MessageLoop::current()->message_loop_proxy()), 107 : task_runners_(base::MessageLoop::current()->message_loop_proxy()),
51 storage_(), 108 storage_(),
52 loader_(task_runners_.io_runner(), 109 loader_(task_runners_.io_runner(),
53 task_runners_.file_runner(), 110 task_runners_.file_runner(),
54 task_runners_.cache_runner(), 111 task_runners_.cache_runner(),
55 scoped_ptr<net::NetworkDelegate>(new NetworkDelegate()), 112 scoped_ptr<net::NetworkDelegate>(new NetworkDelegate()),
56 storage_.profile_path()) { 113 storage_.profile_path()) {
57 embedder::Init(); 114 setup.Get();
58 gles2::GLES2SupportImpl::Init();
59
60 CommandLine* cmdline = CommandLine::ForCurrentProcess(); 115 CommandLine* cmdline = CommandLine::ForCurrentProcess();
61 scoped_ptr<DynamicServiceRunnerFactory> runner_factory; 116 scoped_ptr<DynamicServiceRunnerFactory> runner_factory;
62 if (cmdline->HasSwitch(switches::kEnableMultiprocess)) 117 if (cmdline->HasSwitch(switches::kEnableMultiprocess))
63 runner_factory.reset(new OutOfProcessDynamicServiceRunnerFactory()); 118 runner_factory.reset(new OutOfProcessDynamicServiceRunnerFactory());
64 else 119 else
65 runner_factory.reset(new InProcessDynamicServiceRunnerFactory()); 120 runner_factory.reset(new InProcessDynamicServiceRunnerFactory());
66 121
67 service_manager_.set_default_loader( 122 service_manager_.set_default_loader(
68 scoped_ptr<ServiceLoader>( 123 scoped_ptr<ServiceLoader>(
69 new DynamicServiceLoader(this, runner_factory.Pass()))); 124 new DynamicServiceLoader(this, runner_factory.Pass())));
70 service_manager_.SetLoaderForURL( 125 service_manager_.SetLoaderForURL(
71 scoped_ptr<ServiceLoader>(new NativeViewportServiceLoader(this)), 126 scoped_ptr<ServiceLoader>(new NativeViewportServiceLoader(this)),
72 GURL("mojo:mojo_native_viewport_service")); 127 GURL("mojo:mojo_native_viewport_service"));
128 #if defined(USE_AURA)
129 // TODO(sky): need a better way to find this. It shouldn't be linked in.
130 service_manager_.SetLoaderForURL(
131 scoped_ptr<ServiceLoader>(new ViewManagerLoader()),
132 GURL("mojo:mojo_view_manager"));
133 #endif
73 134
74 #if defined(OS_LINUX) 135 #if defined(OS_LINUX)
75 service_manager_.SetLoaderForScheme( 136 service_manager_.SetLoaderForScheme(
76 scoped_ptr<ServiceLoader>(new DBusServiceLoader(this)), 137 scoped_ptr<ServiceLoader>(new DBusServiceLoader(this)),
77 "dbus"); 138 "dbus");
78 #endif // defined(OS_LINUX) 139 #endif // defined(OS_LINUX)
79 140
80 if (cmdline->HasSwitch(switches::kSpy)) { 141 if (cmdline->HasSwitch(switches::kSpy)) {
81 spy_.reset(new mojo::Spy(&service_manager_, 142 spy_.reset(new mojo::Spy(&service_manager_,
82 cmdline->GetSwitchValueASCII(switches::kSpy))); 143 cmdline->GetSwitchValueASCII(switches::kSpy)));
83 } 144 }
84 } 145 }
85 146
86 Context::~Context() { 147 Context::~Context() {
87 service_manager_.set_default_loader(scoped_ptr<ServiceLoader>()); 148 service_manager_.set_default_loader(scoped_ptr<ServiceLoader>());
88 } 149 }
89 150
90 } // namespace shell 151 } // namespace shell
91 } // namespace mojo 152 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/services/view_manager/view_manager_connection_unittest.cc ('k') | mojo/shell/run.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698