| OLD | NEW | 
|---|
| 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  Loading... | 
| 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   bool StartWithFilePath(const base::FilePath& path) { | 193   void StartWithFilePath(const base::FilePath& path) { | 
| 194     DCHECK(!service_); | 194     CHECK(!service_); | 
| 195     DCHECK(!path.empty()); |  | 
| 196     runner_ = service_manager_->native_runner_factory_->Create(path); | 195     runner_ = service_manager_->native_runner_factory_->Create(path); | 
| 197     if (!runner_) |  | 
| 198       return false; |  | 
| 199     bool start_sandboxed = false; | 196     bool start_sandboxed = false; | 
| 200     mojom::ServicePtr service = runner_->Start( | 197     mojom::ServicePtr service = runner_->Start( | 
| 201         identity_, start_sandboxed, | 198         path, identity_, start_sandboxed, | 
| 202         base::Bind(&Instance::PIDAvailable, weak_factory_.GetWeakPtr()), | 199         base::Bind(&Instance::PIDAvailable, weak_factory_.GetWeakPtr()), | 
| 203         base::Bind(&Instance::OnRunnerCompleted, weak_factory_.GetWeakPtr())); | 200         base::Bind(&Instance::OnRunnerCompleted, weak_factory_.GetWeakPtr())); | 
| 204     StartWithService(std::move(service)); | 201     StartWithService(std::move(service)); | 
| 205     return true; |  | 
| 206   } | 202   } | 
| 207 | 203 | 
| 208   mojom::RunningServiceInfoPtr CreateRunningServiceInfo() const { | 204   mojom::RunningServiceInfoPtr CreateRunningServiceInfo() const { | 
| 209     mojom::RunningServiceInfoPtr info(mojom::RunningServiceInfo::New()); | 205     mojom::RunningServiceInfoPtr info(mojom::RunningServiceInfo::New()); | 
| 210     info->id = id_; | 206     info->id = id_; | 
| 211     info->identity = identity_; | 207     info->identity = identity_; | 
| 212     info->pid = pid_; | 208     info->pid = pid_; | 
| 213     return info; | 209     return info; | 
| 214   } | 210   } | 
| 215 | 211 | 
| (...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 924       Identity factory(result->resolved_name, target_user_id, | 920       Identity factory(result->resolved_name, target_user_id, | 
| 925                        factory_instance_name); | 921                        factory_instance_name); | 
| 926       CreateServiceWithFactory(factory, target.name(), std::move(request)); | 922       CreateServiceWithFactory(factory, target.name(), std::move(request)); | 
| 927     } else { | 923     } else { | 
| 928       base::FilePath package_path; | 924       base::FilePath package_path; | 
| 929       if (!service_overrides_ || !service_overrides_->GetExecutablePathOverride( | 925       if (!service_overrides_ || !service_overrides_->GetExecutablePathOverride( | 
| 930             target.name(), &package_path)) { | 926             target.name(), &package_path)) { | 
| 931         package_path = result->package_path; | 927         package_path = result->package_path; | 
| 932       } | 928       } | 
| 933 | 929 | 
| 934       if (!instance->StartWithFilePath(package_path)) { | 930       // TODO(rockot): Find a way to block this code path for content but allow | 
| 935         OnInstanceError(instance); | 931       // it for chrome_mash. | 
| 936         return; | 932       instance->StartWithFilePath(package_path); | 
| 937       } |  | 
| 938     } | 933     } | 
| 939   } | 934   } | 
| 940 | 935 | 
| 941   // Now that the instance has a Service, we can connect to it. | 936   // Now that the instance has a Service, we can connect to it. | 
| 942   bool connected = instance->ConnectToService(¶ms); | 937   bool connected = instance->ConnectToService(¶ms); | 
| 943   DCHECK(connected); | 938   DCHECK(connected); | 
| 944 } | 939 } | 
| 945 | 940 | 
| 946 base::WeakPtr<ServiceManager> ServiceManager::GetWeakPtr() { | 941 base::WeakPtr<ServiceManager> ServiceManager::GetWeakPtr() { | 
| 947   return weak_ptr_factory_.GetWeakPtr(); | 942   return weak_ptr_factory_.GetWeakPtr(); | 
| 948 } | 943 } | 
| 949 | 944 | 
| 950 }  // namespace service_manager | 945 }  // namespace service_manager | 
| OLD | NEW | 
|---|