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 {
@Test
@MediumTest
@Feature({"ServicificationStartup"})
@CommandLineFlags.
Add({"enable-features=NetworkService,NetworkServiceInProcess,AllowStartingServiceManagerOnly"})
@CommandLineFlags.Add({"enable-features=NetworkService,AllowStartingServiceManagerOnly"})
public void testSeriveManagerStarts() {
startOnRunTaskAndVerify(ServiceManagerStartupUtils.TASK_TAG, true);
}
......
......@@ -83,8 +83,7 @@ public final class ServicificationDownloadTest {
@Test
@LargeTest
@Feature({"Download"})
@CommandLineFlags.
Add({"enable-features=NetworkService,NetworkServiceInProcess,AllowStartingServiceManagerOnly"})
@CommandLineFlags.Add({"enable-features=NetworkService,AllowStartingServiceManagerOnly"})
public void testResumeInterruptedDownload() {
mServicificationBackgroundService.onRunTask(
new TaskParams(ServiceManagerStartupUtils.TASK_TAG));
......
......@@ -9,6 +9,7 @@ include_rules = [
"+gin/public/isolate_holder.h",
"+gin/public/snapshot_fd_data.h",
"+gin/v8_initializer.h",
"+services/network/public/cpp/features.h",
"+services/service_manager/embedder",
"+services/service_manager/runner/common",
"+services/service_manager/sandbox/sandbox_type.h",
......
......@@ -56,11 +56,13 @@
#include "content/public/common/content_paths.h"
#include "content/public/common/content_switches.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 "gin/v8_initializer.h"
#include "media/base/media.h"
#include "media/media_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/sandbox/sandbox_type.h"
#include "services/service_manager/sandbox/switches.h"
......@@ -875,6 +877,7 @@ int ContentMainRunnerImpl::RunServiceManager(MainFunctionParams& main_params,
if (is_browser_main_loop_started_)
return -1;
bool should_start_service_manager_only = start_service_manager_only;
if (!service_manager_context_) {
if (delegate_->ShouldCreateFeatureList()) {
DCHECK(!field_trial_list_);
......@@ -915,6 +918,17 @@ int ContentMainRunnerImpl::RunServiceManager(MainFunctionParams& main_params,
// incorrect to post to a BrowserThread before this point.
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
// BrowserMain() which may elect to promote it (e.g. to BrowserThread::IO).
service_manager_thread_ = BrowserProcessSubThread::CreateIOThread();
......@@ -927,11 +941,8 @@ int ContentMainRunnerImpl::RunServiceManager(MainFunctionParams& main_params,
#endif
}
if (base::FeatureList::IsEnabled(
features::kAllowStartingServiceManagerOnly) &&
start_service_manager_only) {
if (should_start_service_manager_only)
return -1;
}
is_browser_main_loop_started_ = true;
startup_data_ = std::make_unique<StartupDataImpl>();
......
......@@ -27,6 +27,10 @@ constexpr base::FeatureParam<int> kNetworkServiceOutOfProcessThresholdMb{
1077};
#endif
// Indicates whether the network service is forced to be running in the browser
// process.
bool g_force_in_process_network_service = false;
} // namespace
bool IsOutOfProcessNetworkService() {
......@@ -38,7 +42,8 @@ bool IsInProcessNetworkService() {
if (!base::FeatureList::IsEnabled(network::features::kNetworkService))
return false;
if (base::FeatureList::IsEnabled(features::kNetworkServiceInProcess) ||
if (g_force_in_process_network_service ||
base::FeatureList::IsEnabled(features::kNetworkServiceInProcess) ||
base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kSingleProcess)) {
return true;
......@@ -51,4 +56,8 @@ bool IsInProcessNetworkService() {
return false;
}
void ForceInProcessNetworkService(bool is_forced) {
g_force_in_process_network_service = is_forced;
}
} // namespace content
......@@ -17,6 +17,9 @@ CONTENT_EXPORT bool IsOutOfProcessNetworkService();
// browser process.
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
#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