OLD | NEW |
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/child/service_factory.h" | 5 #include "content/child/service_factory.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
11 #include "content/common/mojo/embedded_application_runner.h" | 11 #include "content/common/service_manager/embedded_service_runner.h" |
12 #include "content/public/common/content_client.h" | 12 #include "content/public/common/content_client.h" |
13 | 13 |
14 namespace content { | 14 namespace content { |
15 | 15 |
16 ServiceFactory::ServiceFactory() {} | 16 ServiceFactory::ServiceFactory() {} |
17 ServiceFactory::~ServiceFactory() {} | 17 ServiceFactory::~ServiceFactory() {} |
18 | 18 |
19 void ServiceFactory::CreateService(shell::mojom::ServiceRequest request, | 19 void ServiceFactory::CreateService(shell::mojom::ServiceRequest request, |
20 const std::string& name) { | 20 const std::string& name) { |
21 // Only register services on first run. | 21 // Only register services on first run. |
22 if (!has_registered_services_) { | 22 if (!has_registered_services_) { |
23 DCHECK(services_.empty()); | 23 DCHECK(services_.empty()); |
24 ServiceMap services; | 24 ServiceMap services; |
25 RegisterServices(&services); | 25 RegisterServices(&services); |
26 for (const auto& service : services) { | 26 for (const auto& service : services) { |
27 std::unique_ptr<EmbeddedApplicationRunner> runner( | 27 std::unique_ptr<EmbeddedServiceRunner> runner( |
28 new EmbeddedApplicationRunner(service.first, service.second)); | 28 new EmbeddedServiceRunner(service.first, service.second)); |
29 runner->SetQuitClosure(base::Bind(&ServiceFactory::OnServiceQuit, | 29 runner->SetQuitClosure(base::Bind(&ServiceFactory::OnServiceQuit, |
30 base::Unretained(this))); | 30 base::Unretained(this))); |
31 services_.insert(std::make_pair(service.first, std::move(runner))); | 31 services_.insert(std::make_pair(service.first, std::move(runner))); |
32 } | 32 } |
33 has_registered_services_ = true; | 33 has_registered_services_ = true; |
34 } | 34 } |
35 | 35 |
36 auto it = services_.find(name); | 36 auto it = services_.find(name); |
37 if (it == services_.end()) { | 37 if (it == services_.end()) { |
38 OnLoadFailed(); | 38 OnLoadFailed(); |
39 return; | 39 return; |
40 } | 40 } |
41 | 41 |
42 it->second->BindServiceRequest(std::move(request)); | 42 it->second->BindServiceRequest(std::move(request)); |
43 } | 43 } |
44 | 44 |
45 } // namespace content | 45 } // namespace content |
OLD | NEW |