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

Side by Side Diff: services/service_manager/service_manager.cc

Issue 2557213002: Build services as standalone executables (Closed)
Patch Set: remove DCHECKs with side effects -_- 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "services/service_manager/service_manager.h" 5 #include "services/service_manager/service_manager.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 void StartWithClientProcessConnection( 183 void StartWithClientProcessConnection(
184 mojom::ClientProcessConnectionPtr client_process_connection) { 184 mojom::ClientProcessConnectionPtr client_process_connection) {
185 mojom::ServicePtr service; 185 mojom::ServicePtr service;
186 service.Bind(mojom::ServicePtrInfo( 186 service.Bind(mojom::ServicePtrInfo(
187 std::move(client_process_connection->service), 0)); 187 std::move(client_process_connection->service), 0));
188 pid_receiver_binding_.Bind( 188 pid_receiver_binding_.Bind(
189 std::move(client_process_connection->pid_receiver_request)); 189 std::move(client_process_connection->pid_receiver_request));
190 StartWithService(std::move(service)); 190 StartWithService(std::move(service));
191 } 191 }
192 192
193 void StartWithFilePath(const base::FilePath& path) { 193 bool StartWithFilePath(const base::FilePath& path) {
194 CHECK(!service_); 194 DCHECK(!service_);
195 DCHECK(!path.empty());
195 runner_ = service_manager_->native_runner_factory_->Create(path); 196 runner_ = service_manager_->native_runner_factory_->Create(path);
197 if (!runner_)
198 return false;
196 bool start_sandboxed = false; 199 bool start_sandboxed = false;
197 mojom::ServicePtr service = runner_->Start( 200 mojom::ServicePtr service = runner_->Start(
198 path, identity_, start_sandboxed, 201 identity_, start_sandboxed,
199 base::Bind(&Instance::PIDAvailable, weak_factory_.GetWeakPtr()), 202 base::Bind(&Instance::PIDAvailable, weak_factory_.GetWeakPtr()),
200 base::Bind(&Instance::OnRunnerCompleted, weak_factory_.GetWeakPtr())); 203 base::Bind(&Instance::OnRunnerCompleted, weak_factory_.GetWeakPtr()));
201 StartWithService(std::move(service)); 204 StartWithService(std::move(service));
205 return true;
202 } 206 }
203 207
204 mojom::RunningServiceInfoPtr CreateRunningServiceInfo() const { 208 mojom::RunningServiceInfoPtr CreateRunningServiceInfo() const {
205 mojom::RunningServiceInfoPtr info(mojom::RunningServiceInfo::New()); 209 mojom::RunningServiceInfoPtr info(mojom::RunningServiceInfo::New());
206 info->id = id_; 210 info->id = id_;
207 info->identity = identity_; 211 info->identity = identity_;
208 info->pid = pid_; 212 info->pid = pid_;
209 return info; 213 return info;
210 } 214 }
211 215
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 Identity factory(result->resolved_name, target_user_id, 944 Identity factory(result->resolved_name, target_user_id,
941 factory_instance_name); 945 factory_instance_name);
942 CreateServiceWithFactory(factory, target.name(), std::move(request)); 946 CreateServiceWithFactory(factory, target.name(), std::move(request));
943 } else { 947 } else {
944 base::FilePath package_path; 948 base::FilePath package_path;
945 if (!service_overrides_ || !service_overrides_->GetExecutablePathOverride( 949 if (!service_overrides_ || !service_overrides_->GetExecutablePathOverride(
946 target.name(), &package_path)) { 950 target.name(), &package_path)) {
947 package_path = result->package_path; 951 package_path = result->package_path;
948 } 952 }
949 953
950 // TODO(rockot): Find a way to block this code path for content but allow 954 if (!instance->StartWithFilePath(package_path)) {
951 // it for chrome_mash. 955 OnInstanceError(instance);
952 instance->StartWithFilePath(package_path); 956 return;
957 }
953 } 958 }
954 } 959 }
955 960
956 // Now that the instance has a Service, we can connect to it. 961 // Now that the instance has a Service, we can connect to it.
957 bool connected = instance->ConnectToService(&params); 962 bool connected = instance->ConnectToService(&params);
958 DCHECK(connected); 963 DCHECK(connected);
959 } 964 }
960 965
961 base::WeakPtr<ServiceManager> ServiceManager::GetWeakPtr() { 966 base::WeakPtr<ServiceManager> ServiceManager::GetWeakPtr() {
962 return weak_ptr_factory_.GetWeakPtr(); 967 return weak_ptr_factory_.GetWeakPtr();
963 } 968 }
964 969
965 } // namespace service_manager 970 } // namespace service_manager
OLDNEW
« no previous file with comments | « services/service_manager/runner/host/out_of_process_native_runner.cc ('k') | services/service_manager/standalone/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698