Fix SystemNetworkContextManager initialization timing (see issue #2622).

This commit is contained in:
Marshall Greenblatt 2019-05-02 12:16:44 -04:00
parent 5ce52bd775
commit b1018ad64b
2 changed files with 8 additions and 9 deletions

View File

@ -27,7 +27,9 @@
#include "base/message_loop/message_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/task/post_task.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_browser_main_extra_parts.h"
#include "chrome/browser/net/system_network_context_manager.h"
#include "chrome/browser/plugins/plugin_finder.h"
#include "content/public/browser/gpu_data_manager.h"
#include "extensions/browser/extension_system.h"
@ -153,9 +155,13 @@ int CefBrowserMainParts::PreCreateThreads() {
net::NetModule::SetResourceProvider(&NetResourceProvider);
// Initialize the GpuDataManager before IO access restrictions are applied and
// Initialize these objects before IO access restrictions are applied and
// before the IO thread is started.
content::GpuDataManager::GetInstance();
if (net_service::IsEnabled()) {
SystemNetworkContextManager::CreateInstance(
g_browser_process->local_state());
}
for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
chrome_extra_parts_[i]->PreCreateThreads();

View File

@ -1290,15 +1290,8 @@ void CefContentBrowserClient::OnNetworkServiceCreated(
PrefService* local_state = g_browser_process->local_state();
DCHECK(local_state);
if (!SystemNetworkContextManager::GetInstance()) {
// TODO(network): This triggers creation of ChromeBrowserPolicyConnector via
// ChromeBrowserProcessStub::policy_service() which loads some system DLLs
// on Windows. Determine the correct initialization timing to avoid the need
// for ScopedAllowIO here.
base::ThreadRestrictions::ScopedAllowIO allow_io;
SystemNetworkContextManager::CreateInstance(local_state);
}
// Need to set up global NetworkService state before anything else uses it.
DCHECK(SystemNetworkContextManager::GetInstance());
SystemNetworkContextManager::GetInstance()->OnNetworkServiceCreated(
network_service);
}