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 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 // ServiceManager, public: | 507 // ServiceManager, public: |
508 | 508 |
509 ServiceManager::ServiceManager( | 509 ServiceManager::ServiceManager( |
510 std::unique_ptr<ServiceProcessLauncherFactory> | 510 std::unique_ptr<ServiceProcessLauncherFactory> |
511 service_process_launcher_factory, | 511 service_process_launcher_factory, |
512 mojom::ServicePtr catalog) | 512 mojom::ServicePtr catalog) |
513 : service_process_launcher_factory_( | 513 : service_process_launcher_factory_( |
514 std::move(service_process_launcher_factory)), | 514 std::move(service_process_launcher_factory)), |
515 weak_ptr_factory_(this) { | 515 weak_ptr_factory_(this) { |
516 mojom::ServicePtr service; | 516 mojom::ServicePtr service; |
517 mojom::ServiceRequest request = mojo::MakeRequest(&service); | 517 mojom::ServiceRequest request(&service); |
518 | 518 |
519 InterfaceProviderSpec spec; | 519 InterfaceProviderSpec spec; |
520 spec.provides[kCapability_ServiceManager].insert( | 520 spec.provides[kCapability_ServiceManager].insert( |
521 "service_manager::mojom::ServiceManager"); | 521 "service_manager::mojom::ServiceManager"); |
522 spec.requires["*"].insert("service_manager:service_factory"); | 522 spec.requires["*"].insert("service_manager:service_factory"); |
523 spec.requires[catalog::mojom::kServiceName].insert( | 523 spec.requires[catalog::mojom::kServiceName].insert( |
524 "service_manager:resolver"); | 524 "service_manager:resolver"); |
525 spec.requires[tracing::mojom::kServiceName].insert("app"); | 525 spec.requires[tracing::mojom::kServiceName].insert("app"); |
526 InterfaceProviderSpecMap specs; | 526 InterfaceProviderSpecMap specs; |
527 specs[mojom::kServiceManager_ConnectorSpec] = spec; | 527 specs[mojom::kServiceManager_ConnectorSpec] = spec; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 | 574 |
575 mojom::ServiceRequest ServiceManager::StartEmbedderService( | 575 mojom::ServiceRequest ServiceManager::StartEmbedderService( |
576 const std::string& name) { | 576 const std::string& name) { |
577 std::unique_ptr<ConnectParams> params(new ConnectParams); | 577 std::unique_ptr<ConnectParams> params(new ConnectParams); |
578 | 578 |
579 Identity embedder_identity(name, mojom::kRootUserID); | 579 Identity embedder_identity(name, mojom::kRootUserID); |
580 params->set_source(embedder_identity); | 580 params->set_source(embedder_identity); |
581 params->set_target(embedder_identity); | 581 params->set_target(embedder_identity); |
582 | 582 |
583 mojom::ServicePtr service; | 583 mojom::ServicePtr service; |
584 mojom::ServiceRequest request = mojo::MakeRequest(&service); | 584 mojom::ServiceRequest request(&service); |
585 Connect(std::move(params), std::move(service), nullptr); | 585 Connect(std::move(params), std::move(service), nullptr); |
586 | 586 |
587 return request; | 587 return request; |
588 } | 588 } |
589 | 589 |
590 //////////////////////////////////////////////////////////////////////////////// | 590 //////////////////////////////////////////////////////////////////////////////// |
591 // ServiceManager, private: | 591 // ServiceManager, private: |
592 | 592 |
593 void ServiceManager::InitCatalog(mojom::ServicePtr catalog) { | 593 void ServiceManager::InitCatalog(mojom::ServicePtr catalog) { |
594 // TODO(beng): It'd be great to build this from the manifest, however there's | 594 // TODO(beng): It'd be great to build this from the manifest, however there's |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
872 // If a ServicePtr was provided, there's no more work to do: someone | 872 // If a ServicePtr was provided, there's no more work to do: someone |
873 // is already holding a corresponding ServiceRequest. | 873 // is already holding a corresponding ServiceRequest. |
874 instance->StartWithService(std::move(service)); | 874 instance->StartWithService(std::move(service)); |
875 } else if (!client_process_connection.is_null()) { | 875 } else if (!client_process_connection.is_null()) { |
876 // Likewise if a ClientProcessConnection was given via Connect(), it | 876 // Likewise if a ClientProcessConnection was given via Connect(), it |
877 // provides the Service proxy to use. | 877 // provides the Service proxy to use. |
878 instance->StartWithClientProcessConnection( | 878 instance->StartWithClientProcessConnection( |
879 std::move(client_process_connection)); | 879 std::move(client_process_connection)); |
880 } else { | 880 } else { |
881 // Otherwise we create a new Service pipe. | 881 // Otherwise we create a new Service pipe. |
882 mojom::ServiceRequest request = MakeRequest(&service); | 882 mojom::ServiceRequest request(&service); |
883 CHECK(!result->package_path.empty()); | 883 CHECK(!result->package_path.empty()); |
884 | 884 |
885 // The catalog was unable to read a manifest for this service. We can't do | 885 // The catalog was unable to read a manifest for this service. We can't do |
886 // anything more. | 886 // anything more. |
887 // TODO(beng): There may be some cases where it's valid to have an empty | 887 // TODO(beng): There may be some cases where it's valid to have an empty |
888 // spec, so we should probably include a return value in |result|. | 888 // spec, so we should probably include a return value in |result|. |
889 if (result->interface_provider_specs.empty()) { | 889 if (result->interface_provider_specs.empty()) { |
890 LOG(ERROR) | 890 LOG(ERROR) |
891 << "Error: The catalog was unable to read a manifest for service \"" | 891 << "Error: The catalog was unable to read a manifest for service \"" |
892 << result->name << "\"."; | 892 << result->name << "\"."; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
940 // Now that the instance has a Service, we can connect to it. | 940 // Now that the instance has a Service, we can connect to it. |
941 bool connected = instance->ConnectToService(¶ms); | 941 bool connected = instance->ConnectToService(¶ms); |
942 DCHECK(connected); | 942 DCHECK(connected); |
943 } | 943 } |
944 | 944 |
945 base::WeakPtr<ServiceManager> ServiceManager::GetWeakPtr() { | 945 base::WeakPtr<ServiceManager> ServiceManager::GetWeakPtr() { |
946 return weak_ptr_factory_.GetWeakPtr(); | 946 return weak_ptr_factory_.GetWeakPtr(); |
947 } | 947 } |
948 | 948 |
949 } // namespace service_manager | 949 } // namespace service_manager |
OLD | NEW |