Commit 6975304c authored by Xi Han's avatar Xi Han Committed by Commit Bot

Force NetworkService run in process in ServiceManager only mode.

Foces ServiceManager to register NetworkService as a in process service when
running in the ServiceManager only mode.

Bug: 846846
Change-Id: I9693bbcb3d0379fc293b2277d5dd513a03d3fe8c
Reviewed-on: https://chromium-review.googlesource.com/c/1368455Reviewed-by: default avatarKen Rockot <rockot@google.com>
Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Reviewed-by: default avatarMin Qin <qinmin@chromium.org>
Commit-Queue: Xi Han <hanxi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#615640}
parent 531fa924
...@@ -50,8 +50,7 @@ public final class ServicificationBackgroundServiceTest { ...@@ -50,8 +50,7 @@ public final class ServicificationBackgroundServiceTest {
@Test @Test
@MediumTest @MediumTest
@Feature({"ServicificationStartup"}) @Feature({"ServicificationStartup"})
@CommandLineFlags. @CommandLineFlags.Add({"enable-features=NetworkService,AllowStartingServiceManagerOnly"})
Add({"enable-features=NetworkService,NetworkServiceInProcess,AllowStartingServiceManagerOnly"})
public void testSeriveManagerStarts() { public void testSeriveManagerStarts() {
startOnRunTaskAndVerify(ServiceManagerStartupUtils.TASK_TAG, true); startOnRunTaskAndVerify(ServiceManagerStartupUtils.TASK_TAG, true);
} }
......
...@@ -83,8 +83,7 @@ public final class ServicificationDownloadTest { ...@@ -83,8 +83,7 @@ public final class ServicificationDownloadTest {
@Test @Test
@LargeTest @LargeTest
@Feature({"Download"}) @Feature({"Download"})
@CommandLineFlags. @CommandLineFlags.Add({"enable-features=NetworkService,AllowStartingServiceManagerOnly"})
Add({"enable-features=NetworkService,NetworkServiceInProcess,AllowStartingServiceManagerOnly"})
public void testResumeInterruptedDownload() { public void testResumeInterruptedDownload() {
mServicificationBackgroundService.onRunTask( mServicificationBackgroundService.onRunTask(
new TaskParams(ServiceManagerStartupUtils.TASK_TAG)); new TaskParams(ServiceManagerStartupUtils.TASK_TAG));
......
...@@ -9,6 +9,7 @@ include_rules = [ ...@@ -9,6 +9,7 @@ include_rules = [
"+gin/public/isolate_holder.h", "+gin/public/isolate_holder.h",
"+gin/public/snapshot_fd_data.h", "+gin/public/snapshot_fd_data.h",
"+gin/v8_initializer.h", "+gin/v8_initializer.h",
"+services/network/public/cpp/features.h",
"+services/service_manager/embedder", "+services/service_manager/embedder",
"+services/service_manager/runner/common", "+services/service_manager/runner/common",
"+services/service_manager/sandbox/sandbox_type.h", "+services/service_manager/sandbox/sandbox_type.h",
......
...@@ -56,11 +56,13 @@ ...@@ -56,11 +56,13 @@
#include "content/public/common/content_paths.h" #include "content/public/common/content_paths.h"
#include "content/public/common/content_switches.h" #include "content/public/common/content_switches.h"
#include "content/public/common/main_function_params.h" #include "content/public/common/main_function_params.h"
#include "content/public/common/network_service_util.h"
#include "content/public/common/sandbox_init.h" #include "content/public/common/sandbox_init.h"
#include "gin/v8_initializer.h" #include "gin/v8_initializer.h"
#include "media/base/media.h" #include "media/base/media.h"
#include "media/media_buildflags.h" #include "media/media_buildflags.h"
#include "ppapi/buildflags/buildflags.h" #include "ppapi/buildflags/buildflags.h"
#include "services/network/public/cpp/features.h"
#include "services/service_manager/embedder/switches.h" #include "services/service_manager/embedder/switches.h"
#include "services/service_manager/sandbox/sandbox_type.h" #include "services/service_manager/sandbox/sandbox_type.h"
#include "services/service_manager/sandbox/switches.h" #include "services/service_manager/sandbox/switches.h"
...@@ -875,6 +877,7 @@ int ContentMainRunnerImpl::RunServiceManager(MainFunctionParams& main_params, ...@@ -875,6 +877,7 @@ int ContentMainRunnerImpl::RunServiceManager(MainFunctionParams& main_params,
if (is_browser_main_loop_started_) if (is_browser_main_loop_started_)
return -1; return -1;
bool should_start_service_manager_only = start_service_manager_only;
if (!service_manager_context_) { if (!service_manager_context_) {
if (delegate_->ShouldCreateFeatureList()) { if (delegate_->ShouldCreateFeatureList()) {
DCHECK(!field_trial_list_); DCHECK(!field_trial_list_);
...@@ -915,6 +918,17 @@ int ContentMainRunnerImpl::RunServiceManager(MainFunctionParams& main_params, ...@@ -915,6 +918,17 @@ int ContentMainRunnerImpl::RunServiceManager(MainFunctionParams& main_params,
// incorrect to post to a BrowserThread before this point. // incorrect to post to a BrowserThread before this point.
BrowserTaskExecutor::Create(); BrowserTaskExecutor::Create();
if (!base::FeatureList::IsEnabled(
features::kAllowStartingServiceManagerOnly)) {
should_start_service_manager_only = false;
}
if (should_start_service_manager_only &&
base::FeatureList::IsEnabled(network::features::kNetworkService)) {
// This must be called before creating the ServiceManagerContext.
ForceInProcessNetworkService(true);
}
// The thread used to start the ServiceManager is handed-off to // The thread used to start the ServiceManager is handed-off to
// BrowserMain() which may elect to promote it (e.g. to BrowserThread::IO). // BrowserMain() which may elect to promote it (e.g. to BrowserThread::IO).
service_manager_thread_ = BrowserProcessSubThread::CreateIOThread(); service_manager_thread_ = BrowserProcessSubThread::CreateIOThread();
...@@ -927,11 +941,8 @@ int ContentMainRunnerImpl::RunServiceManager(MainFunctionParams& main_params, ...@@ -927,11 +941,8 @@ int ContentMainRunnerImpl::RunServiceManager(MainFunctionParams& main_params,
#endif #endif
} }
if (base::FeatureList::IsEnabled( if (should_start_service_manager_only)
features::kAllowStartingServiceManagerOnly) &&
start_service_manager_only) {
return -1; return -1;
}
is_browser_main_loop_started_ = true; is_browser_main_loop_started_ = true;
startup_data_ = std::make_unique<StartupDataImpl>(); startup_data_ = std::make_unique<StartupDataImpl>();
......
...@@ -27,6 +27,10 @@ constexpr base::FeatureParam<int> kNetworkServiceOutOfProcessThresholdMb{ ...@@ -27,6 +27,10 @@ constexpr base::FeatureParam<int> kNetworkServiceOutOfProcessThresholdMb{
1077}; 1077};
#endif #endif
// Indicates whether the network service is forced to be running in the browser
// process.
bool g_force_in_process_network_service = false;
} // namespace } // namespace
bool IsOutOfProcessNetworkService() { bool IsOutOfProcessNetworkService() {
...@@ -38,7 +42,8 @@ bool IsInProcessNetworkService() { ...@@ -38,7 +42,8 @@ bool IsInProcessNetworkService() {
if (!base::FeatureList::IsEnabled(network::features::kNetworkService)) if (!base::FeatureList::IsEnabled(network::features::kNetworkService))
return false; return false;
if (base::FeatureList::IsEnabled(features::kNetworkServiceInProcess) || if (g_force_in_process_network_service ||
base::FeatureList::IsEnabled(features::kNetworkServiceInProcess) ||
base::CommandLine::ForCurrentProcess()->HasSwitch( base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kSingleProcess)) { switches::kSingleProcess)) {
return true; return true;
...@@ -51,4 +56,8 @@ bool IsInProcessNetworkService() { ...@@ -51,4 +56,8 @@ bool IsInProcessNetworkService() {
return false; return false;
} }
void ForceInProcessNetworkService(bool is_forced) {
g_force_in_process_network_service = is_forced;
}
} // namespace content } // namespace content
...@@ -17,6 +17,9 @@ CONTENT_EXPORT bool IsOutOfProcessNetworkService(); ...@@ -17,6 +17,9 @@ CONTENT_EXPORT bool IsOutOfProcessNetworkService();
// browser process. // browser process.
CONTENT_EXPORT bool IsInProcessNetworkService(); CONTENT_EXPORT bool IsInProcessNetworkService();
// Sets the flag of whether the network service is forced to be running in the
// browser process. The flag will be checked in |IsInProcessNetworkService()|.
void ForceInProcessNetworkService(bool is_forced);
} // namespace content } // namespace content
#endif // CONTENT_PUBLIC_COMMON_NETWORK_SERVICE_UTIL_H_ #endif // CONTENT_PUBLIC_COMMON_NETWORK_SERVICE_UTIL_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment