| 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/shell/service_manager.h" | 5 #include "services/shell/service_manager.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/guid.h" | 13 #include "base/guid.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/process/process.h" | 16 #include "base/process/process.h" |
| 17 #include "base/process/process_handle.h" | 17 #include "base/process/process_handle.h" |
| 18 #include "base/stl_util.h" | 18 #include "base/stl_util.h" |
| 19 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
| 20 #include "base/trace_event/trace_event.h" | 20 #include "base/trace_event/trace_event.h" |
| 21 #include "mojo/public/cpp/bindings/binding.h" | 21 #include "mojo/public/cpp/bindings/binding.h" |
| 22 #include "mojo/public/cpp/bindings/binding_set.h" | 22 #include "mojo/public/cpp/bindings/binding_set.h" |
| 23 #include "services/shell/connect_util.h" | 23 #include "services/shell/connect_util.h" |
| 24 #include "services/shell/public/cpp/connector.h" | 24 #include "services/shell/public/cpp/connector.h" |
| 25 #include "services/shell/public/cpp/names.h" | 25 #include "services/shell/public/cpp/names.h" |
| 26 #include "services/shell/public/cpp/shell_connection.h" | 26 #include "services/shell/public/cpp/service_context.h" |
| 27 #include "services/shell/public/interfaces/connector.mojom.h" | 27 #include "services/shell/public/interfaces/connector.mojom.h" |
| 28 #include "services/shell/public/interfaces/service.mojom.h" | 28 #include "services/shell/public/interfaces/service.mojom.h" |
| 29 #include "services/shell/public/interfaces/service_manager.mojom.h" | 29 #include "services/shell/public/interfaces/service_manager.mojom.h" |
| 30 | 30 |
| 31 namespace shell { | 31 namespace shell { |
| 32 | 32 |
| 33 namespace { | 33 namespace { |
| 34 | 34 |
| 35 const char kCatalogName[] = "mojo:catalog"; | 35 const char kCatalogName[] = "mojo:catalog"; |
| 36 const char kServiceManagerName[] = "mojo:shell"; | 36 const char kServiceManagerName[] = "mojo:shell"; |
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 std::unique_ptr<NativeRunnerFactory> native_runner_factory, | 490 std::unique_ptr<NativeRunnerFactory> native_runner_factory, |
| 491 mojom::ServicePtr catalog) | 491 mojom::ServicePtr catalog) |
| 492 : native_runner_factory_(std::move(native_runner_factory)), | 492 : native_runner_factory_(std::move(native_runner_factory)), |
| 493 weak_ptr_factory_(this) { | 493 weak_ptr_factory_(this) { |
| 494 mojom::ServicePtr service; | 494 mojom::ServicePtr service; |
| 495 mojom::ServiceRequest request = mojo::GetProxy(&service); | 495 mojom::ServiceRequest request = mojo::GetProxy(&service); |
| 496 Instance* instance = CreateInstance( | 496 Instance* instance = CreateInstance( |
| 497 Identity(), CreateServiceManagerIdentity(), GetPermissiveCapabilities()); | 497 Identity(), CreateServiceManagerIdentity(), GetPermissiveCapabilities()); |
| 498 instance->StartWithService(std::move(service)); | 498 instance->StartWithService(std::move(service)); |
| 499 singletons_.insert(kServiceManagerName); | 499 singletons_.insert(kServiceManagerName); |
| 500 shell_connection_.reset(new ShellConnection(this, std::move(request))); | 500 service_context_.reset(new ServiceContext(this, std::move(request))); |
| 501 | 501 |
| 502 if (catalog) | 502 if (catalog) |
| 503 InitCatalog(std::move(catalog)); | 503 InitCatalog(std::move(catalog)); |
| 504 } | 504 } |
| 505 | 505 |
| 506 ServiceManager::~ServiceManager() { | 506 ServiceManager::~ServiceManager() { |
| 507 TerminateServiceManagerConnections(); | 507 TerminateServiceManagerConnections(); |
| 508 // Terminate any remaining instances. | 508 // Terminate any remaining instances. |
| 509 while (!identity_to_instance_.empty()) | 509 while (!identity_to_instance_.empty()) |
| 510 OnInstanceError(identity_to_instance_.begin()->second); | 510 OnInstanceError(identity_to_instance_.begin()->second); |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 798 // Now that the instance has a Service, we can connect to it. | 798 // Now that the instance has a Service, we can connect to it. |
| 799 bool connected = instance->ConnectToService(¶ms); | 799 bool connected = instance->ConnectToService(¶ms); |
| 800 DCHECK(connected); | 800 DCHECK(connected); |
| 801 } | 801 } |
| 802 | 802 |
| 803 base::WeakPtr<ServiceManager> ServiceManager::GetWeakPtr() { | 803 base::WeakPtr<ServiceManager> ServiceManager::GetWeakPtr() { |
| 804 return weak_ptr_factory_.GetWeakPtr(); | 804 return weak_ptr_factory_.GetWeakPtr(); |
| 805 } | 805 } |
| 806 | 806 |
| 807 } // namespace shell | 807 } // namespace shell |
| OLD | NEW |