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

Side by Side Diff: content/utility/utility_service_factory.cc

Issue 2960703003: Add a feature flag for network service and about:flags entry for it. (Closed)
Patch Set: merge Created 3 years, 5 months 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
« no previous file with comments | « content/renderer/renderer_blink_platform_impl.cc ('k') | testing/buildbot/chromium.fyi.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/utility/utility_service_factory.h" 5 #include "content/utility/utility_service_factory.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "content/child/child_process.h" 9 #include "content/child/child_process.h"
10 #include "content/network/network_service.h" 10 #include "content/network/network_service.h"
11 #include "content/public/common/content_client.h" 11 #include "content/public/common/content_client.h"
12 #include "content/public/common/content_features.h"
12 #include "content/public/common/content_switches.h" 13 #include "content/public/common/content_switches.h"
13 #include "content/public/common/service_names.mojom.h" 14 #include "content/public/common/service_names.mojom.h"
14 #include "content/public/utility/content_utility_client.h" 15 #include "content/public/utility/content_utility_client.h"
15 #include "content/public/utility/utility_thread.h" 16 #include "content/public/utility/utility_thread.h"
16 #include "content/utility/utility_thread_impl.h" 17 #include "content/utility/utility_thread_impl.h"
17 #include "ppapi/features/features.h" 18 #include "ppapi/features/features.h"
18 #include "services/data_decoder/data_decoder_service.h" 19 #include "services/data_decoder/data_decoder_service.h"
19 #include "services/data_decoder/public/interfaces/constants.mojom.h" 20 #include "services/data_decoder/public/interfaces/constants.mojom.h"
20 #include "services/shape_detection/public/interfaces/constants.mojom.h" 21 #include "services/shape_detection/public/interfaces/constants.mojom.h"
21 #include "services/shape_detection/shape_detection_service.h" 22 #include "services/shape_detection/shape_detection_service.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 shape_detection_info.factory = 101 shape_detection_info.factory =
101 base::Bind(&shape_detection::ShapeDetectionService::Create); 102 base::Bind(&shape_detection::ShapeDetectionService::Create);
102 services->insert(std::make_pair(shape_detection::mojom::kServiceName, 103 services->insert(std::make_pair(shape_detection::mojom::kServiceName,
103 shape_detection_info)); 104 shape_detection_info));
104 105
105 service_manager::EmbeddedServiceInfo data_decoder_info; 106 service_manager::EmbeddedServiceInfo data_decoder_info;
106 data_decoder_info.factory = base::Bind(&CreateDataDecoderService); 107 data_decoder_info.factory = base::Bind(&CreateDataDecoderService);
107 services->insert( 108 services->insert(
108 std::make_pair(data_decoder::mojom::kServiceName, data_decoder_info)); 109 std::make_pair(data_decoder::mojom::kServiceName, data_decoder_info));
109 110
110 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 111 if (base::FeatureList::IsEnabled(features::kNetworkService)) {
111 switches::kEnableNetworkService)) {
112 GetContentClient()->utility()->RegisterNetworkBinders( 112 GetContentClient()->utility()->RegisterNetworkBinders(
113 network_registry_.get()); 113 network_registry_.get());
114 service_manager::EmbeddedServiceInfo network_info; 114 service_manager::EmbeddedServiceInfo network_info;
115 network_info.factory = base::Bind( 115 network_info.factory = base::Bind(
116 &UtilityServiceFactory::CreateNetworkService, base::Unretained(this)); 116 &UtilityServiceFactory::CreateNetworkService, base::Unretained(this));
117 network_info.task_runner = ChildProcess::current()->io_task_runner(); 117 network_info.task_runner = ChildProcess::current()->io_task_runner();
118 services->insert( 118 services->insert(
119 std::make_pair(content::mojom::kNetworkServiceName, network_info)); 119 std::make_pair(content::mojom::kNetworkServiceName, network_info));
120 } 120 }
121 } 121 }
122 122
123 void UtilityServiceFactory::OnServiceQuit() { 123 void UtilityServiceFactory::OnServiceQuit() {
124 UtilityThread::Get()->ReleaseProcessIfNeeded(); 124 UtilityThread::Get()->ReleaseProcessIfNeeded();
125 } 125 }
126 126
127 void UtilityServiceFactory::OnLoadFailed() { 127 void UtilityServiceFactory::OnLoadFailed() {
128 UtilityThreadImpl* utility_thread = 128 UtilityThreadImpl* utility_thread =
129 static_cast<UtilityThreadImpl*>(UtilityThread::Get()); 129 static_cast<UtilityThreadImpl*>(UtilityThread::Get());
130 utility_thread->Shutdown(); 130 utility_thread->Shutdown();
131 utility_thread->ReleaseProcessIfNeeded(); 131 utility_thread->ReleaseProcessIfNeeded();
132 } 132 }
133 133
134 std::unique_ptr<service_manager::Service> 134 std::unique_ptr<service_manager::Service>
135 UtilityServiceFactory::CreateNetworkService() { 135 UtilityServiceFactory::CreateNetworkService() {
136 return base::MakeUnique<NetworkService>(std::move(network_registry_)); 136 return base::MakeUnique<NetworkService>(std::move(network_registry_));
137 } 137 }
138 138
139 } // namespace content 139 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/renderer_blink_platform_impl.cc ('k') | testing/buildbot/chromium.fyi.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698