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

Side by Side Diff: content/browser/service_manager/service_manager_context.cc

Issue 2576233002: Consolidating the mojo NativeRunner functionality. (Closed)
Patch Set: Merged mojo_runner_host_unittests in service_manager_unittests Created 4 years 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
« no previous file with comments | « chrome/test/base/mojo_test_connector.cc ('k') | mojo/BUILD.gn » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "content/browser/service_manager/service_manager_context.h" 5 #include "content/browser/service_manager/service_manager_context.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 14 matching lines...) Expand all
25 #include "content/public/common/content_client.h" 25 #include "content/public/common/content_client.h"
26 #include "content/public/common/service_manager_connection.h" 26 #include "content/public/common/service_manager_connection.h"
27 #include "content/public/common/service_names.mojom.h" 27 #include "content/public/common/service_names.mojom.h"
28 #include "mojo/edk/embedder/embedder.h" 28 #include "mojo/edk/embedder/embedder.h"
29 #include "services/catalog/catalog.h" 29 #include "services/catalog/catalog.h"
30 #include "services/catalog/manifest_provider.h" 30 #include "services/catalog/manifest_provider.h"
31 #include "services/catalog/public/interfaces/constants.mojom.h" 31 #include "services/catalog/public/interfaces/constants.mojom.h"
32 #include "services/catalog/store.h" 32 #include "services/catalog/store.h"
33 #include "services/file/public/interfaces/constants.mojom.h" 33 #include "services/file/public/interfaces/constants.mojom.h"
34 #include "services/service_manager/connect_params.h" 34 #include "services/service_manager/connect_params.h"
35 #include "services/service_manager/native_runner.h"
36 #include "services/service_manager/public/cpp/connector.h" 35 #include "services/service_manager/public/cpp/connector.h"
37 #include "services/service_manager/public/cpp/service.h" 36 #include "services/service_manager/public/cpp/service.h"
38 #include "services/service_manager/public/interfaces/service.mojom.h" 37 #include "services/service_manager/public/interfaces/service.mojom.h"
39 #include "services/service_manager/runner/common/client_util.h" 38 #include "services/service_manager/runner/common/client_util.h"
40 #include "services/service_manager/service_manager.h" 39 #include "services/service_manager/service_manager.h"
41 40
42 namespace content { 41 namespace content {
43 42
44 namespace { 43 namespace {
45 44
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 std::unique_ptr<base::Value> GetManifest(const std::string& name) override { 125 std::unique_ptr<base::Value> GetManifest(const std::string& name) override {
127 auto it = manifests_.find(name); 126 auto it = manifests_.find(name);
128 return it != manifests_.end() ? it->second->CreateDeepCopy() : nullptr; 127 return it != manifests_.end() ? it->second->CreateDeepCopy() : nullptr;
129 } 128 }
130 129
131 std::map<std::string, std::unique_ptr<base::Value>> manifests_; 130 std::map<std::string, std::unique_ptr<base::Value>> manifests_;
132 131
133 DISALLOW_COPY_AND_ASSIGN(BuiltinManifestProvider); 132 DISALLOW_COPY_AND_ASSIGN(BuiltinManifestProvider);
134 }; 133 };
135 134
136 class NullNativeRunnerFactory : public service_manager::NativeRunnerFactory { 135 class NullServiceProcessLauncherFactory
136 : public service_manager::ServiceProcessLauncherFactory {
137 public: 137 public:
138 NullNativeRunnerFactory() {} 138 NullServiceProcessLauncherFactory() {}
139 ~NullNativeRunnerFactory() override {} 139 ~NullServiceProcessLauncherFactory() override {}
140 140
141 std::unique_ptr<service_manager::NativeRunner> Create( 141 private:
142 std::unique_ptr<service_manager::ServiceProcessLauncher> Create(
142 const base::FilePath& service_path) override { 143 const base::FilePath& service_path) override {
143 LOG(ERROR) << "Attempting to run unsupported native service: " 144 LOG(ERROR) << "Attempting to run unsupported native service: "
144 << service_path.value(); 145 << service_path.value();
145 return nullptr; 146 return nullptr;
146 } 147 }
147 148
148 private: 149 DISALLOW_COPY_AND_ASSIGN(NullServiceProcessLauncherFactory);
149 DISALLOW_COPY_AND_ASSIGN(NullNativeRunnerFactory);
150 }; 150 };
151 151
152 } // namespace 152 } // namespace
153 153
154 // State which lives on the IO thread and drives the ServiceManager. 154 // State which lives on the IO thread and drives the ServiceManager.
155 class ServiceManagerContext::InProcessServiceManagerContext 155 class ServiceManagerContext::InProcessServiceManagerContext
156 : public base::RefCountedThreadSafe<InProcessServiceManagerContext> { 156 : public base::RefCountedThreadSafe<InProcessServiceManagerContext> {
157 public: 157 public:
158 InProcessServiceManagerContext() {} 158 InProcessServiceManagerContext() {}
159 159
(...skipping 22 matching lines...) Expand all
182 friend class base::RefCountedThreadSafe<InProcessServiceManagerContext>; 182 friend class base::RefCountedThreadSafe<InProcessServiceManagerContext>;
183 183
184 ~InProcessServiceManagerContext() {} 184 ~InProcessServiceManagerContext() {}
185 185
186 void StartOnIOThread( 186 void StartOnIOThread(
187 std::unique_ptr<BuiltinManifestProvider> manifest_provider, 187 std::unique_ptr<BuiltinManifestProvider> manifest_provider,
188 service_manager::mojom::ServicePtrInfo embedder_service_proxy_info) { 188 service_manager::mojom::ServicePtrInfo embedder_service_proxy_info) {
189 manifest_provider_ = std::move(manifest_provider); 189 manifest_provider_ = std::move(manifest_provider);
190 190
191 base::SequencedWorkerPool* blocking_pool = BrowserThread::GetBlockingPool(); 191 base::SequencedWorkerPool* blocking_pool = BrowserThread::GetBlockingPool();
192 catalog_.reset( 192 catalog_ = base::MakeUnique<catalog::Catalog>(
193 new catalog::Catalog(blocking_pool, nullptr, manifest_provider_.get())); 193 blocking_pool, nullptr, manifest_provider_.get());
194 service_manager_.reset(new service_manager::ServiceManager( 194 service_manager_ = base::MakeUnique<service_manager::ServiceManager>(
195 base::MakeUnique<NullNativeRunnerFactory>(), catalog_->TakeService())); 195 base::MakeUnique<NullServiceProcessLauncherFactory>(),
196 catalog_->TakeService());
196 197
197 service_manager::mojom::ServiceRequest request = 198 service_manager::mojom::ServiceRequest request =
198 service_manager_->StartEmbedderService(mojom::kBrowserServiceName); 199 service_manager_->StartEmbedderService(mojom::kBrowserServiceName);
199 mojo::FuseInterface( 200 mojo::FuseInterface(
200 std::move(request), std::move(embedder_service_proxy_info)); 201 std::move(request), std::move(embedder_service_proxy_info));
201 } 202 }
202 203
203 void ShutDownOnIOThread() { 204 void ShutDownOnIOThread() {
204 service_manager_.reset(); 205 service_manager_.reset();
205 catalog_.reset(); 206 catalog_.reset();
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 base::Bind(&DestroyConnectorOnIOThread)); 325 base::Bind(&DestroyConnectorOnIOThread));
325 } 326 }
326 327
327 // static 328 // static
328 service_manager::Connector* ServiceManagerContext::GetConnectorForIOThread() { 329 service_manager::Connector* ServiceManagerContext::GetConnectorForIOThread() {
329 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 330 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
330 return g_io_thread_connector.Get().get(); 331 return g_io_thread_connector.Get().get();
331 } 332 }
332 333
333 } // namespace content 334 } // namespace content
OLDNEW
« no previous file with comments | « chrome/test/base/mojo_test_connector.cc ('k') | mojo/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698