Remove most of the code to create URLRequestContexts in src/chrome.
This code isn't needed anymore. There's still a lot of related code left; I'm stopping at this point to keep changes manageable to review.
Bug: 934009
Change-Id: Ibe2b5861fa45f0bd8e67f86aed1d52c256b2e0a1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1640718
Reviewed-by: Matt Menke <[email protected]>
Reviewed-by: Reilly Grant <[email protected]>
Commit-Queue: John Abd-El-Malek <[email protected]>
Cr-Commit-Position: refs/heads/master@{#665704}
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn
index beab18d..33458e2a 100644
--- a/chrome/browser/BUILD.gn
+++ b/chrome/browser/BUILD.gn
@@ -830,8 +830,6 @@
"net/chrome_network_delegate.h",
"net/chrome_report_sender.cc",
"net/chrome_report_sender.h",
- "net/chrome_url_request_context_getter.cc",
- "net/chrome_url_request_context_getter.h",
"net/dns_probe_runner.cc",
"net/dns_probe_runner.h",
"net/dns_probe_service.h",
diff --git a/chrome/browser/chromeos/profiles/profile_helper.cc b/chrome/browser/chromeos/profiles/profile_helper.cc
index 5e6389b4..8ca5b64 100644
--- a/chrome/browser/chromeos/profiles/profile_helper.cc
+++ b/chrome/browser/chromeos/profiles/profile_helper.cc
@@ -538,7 +538,6 @@
excludes.push_back(base::FilePath(chrome::kPreferencesFilename));
// Do not flush cache files.
excludes.push_back(base::FilePath(chrome::kCacheDirname));
- excludes.push_back(base::FilePath(chrome::kMediaCacheDirname));
excludes.push_back(base::FilePath(FILE_PATH_LITERAL("GPUCache")));
// Do not flush user Downloads.
excludes.push_back(
diff --git a/chrome/browser/extensions/active_tab_apitest.cc b/chrome/browser/extensions/active_tab_apitest.cc
index eab62fdc..ce868d38 100644
--- a/chrome/browser/extensions/active_tab_apitest.cc
+++ b/chrome/browser/extensions/active_tab_apitest.cc
@@ -55,10 +55,8 @@
std::vector<base::Feature> disabled_features;
if (ShouldEnableOutOfBlinkCors()) {
enabled_features.push_back(network::features::kOutOfBlinkCors);
- enabled_features.push_back(network::features::kNetworkService);
} else {
disabled_features.push_back(network::features::kOutOfBlinkCors);
- disabled_features.push_back(network::features::kNetworkService);
}
scoped_feature_list_.InitWithFeatures(enabled_features, disabled_features);
ExtensionApiTest::SetUp();
@@ -72,8 +70,6 @@
ASSERT_EQ(ShouldEnableOutOfBlinkCors(),
base::FeatureList::IsEnabled(network::features::kOutOfBlinkCors));
- ASSERT_EQ(ShouldEnableOutOfBlinkCors(),
- base::FeatureList::IsEnabled(network::features::kNetworkService));
}
private:
diff --git a/chrome/browser/extensions/background_xhr_browsertest.cc b/chrome/browser/extensions/background_xhr_browsertest.cc
index 6285b64..41b2527 100644
--- a/chrome/browser/extensions/background_xhr_browsertest.cc
+++ b/chrome/browser/extensions/background_xhr_browsertest.cc
@@ -47,7 +47,6 @@
enum class TestMode {
kWithoutAny,
kWithOutOfBlinkCors,
- kWithOutOfBlinkCorsAndNetworkService,
};
std::unique_ptr<net::ClientCertStore> CreateNullCertStore() {
@@ -134,15 +133,9 @@
switch (GetParam()) {
case TestMode::kWithoutAny:
disabled_features.push_back(network::features::kOutOfBlinkCors);
- disabled_features.push_back(network::features::kNetworkService);
break;
case TestMode::kWithOutOfBlinkCors:
enabled_features.push_back(network::features::kOutOfBlinkCors);
- disabled_features.push_back(network::features::kNetworkService);
- break;
- case TestMode::kWithOutOfBlinkCorsAndNetworkService:
- enabled_features.push_back(network::features::kOutOfBlinkCors);
- enabled_features.push_back(network::features::kNetworkService);
break;
}
scoped_feature_list_.InitWithFeatures(enabled_features, disabled_features);
@@ -467,9 +460,5 @@
INSTANTIATE_TEST_SUITE_P(WithOutOfBlinkCors,
BackgroundXhrWebstoreTest,
testing::Values(TestMode::kWithOutOfBlinkCors));
-INSTANTIATE_TEST_SUITE_P(
- WithOutOfBlinkCorsAndNetworkService,
- BackgroundXhrWebstoreTest,
- testing::Values(TestMode::kWithOutOfBlinkCorsAndNetworkService));
} // namespace extensions
diff --git a/chrome/browser/loader/signed_exchange_policy_browsertest.cc b/chrome/browser/loader/signed_exchange_policy_browsertest.cc
index 9d65bae..7ef1efa 100644
--- a/chrome/browser/loader/signed_exchange_policy_browsertest.cc
+++ b/chrome/browser/loader/signed_exchange_policy_browsertest.cc
@@ -3,7 +3,6 @@
// found in the LICENSE file.
#include "base/strings/utf_string_conversions.h"
-#include "base/test/scoped_feature_list.h"
#include "base/values.h"
#include "chrome/browser/ssl/cert_verifier_browser_test.h"
#include "chrome/browser/ui/browser.h"
@@ -14,17 +13,8 @@
#include "components/policy/policy_constants.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/signed_exchange_browser_test_helper.h"
-#include "services/network/public/cpp/features.h"
-struct SignedExchangePolicyBrowserTestParam {
- explicit SignedExchangePolicyBrowserTestParam(bool network_service_enabled)
- : network_service_enabled(network_service_enabled) {}
- const bool network_service_enabled;
-};
-
-class SignedExchangePolicyBrowserTest
- : public CertVerifierBrowserTest,
- public testing::WithParamInterface<SignedExchangePolicyBrowserTestParam> {
+class SignedExchangePolicyBrowserTest : public CertVerifierBrowserTest {
public:
SignedExchangePolicyBrowserTest() = default;
~SignedExchangePolicyBrowserTest() override = default;
@@ -48,14 +38,6 @@
private:
void SetUp() override {
- std::vector<base::Feature> enable_features;
- std::vector<base::Feature> disable_features;
- if (GetParam().network_service_enabled) {
- enable_features.push_back(network::features::kNetworkService);
- } else {
- disable_features.push_back(network::features::kNetworkService);
- }
- feature_list_.InitWithFeatures(enable_features, disable_features);
sxg_test_helper_.SetUp();
InProcessBrowserTest::SetUp();
}
@@ -64,13 +46,12 @@
sxg_test_helper_.TearDownOnMainThread();
}
- base::test::ScopedFeatureList feature_list_;
content::SignedExchangeBrowserTestHelper sxg_test_helper_;
DISALLOW_COPY_AND_ASSIGN(SignedExchangePolicyBrowserTest);
};
-IN_PROC_BROWSER_TEST_P(SignedExchangePolicyBrowserTest, BlackList) {
+IN_PROC_BROWSER_TEST_F(SignedExchangePolicyBrowserTest, BlackList) {
embedded_test_server()->ServeFilesFromSourceDirectory("content/test/data");
ASSERT_TRUE(embedded_test_server()->Start());
@@ -120,9 +101,3 @@
&result));
EXPECT_TRUE(result);
}
-
-INSTANTIATE_TEST_SUITE_P(
- SignedExchangePolicyBrowserTest,
- SignedExchangePolicyBrowserTest,
- testing::Values(SignedExchangePolicyBrowserTestParam(false),
- SignedExchangePolicyBrowserTestParam(true)));
diff --git a/chrome/browser/net/chrome_url_request_context_getter.cc b/chrome/browser/net/chrome_url_request_context_getter.cc
deleted file mode 100644
index a931ece0..0000000
--- a/chrome/browser/net/chrome_url_request_context_getter.cc
+++ /dev/null
@@ -1,267 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/net/chrome_url_request_context_getter.h"
-
-#include <utility>
-
-#include "base/bind.h"
-#include "base/compiler_specific.h"
-#include "base/macros.h"
-#include "base/task/post_task.h"
-#include "base/threading/thread_task_runner_handle.h"
-#include "chrome/browser/browser_process.h"
-#include "chrome/browser/io_thread.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/profiles/profile_io_data.h"
-#include "chrome/browser/profiles/storage_partition_descriptor.h"
-#include "content/public/browser/browser_task_traits.h"
-#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/storage_partition.h"
-
-using content::BrowserThread;
-
-class ChromeURLRequestContextFactory {
- public:
- ChromeURLRequestContextFactory() {}
- virtual ~ChromeURLRequestContextFactory() {}
-
- // Called to create a new instance (will only be called once).
- virtual net::URLRequestContext* Create() = 0;
-
- protected:
- DISALLOW_COPY_AND_ASSIGN(ChromeURLRequestContextFactory);
-};
-
-namespace {
-
-// ----------------------------------------------------------------------------
-// Helper factories
-// ----------------------------------------------------------------------------
-
-// Factory that creates the main URLRequestContext.
-class FactoryForMain : public ChromeURLRequestContextFactory {
- public:
- FactoryForMain(
- const ProfileIOData* profile_io_data,
- content::ProtocolHandlerMap* protocol_handlers,
- content::URLRequestInterceptorScopedVector request_interceptors)
- : profile_io_data_(profile_io_data),
- request_interceptors_(std::move(request_interceptors)) {
- std::swap(protocol_handlers_, *protocol_handlers);
- }
-
- net::URLRequestContext* Create() override {
- profile_io_data_->Init(&protocol_handlers_,
- std::move(request_interceptors_));
- return profile_io_data_->GetMainRequestContext();
- }
-
- private:
- const ProfileIOData* const profile_io_data_;
- content::ProtocolHandlerMap protocol_handlers_;
- content::URLRequestInterceptorScopedVector request_interceptors_;
-};
-
-// Factory that creates the URLRequestContext for a given isolated app.
-class FactoryForIsolatedApp : public ChromeURLRequestContextFactory {
- public:
- FactoryForIsolatedApp(
- const ProfileIOData* profile_io_data,
- const StoragePartitionDescriptor& partition_descriptor,
- std::unique_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>
- protocol_handler_interceptor,
- content::ProtocolHandlerMap* protocol_handlers,
- content::URLRequestInterceptorScopedVector request_interceptors,
- network::mojom::NetworkContextRequest network_context_request,
- network::mojom::NetworkContextParamsPtr network_context_params)
- : profile_io_data_(profile_io_data),
- partition_descriptor_(partition_descriptor),
- io_thread_(g_browser_process->io_thread()),
- protocol_handler_interceptor_(std::move(protocol_handler_interceptor)),
- request_interceptors_(std::move(request_interceptors)),
- network_context_request_(std::move(network_context_request)),
- network_context_params_(std::move(network_context_params)) {
- std::swap(protocol_handlers_, *protocol_handlers);
- }
-
- net::URLRequestContext* Create() override {
- // We will copy most of the state from the main request context.
- //
- // Note that this factory is one-shot. After Create() is called once, the
- // factory is actually destroyed. Thus it is safe to destructively pass
- // state onwards.
- return profile_io_data_->GetIsolatedAppRequestContext(
- io_thread_, partition_descriptor_,
- std::move(protocol_handler_interceptor_), &protocol_handlers_,
- std::move(request_interceptors_), std::move(network_context_request_),
- std::move(network_context_params_));
- }
-
- private:
- const ProfileIOData* const profile_io_data_;
- const StoragePartitionDescriptor partition_descriptor_;
- IOThread* io_thread_;
- std::unique_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>
- protocol_handler_interceptor_;
- content::ProtocolHandlerMap protocol_handlers_;
- content::URLRequestInterceptorScopedVector request_interceptors_;
- network::mojom::NetworkContextRequest network_context_request_;
- network::mojom::NetworkContextParamsPtr network_context_params_;
-};
-
-// Factory that creates the media URLRequestContext for a given isolated
-// app. The media context is based on the corresponding isolated app's context.
-class FactoryForIsolatedMedia : public ChromeURLRequestContextFactory {
- public:
- FactoryForIsolatedMedia(
- const ProfileIOData* profile_io_data,
- const StoragePartitionDescriptor& partition_descriptor,
- ChromeURLRequestContextGetter* app_context)
- : profile_io_data_(profile_io_data),
- partition_descriptor_(partition_descriptor),
- app_context_getter_(app_context) {}
-
- net::URLRequestContext* Create() override {
- // We will copy most of the state from the corresopnding app's
- // request context. We expect to have the same lifetime as
- // the associated |app_context_getter_| so we can just reuse
- // all its backing objects, including the
- // |protocol_handler_interceptor|. This is why the API
- // looks different from FactoryForIsolatedApp's.
- return profile_io_data_->GetIsolatedMediaRequestContext(
- app_context_getter_->GetURLRequestContext(), partition_descriptor_);
- }
-
- private:
- const ProfileIOData* const profile_io_data_;
- const StoragePartitionDescriptor partition_descriptor_;
- scoped_refptr<ChromeURLRequestContextGetter> app_context_getter_;
-};
-
-// Factory that creates the URLRequestContext for media.
-class FactoryForMedia : public ChromeURLRequestContextFactory {
- public:
- explicit FactoryForMedia(const ProfileIOData* profile_io_data)
- : profile_io_data_(profile_io_data) {
- }
-
- net::URLRequestContext* Create() override {
- return profile_io_data_->GetMediaRequestContext();
- }
-
- private:
- const ProfileIOData* const profile_io_data_;
-};
-
-} // namespace
-
-// ----------------------------------------------------------------------------
-// ChromeURLRequestContextGetter
-// ----------------------------------------------------------------------------
-
-ChromeURLRequestContextGetter::ChromeURLRequestContextGetter()
- : url_request_context_(nullptr) {}
-
-ChromeURLRequestContextGetter::~ChromeURLRequestContextGetter() {
- // NotifyContextShuttingDown() must have been called.
- DCHECK(!url_request_context_);
-}
-
-scoped_refptr<ChromeURLRequestContextGetter>
-ChromeURLRequestContextGetter::CreateAndInit(
- std::unique_ptr<ChromeURLRequestContextFactory> factory) {
- scoped_refptr<ChromeURLRequestContextGetter> url_request_context_getter(
- new ChromeURLRequestContextGetter());
- // This can't be done in the constructor because it's possible for the task to
- // run and complete before the constructor returns, which would reduce the
- // reference count from 1 to 0 on completion, and delete the object
- // immediately.
- base::PostTaskWithTraits(
- FROM_HERE, {content::BrowserThread::IO},
- base::BindOnce(&ChromeURLRequestContextGetter::Init,
- url_request_context_getter, std::move(factory)));
- return url_request_context_getter;
-}
-
-void ChromeURLRequestContextGetter::Init(
- std::unique_ptr<ChromeURLRequestContextFactory> factory) {
- DCHECK(factory);
- DCHECK(!url_request_context_);
-
- url_request_context_ = factory->Create();
-}
-
-// Lazily create a URLRequestContext using our factory.
-net::URLRequestContext*
-ChromeURLRequestContextGetter::GetURLRequestContext() {
- DCHECK_CURRENTLY_ON(BrowserThread::IO);
-
- return url_request_context_;
-}
-
-void ChromeURLRequestContextGetter::NotifyContextShuttingDown() {
- DCHECK_CURRENTLY_ON(BrowserThread::IO);
-
- url_request_context_ = nullptr;
- URLRequestContextGetter::NotifyContextShuttingDown();
-}
-
-scoped_refptr<base::SingleThreadTaskRunner>
-ChromeURLRequestContextGetter::GetNetworkTaskRunner() const {
- return base::CreateSingleThreadTaskRunnerWithTraits({BrowserThread::IO});
-}
-
-// static
-scoped_refptr<ChromeURLRequestContextGetter>
-ChromeURLRequestContextGetter::Create(
- Profile* profile,
- const ProfileIOData* profile_io_data,
- content::ProtocolHandlerMap* protocol_handlers,
- content::URLRequestInterceptorScopedVector request_interceptors) {
- return ChromeURLRequestContextGetter::CreateAndInit(
- std::make_unique<FactoryForMain>(profile_io_data, protocol_handlers,
- std::move(request_interceptors)));
-}
-
-// static
-scoped_refptr<ChromeURLRequestContextGetter>
-ChromeURLRequestContextGetter::CreateForMedia(
- Profile* profile,
- const ProfileIOData* profile_io_data) {
- return ChromeURLRequestContextGetter::CreateAndInit(
- std::make_unique<FactoryForMedia>(profile_io_data));
-}
-
-// static
-scoped_refptr<ChromeURLRequestContextGetter>
-ChromeURLRequestContextGetter::CreateForIsolatedApp(
- Profile* profile,
- const ProfileIOData* profile_io_data,
- const StoragePartitionDescriptor& partition_descriptor,
- std::unique_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>
- protocol_handler_interceptor,
- content::ProtocolHandlerMap* protocol_handlers,
- content::URLRequestInterceptorScopedVector request_interceptors,
- network::mojom::NetworkContextRequest network_context_request,
- network::mojom::NetworkContextParamsPtr network_context_params) {
- return ChromeURLRequestContextGetter::CreateAndInit(
- std::make_unique<FactoryForIsolatedApp>(
- profile_io_data, partition_descriptor,
- std::move(protocol_handler_interceptor), protocol_handlers,
- std::move(request_interceptors), std::move(network_context_request),
- std::move(network_context_params)));
-}
-
-// static
-scoped_refptr<ChromeURLRequestContextGetter>
-ChromeURLRequestContextGetter::CreateForIsolatedMedia(
- Profile* profile,
- ChromeURLRequestContextGetter* app_context,
- const ProfileIOData* profile_io_data,
- const StoragePartitionDescriptor& partition_descriptor) {
- return ChromeURLRequestContextGetter::CreateAndInit(
- std::make_unique<FactoryForIsolatedMedia>(
- profile_io_data, partition_descriptor, app_context));
-}
diff --git a/chrome/browser/net/chrome_url_request_context_getter.h b/chrome/browser/net/chrome_url_request_context_getter.h
deleted file mode 100644
index b17941e..0000000
--- a/chrome/browser/net/chrome_url_request_context_getter.h
+++ /dev/null
@@ -1,103 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_NET_CHROME_URL_REQUEST_CONTEXT_GETTER_H_
-#define CHROME_BROWSER_NET_CHROME_URL_REQUEST_CONTEXT_GETTER_H_
-
-#include <memory>
-#include <string>
-
-#include "base/macros.h"
-#include "base/single_thread_task_runner.h"
-#include "chrome/browser/custom_handlers/protocol_handler_registry.h"
-#include "net/url_request/url_request_context.h"
-#include "net/url_request/url_request_context_getter.h"
-#include "net/url_request/url_request_job_factory.h"
-#include "services/network/public/mojom/network_context.mojom.h"
-
-class ChromeURLRequestContextFactory;
-class Profile;
-class ProfileIOData;
-struct StoragePartitionDescriptor;
-
-// A net::URLRequestContextGetter subclass used by the browser. This returns a
-// subclass of net::URLRequestContext which can be used to store extra
-// information about requests.
-//
-// Most methods are expected to be called on the UI thread, except for
-// the destructor and GetURLRequestContext().
-class ChromeURLRequestContextGetter : public net::URLRequestContextGetter {
- public:
- // Note that GetURLRequestContext() can only be called from the IO
- // thread (it will assert otherwise).
- // GetIOTaskRunner however can be called from any thread.
- //
- // net::URLRequestContextGetter implementation.
- net::URLRequestContext* GetURLRequestContext() override;
- scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner()
- const override;
-
- // Create an instance for use with an 'original' (non-OTR) profile. This is
- // expected to get called on the UI thread.
- static scoped_refptr<ChromeURLRequestContextGetter> Create(
- Profile* profile,
- const ProfileIOData* profile_io_data,
- content::ProtocolHandlerMap* protocol_handlers,
- content::URLRequestInterceptorScopedVector request_interceptors);
-
- // Create an instance for an original profile for media. This is expected to
- // get called on UI thread. This method takes a profile and reuses the
- // 'original' net::URLRequestContext for common files.
- static scoped_refptr<ChromeURLRequestContextGetter> CreateForMedia(
- Profile* profile,
- const ProfileIOData* profile_io_data);
-
- // Create an instance for an original profile for an app with isolated
- // storage. This is expected to get called on UI thread.
- static scoped_refptr<ChromeURLRequestContextGetter> CreateForIsolatedApp(
- Profile* profile,
- const ProfileIOData* profile_io_data,
- const StoragePartitionDescriptor& partition_descriptor,
- std::unique_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>
- protocol_handler_interceptor,
- content::ProtocolHandlerMap* protocol_handlers,
- content::URLRequestInterceptorScopedVector request_interceptors,
- network::mojom::NetworkContextRequest network_context_request,
- network::mojom::NetworkContextParamsPtr network_context_params);
-
- // Create an instance for an original profile for media with isolated
- // storage. This is expected to get called on UI thread.
- static scoped_refptr<ChromeURLRequestContextGetter> CreateForIsolatedMedia(
- Profile* profile,
- ChromeURLRequestContextGetter* app_context,
- const ProfileIOData* profile_io_data,
- const StoragePartitionDescriptor& partition_descriptor);
-
- // Discard reference to URLRequestContext and inform observers of shutdown.
- // Must be called before destruction. May only be called on IO thread.
- void NotifyContextShuttingDown();
-
- private:
- ChromeURLRequestContextGetter();
- ~ChromeURLRequestContextGetter() override;
-
- // Called on IO thread. Calls |factory's| Create method and populates
- // |url_request_context_|, which is actually owned by the ProfileIOData.
- void Init(std::unique_ptr<ChromeURLRequestContextFactory> factory);
-
- // Should be used instead of constructor. Both creates object and triggers
- // initialization on the IO thread.
- static scoped_refptr<ChromeURLRequestContextGetter> CreateAndInit(
- std::unique_ptr<ChromeURLRequestContextFactory> factory);
-
- // NULL before initialization and after invalidation.
- // Otherwise, it is the URLRequestContext instance that was created by the
- // |factory| used by Init(). The object is owned by the ProfileIOData.
- // Access only from the IO thread.
- net::URLRequestContext* url_request_context_;
-
- DISALLOW_COPY_AND_ASSIGN(ChromeURLRequestContextGetter);
-};
-
-#endif // CHROME_BROWSER_NET_CHROME_URL_REQUEST_CONTEXT_GETTER_H_
diff --git a/chrome/browser/net/network_context_configuration_browsertest.cc b/chrome/browser/net/network_context_configuration_browsertest.cc
index f031be5..47539f28 100644
--- a/chrome/browser/net/network_context_configuration_browsertest.cc
+++ b/chrome/browser/net/network_context_configuration_browsertest.cc
@@ -102,7 +102,6 @@
const char kControllablePath[] = "/controllable";
enum class NetworkServiceState {
- kDisabled,
kEnabled,
// Similar to |kEnabled|, but will simulate a crash and run tests again the
// restarted Network Service process.
@@ -181,13 +180,6 @@
~NetworkContextConfigurationBrowserTest() override {}
- void SetUpInProcessBrowserTestFixture() override {
- if (GetParam().network_service_state != NetworkServiceState::kDisabled)
- feature_list_.InitAndEnableFeature(network::features::kNetworkService);
- else
- feature_list_.InitAndDisableFeature(network::features::kNetworkService);
- }
-
void SetUpOnMainThread() override {
// Used in a bunch of proxy tests. Should not resolve.
host_resolver()->AddSimulatedFailure("does.not.resolve.test");
@@ -1041,8 +1033,7 @@
// The network service must be cleanly shut down to guarantee HSTS information
// is flushed to disk, but that currently generally doesn't happen. See
// https://crbug.com/820996.
- if (GetParam().network_service_state != NetworkServiceState::kDisabled &&
- GetHttpCacheType() == StorageType::kDisk) {
+ if (GetHttpCacheType() == StorageType::kDisk) {
return;
}
base::ScopedAllowBlockingForTesting allow_blocking;
@@ -1793,24 +1784,19 @@
}
};
-// Instiates tests with a prefix indicating which NetworkContext is being
+// Instantiates tests with a prefix indicating which NetworkContext is being
// tested, and a suffix of "/0" if the network service is disabled, "/1" if it's
// enabled, and "/2" if it's enabled and restarted.
-#if defined(OS_CHROMEOS)
// There's an extra network change event on ChromeOS, likely from
// NetworkChangeNotifierPosix that makes these tests flaky on ChromeOS when
// there's an out of process network stack.
//
// TODO(https://crbug.com/927293): Fix that, and enable these tests on ChromeOS.
-#define TEST_CASES(network_context_type) \
- TestCase({NetworkServiceState::kDisabled, network_context_type})
-#else // !defined(OS_CHROMEOS)
+#if !defined(OS_CHROMEOS)
#define TEST_CASES(network_context_type) \
- TestCase({NetworkServiceState::kDisabled, network_context_type}), \
TestCase({NetworkServiceState::kEnabled, network_context_type}), \
TestCase({NetworkServiceState::kRestarted, network_context_type})
-#endif // !defined(OS_CHROMEOS)
#if BUILDFLAG(ENABLE_EXTENSIONS)
#define INSTANTIATE_EXTENSION_TESTS(TestFixture) \
@@ -1864,4 +1850,6 @@
INSTANTIATE_TEST_CASES_FOR_TEST_FIXTURE(
NetworkContextConfigurationHttpsStrippingPacBrowserTest);
+#endif // !defined(OS_CHROMEOS)
+
} // namespace
diff --git a/chrome/browser/net/profile_network_context_service.cc b/chrome/browser/net/profile_network_context_service.cc
index 2b24d1a..2f5778a 100644
--- a/chrome/browser/net/profile_network_context_service.cc
+++ b/chrome/browser/net/profile_network_context_service.cc
@@ -175,9 +175,9 @@
}
}
- if ((!in_memory && !profile_->IsOffTheRecord()) &&
- (base::FeatureList::IsEnabled(network::features::kNetworkService) ||
- base::FeatureList::IsEnabled(features::kUseSameCacheForMedia))) {
+ if ((!in_memory && !profile_->IsOffTheRecord())) {
+ // TODO(jam): delete this code 1 year after Network Service shipped to all
+ // stable users, which would be after M83 branches.
base::FilePath media_cache_path = GetPartitionPath(relative_partition_path)
.Append(chrome::kMediaCacheDirname);
base::PostTaskWithTraits(
diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc
index e783e9a..921bc1e 100644
--- a/chrome/browser/prefs/browser_prefs.cc
+++ b/chrome/browser/prefs/browser_prefs.cc
@@ -1082,4 +1082,7 @@
// Added 5/2019.
profile_prefs->ClearPref(kBookmarkAppCreationLaunchType);
+
+ // Added 6/2019.
+ profile_prefs->ClearPref(prefs::kMediaCacheSize);
}
diff --git a/chrome/browser/profiles/off_the_record_profile_impl.cc b/chrome/browser/profiles/off_the_record_profile_impl.cc
index 8392fe3..dfdad13 100644
--- a/chrome/browser/profiles/off_the_record_profile_impl.cc
+++ b/chrome/browser/profiles/off_the_record_profile_impl.cc
@@ -32,7 +32,6 @@
#include "chrome/browser/download/download_core_service.h"
#include "chrome/browser/download/download_core_service_factory.h"
#include "chrome/browser/io_thread.h"
-#include "chrome/browser/net/chrome_url_request_context_getter.h"
#include "chrome/browser/permissions/permission_manager.h"
#include "chrome/browser/permissions/permission_manager_factory.h"
#include "chrome/browser/plugins/chrome_plugin_service_filter.h"
@@ -385,9 +384,7 @@
net::URLRequestContextGetter* OffTheRecordProfileImpl::CreateRequestContext(
content::ProtocolHandlerMap* protocol_handlers,
content::URLRequestInterceptorScopedVector request_interceptors) {
- return io_data_->CreateMainRequestContextGetter(
- protocol_handlers, std::move(request_interceptors))
- .get();
+ return nullptr;
}
net::URLRequestContextGetter*
@@ -400,8 +397,7 @@
OffTheRecordProfileImpl::CreateMediaRequestContextForStoragePartition(
const base::FilePath& partition_path,
bool in_memory) {
- return io_data_->GetIsolatedAppRequestContextGetter(partition_path, in_memory)
- .get();
+ return nullptr;
}
std::unique_ptr<service_manager::Service>
@@ -464,10 +460,7 @@
bool in_memory,
content::ProtocolHandlerMap* protocol_handlers,
content::URLRequestInterceptorScopedVector request_interceptors) {
- return io_data_->CreateIsolatedAppRequestContextGetter(
- partition_path, in_memory, protocol_handlers,
- std::move(request_interceptors))
- .get();
+ return nullptr;
}
content::ResourceContext* OffTheRecordProfileImpl::GetResourceContext() {
diff --git a/chrome/browser/profiles/off_the_record_profile_io_data.cc b/chrome/browser/profiles/off_the_record_profile_io_data.cc
index 44520d14..9f53f36 100644
--- a/chrome/browser/profiles/off_the_record_profile_io_data.cc
+++ b/chrome/browser/profiles/off_the_record_profile_io_data.cc
@@ -18,7 +18,6 @@
#include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h"
#include "chrome/browser/io_thread.h"
#include "chrome/browser/net/chrome_network_delegate.h"
-#include "chrome/browser/net/chrome_url_request_context_getter.h"
#include "chrome/browser/net/profile_network_context_service.h"
#include "chrome/browser/net/profile_network_context_service_factory.h"
#include "chrome/browser/profiles/profile.h"
@@ -60,7 +59,7 @@
OffTheRecordProfileIOData::Handle::~Handle() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
- io_data_->ShutdownOnUIThread(GetAllContextGetters());
+ io_data_->ShutdownOnUIThread();
}
content::ResourceContext*
@@ -79,78 +78,6 @@
return io_data_->GetResourceContext();
}
-scoped_refptr<ChromeURLRequestContextGetter>
-OffTheRecordProfileIOData::Handle::CreateMainRequestContextGetter(
- content::ProtocolHandlerMap* protocol_handlers,
- content::URLRequestInterceptorScopedVector request_interceptors) const {
- // TODO(oshima): Re-enable when ChromeOS only accesses the profile on the UI
- // thread.
-#if !defined(OS_CHROMEOS)
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
-#endif // defined(OS_CHROMEOS)
- LazyInitialize();
- DCHECK(!main_request_context_getter_.get());
- main_request_context_getter_ = ChromeURLRequestContextGetter::Create(
- profile_, io_data_, protocol_handlers, std::move(request_interceptors));
- return main_request_context_getter_;
-}
-
-scoped_refptr<ChromeURLRequestContextGetter>
-OffTheRecordProfileIOData::Handle::GetIsolatedAppRequestContextGetter(
- const base::FilePath& partition_path,
- bool in_memory) const {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
- DCHECK(!partition_path.empty());
- LazyInitialize();
-
- // Keep a map of request context getters, one per requested app ID.
- StoragePartitionDescriptor descriptor(partition_path, in_memory);
- auto iter = app_request_context_getter_map_.find(descriptor);
- CHECK(iter != app_request_context_getter_map_.end());
- return iter->second;
-}
-
-scoped_refptr<ChromeURLRequestContextGetter>
-OffTheRecordProfileIOData::Handle::CreateIsolatedAppRequestContextGetter(
- const base::FilePath& partition_path,
- bool in_memory,
- content::ProtocolHandlerMap* protocol_handlers,
- content::URLRequestInterceptorScopedVector request_interceptors) const {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
- DCHECK(!partition_path.empty());
- LazyInitialize();
-
- // Keep a map of request context getters, one per requested app ID.
- StoragePartitionDescriptor descriptor(partition_path, in_memory);
- DCHECK_EQ(app_request_context_getter_map_.count(descriptor), 0u);
-
- std::unique_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>
- protocol_handler_interceptor(
- ProtocolHandlerRegistryFactory::GetForBrowserContext(profile_)
- ->CreateJobInterceptorFactory());
- base::FilePath relative_partition_path;
- // This method is passed the absolute partition path, but
- // ProfileNetworkContext works in terms of relative partition paths.
- bool result = profile_->GetPath().AppendRelativePath(
- partition_path, &relative_partition_path);
- DCHECK(result);
- network::mojom::NetworkContextRequest network_context_request;
- network::mojom::NetworkContextParamsPtr network_context_params;
- ProfileNetworkContextServiceFactory::GetForContext(profile_)
- ->SetUpProfileIODataNetworkContext(in_memory, relative_partition_path,
- &network_context_request,
- &network_context_params);
- scoped_refptr<ChromeURLRequestContextGetter> context =
- ChromeURLRequestContextGetter::CreateForIsolatedApp(
- profile_, io_data_, descriptor,
- std::move(protocol_handler_interceptor), protocol_handlers,
- std::move(request_interceptors), std::move(network_context_request),
- std::move(network_context_params));
- app_request_context_getter_map_[descriptor] = context;
-
- return context;
-}
-
void OffTheRecordProfileIOData::Handle::LazyInitialize() const {
if (initialized_)
return;
@@ -175,20 +102,6 @@
io_data_->InitializeOnUIThread(profile_);
}
-std::unique_ptr<ProfileIOData::ChromeURLRequestContextGetterVector>
-OffTheRecordProfileIOData::Handle::GetAllContextGetters() {
- std::unique_ptr<ChromeURLRequestContextGetterVector> context_getters(
- new ChromeURLRequestContextGetterVector());
- auto iter = app_request_context_getter_map_.begin();
- for (; iter != app_request_context_getter_map_.end(); ++iter)
- context_getters->push_back(iter->second);
-
- if (main_request_context_getter_.get())
- context_getters->push_back(main_request_context_getter_);
-
- return context_getters;
-}
-
OffTheRecordProfileIOData::OffTheRecordProfileIOData(
Profile::ProfileType profile_type)
: ProfileIOData(profile_type) {}
@@ -197,17 +110,6 @@
DestroyResourceContext();
}
-void OffTheRecordProfileIOData::InitializeInternal(
- net::URLRequestContextBuilder* builder,
- ProfileParams* profile_params,
- content::ProtocolHandlerMap* protocol_handlers,
- content::URLRequestInterceptorScopedVector request_interceptors) const {
- AddProtocolHandlersToBuilder(builder, protocol_handlers);
- SetUpJobFactoryDefaultsForBuilder(
- builder, std::move(request_interceptors),
- std::move(profile_params->protocol_handler_interceptor));
-}
-
void OffTheRecordProfileIOData::OnMainRequestContextCreated(
ProfileParams* profile_params) const {
#if BUILDFLAG(ENABLE_EXTENSIONS)
@@ -224,29 +126,6 @@
cookie_config, profile_params->io_thread->net_log());
}
-net::URLRequestContext*
-OffTheRecordProfileIOData::InitializeMediaRequestContext(
- net::URLRequestContext* original_context,
- const StoragePartitionDescriptor& partition_descriptor,
- const char* name) const {
- NOTREACHED();
- return NULL;
-}
-
-net::URLRequestContext*
-OffTheRecordProfileIOData::AcquireMediaRequestContext() const {
- NOTREACHED();
- return NULL;
-}
-
-net::URLRequestContext*
-OffTheRecordProfileIOData::AcquireIsolatedMediaRequestContext(
- net::URLRequestContext* app_context,
- const StoragePartitionDescriptor& partition_descriptor) const {
- NOTREACHED();
- return NULL;
-}
-
net::CookieStore* OffTheRecordProfileIOData::GetExtensionsCookieStore() const {
return extensions_cookie_store_.get();
}
diff --git a/chrome/browser/profiles/off_the_record_profile_io_data.h b/chrome/browser/profiles/off_the_record_profile_io_data.h
index 3193c92..7fcc2c1 100644
--- a/chrome/browser/profiles/off_the_record_profile_io_data.h
+++ b/chrome/browser/profiles/off_the_record_profile_io_data.h
@@ -16,13 +16,10 @@
#include "chrome/browser/profiles/profile_io_data.h"
#include "chrome/browser/profiles/storage_partition_descriptor.h"
-class ChromeURLRequestContextGetter;
class Profile;
namespace net {
class CookieStore;
-class URLRequestContext;
-class URLRequestContextBuilder;
} // namespace net
// OffTheRecordProfile owns a OffTheRecordProfileIOData::Handle, which holds a
@@ -48,27 +45,8 @@
// GetResourceContextNoInit() does not call LazyInitialize() so it can be
// safely be used during initialization.
content::ResourceContext* GetResourceContextNoInit() const;
- scoped_refptr<ChromeURLRequestContextGetter> CreateMainRequestContextGetter(
- content::ProtocolHandlerMap* protocol_handlers,
- content::URLRequestInterceptorScopedVector request_interceptors) const;
- scoped_refptr<ChromeURLRequestContextGetter>
- GetIsolatedAppRequestContextGetter(
- const base::FilePath& partition_path,
- bool in_memory) const;
- scoped_refptr<ChromeURLRequestContextGetter>
- CreateIsolatedAppRequestContextGetter(
- const base::FilePath& partition_path,
- bool in_memory,
- content::ProtocolHandlerMap* protocol_handlers,
- content::URLRequestInterceptorScopedVector
- request_interceptors) const;
private:
- typedef std::map<StoragePartitionDescriptor,
- scoped_refptr<ChromeURLRequestContextGetter>,
- StoragePartitionDescriptorLess>
- ChromeURLRequestContextGetterMap;
-
// Lazily initialize ProfileParams. We do this on the calls to
// Get*RequestContextGetter(), so we only initialize ProfileParams right
// before posting a task to the IO thread to start using them. This prevents
@@ -76,17 +54,6 @@
// on the UI thread from being unnecessarily initialized.
void LazyInitialize() const;
- // Collect references to context getters in reverse order, i.e. last item
- // will be main request getter. This list is passed to |io_data_|
- // for invalidation on IO thread.
- std::unique_ptr<ChromeURLRequestContextGetterVector> GetAllContextGetters();
-
- // The getters will be invalidated on the IO thread before
- // ProfileIOData instance is deleted.
- mutable scoped_refptr<ChromeURLRequestContextGetter>
- main_request_context_getter_;
- mutable ChromeURLRequestContextGetterMap
- app_request_context_getter_map_;
OffTheRecordProfileIOData* const io_data_;
Profile* const profile_;
@@ -100,23 +67,10 @@
explicit OffTheRecordProfileIOData(Profile::ProfileType profile_type);
~OffTheRecordProfileIOData() override;
- void InitializeInternal(net::URLRequestContextBuilder* builder,
- ProfileParams* profile_params,
- content::ProtocolHandlerMap* protocol_handlers,
- content::URLRequestInterceptorScopedVector
- request_interceptors) const override;
void OnMainRequestContextCreated(
ProfileParams* profile_params) const override;
void InitializeExtensionsCookieStore(
ProfileParams* profile_params) const override;
- net::URLRequestContext* InitializeMediaRequestContext(
- net::URLRequestContext* original_context,
- const StoragePartitionDescriptor& partition_descriptor,
- const char* name) const override;
- net::URLRequestContext* AcquireMediaRequestContext() const override;
- net::URLRequestContext* AcquireIsolatedMediaRequestContext(
- net::URLRequestContext* app_context,
- const StoragePartitionDescriptor& partition_descriptor) const override;
net::CookieStore* GetExtensionsCookieStore() const override;
mutable std::unique_ptr<net::CookieStore> extensions_cookie_store_;
diff --git a/chrome/browser/profiles/profile_browsertest.cc b/chrome/browser/profiles/profile_browsertest.cc
index 45d57f3..065d866 100644
--- a/chrome/browser/profiles/profile_browsertest.cc
+++ b/chrome/browser/profiles/profile_browsertest.cc
@@ -507,35 +507,6 @@
FlushIoTaskRunnerAndSpinThreads();
}
-namespace {
-
-scoped_refptr<const extensions::Extension> BuildTestApp(Profile* profile) {
- scoped_refptr<const extensions::Extension> app;
- app =
- extensions::ExtensionBuilder()
- .SetManifest(
- extensions::DictionaryBuilder()
- .Set("name", "test app")
- .Set("version", "1")
- .Set("app",
- extensions::DictionaryBuilder()
- .Set("background",
- extensions::DictionaryBuilder()
- .Set("scripts", extensions::ListBuilder()
- .Append("background.js")
- .Build())
- .Build())
- .Build())
- .Build())
- .Build();
- extensions::ExtensionRegistry* registry =
- extensions::ExtensionRegistry::Get(profile);
- EXPECT_TRUE(registry->AddEnabled(app));
- return app;
-}
-
-} // namespace
-
// The EndSession IO synchronization is only critical on Windows, but also
// happens under the USE_X11 define. See BrowserProcessImpl::EndSession.
#if defined(USE_X11) || defined(OS_WIN) || defined(USE_OZONE)
@@ -675,7 +646,6 @@
// by group policy or command line switches.
IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, DiskCacheDirOverride) {
base::ScopedAllowBlockingForTesting allow_blocking;
- int size;
const base::FilePath::StringPieceType profile_name =
FILE_PATH_LITERAL("Profile 1");
base::ScopedTempDir mock_user_data_dir;
@@ -689,10 +659,6 @@
ASSERT_TRUE(temp_disk_cache_dir.CreateUniqueTempDir());
profile_impl->GetPrefs()->SetFilePath(prefs::kDiskCacheDir,
temp_disk_cache_dir.GetPath());
-
- base::FilePath cache_path = profile_path;
- profile_impl->GetMediaCacheParameters(&cache_path, &size);
- EXPECT_EQ(temp_disk_cache_dir.GetPath().Append(profile_name), cache_path);
}
}
@@ -877,100 +843,3 @@
};
} // namespace
-
-// Create a media cache file, and make sure it's deleted by the time the next
-// test runs.
-IN_PROC_BROWSER_TEST_F(ProfileWithoutMediaCacheBrowserTest,
- PRE_DeleteMediaCache) {
- base::FilePath media_cache_path =
- browser()->profile()->GetPath().Append(chrome::kMediaCacheDirname);
-
- base::ScopedAllowBlockingForTesting allow_blocking;
- EXPECT_TRUE(base::CreateDirectory(media_cache_path));
- std::string data = "foo";
- base::WriteFile(media_cache_path.AppendASCII("foo"), data.c_str(),
- data.size());
-}
-
-IN_PROC_BROWSER_TEST_F(ProfileWithoutMediaCacheBrowserTest, DeleteMediaCache) {
- base::FilePath media_cache_path =
- browser()->profile()->GetPath().Append(chrome::kMediaCacheDirname);
-
- base::ScopedAllowBlockingForTesting allow_blocking;
-
- FileDestructionWatcher destruction_watcher(media_cache_path);
- destruction_watcher.WaitForDestruction();
-}
-
-// Create a media cache file, and make sure it's deleted by initializing an
-// extension browser context.
-IN_PROC_BROWSER_TEST_F(ProfileWithoutMediaCacheBrowserTest,
- PRE_DeleteIsolatedAppMediaCache) {
- scoped_refptr<const extensions::Extension> app =
- BuildTestApp(browser()->profile());
- content::StoragePartition* extension_partition =
- content::BrowserContext::GetStoragePartitionForSite(
- browser()->profile(),
- extensions::Extension::GetBaseURLFromExtensionId(app->id()));
-
- base::FilePath extension_media_cache_path =
- extension_partition->GetPath().Append(chrome::kMediaCacheDirname);
-
- base::ScopedAllowBlockingForTesting allow_blocking;
- EXPECT_TRUE(base::CreateDirectory(extension_media_cache_path));
- std::string data = "foo";
- base::WriteFile(extension_media_cache_path.AppendASCII("foo"), data.c_str(),
- data.size());
-}
-
-IN_PROC_BROWSER_TEST_F(ProfileWithoutMediaCacheBrowserTest,
- DeleteIsolatedAppMediaCache) {
- scoped_refptr<const extensions::Extension> app =
- BuildTestApp(browser()->profile());
- content::StoragePartition* extension_partition =
- content::BrowserContext::GetStoragePartitionForSite(
- browser()->profile(),
- extensions::Extension::GetBaseURLFromExtensionId(app->id()));
-
- base::FilePath extension_media_cache_path =
- extension_partition->GetPath().Append(chrome::kMediaCacheDirname);
-
- FileDestructionWatcher destruction_watcher(extension_media_cache_path);
- destruction_watcher.WaitForDestruction();
-}
-
-class ProfileWithNetworkServiceBrowserTest : public ProfileBrowserTest {
- public:
- ProfileWithNetworkServiceBrowserTest() {
- feature_list_.InitAndEnableFeature(network::features::kNetworkService);
- }
-
- ~ProfileWithNetworkServiceBrowserTest() override {}
-
- private:
- base::test::ScopedFeatureList feature_list_;
-};
-
-// Create a media cache file, and make sure it's deleted by the time the next
-// test runs.
-IN_PROC_BROWSER_TEST_F(ProfileWithNetworkServiceBrowserTest,
- PRE_DeleteMediaCache) {
- base::FilePath media_cache_path =
- browser()->profile()->GetPath().Append(chrome::kMediaCacheDirname);
-
- base::ScopedAllowBlockingForTesting allow_blocking;
- EXPECT_TRUE(base::CreateDirectory(media_cache_path));
- std::string data = "foo";
- base::WriteFile(media_cache_path.AppendASCII("foo"), data.c_str(),
- data.size());
-}
-
-IN_PROC_BROWSER_TEST_F(ProfileWithNetworkServiceBrowserTest, DeleteMediaCache) {
- base::FilePath media_cache_path =
- browser()->profile()->GetPath().Append(chrome::kMediaCacheDirname);
-
- base::ScopedAllowBlockingForTesting allow_blocking;
-
- FileDestructionWatcher destruction_watcher(media_cache_path);
- destruction_watcher.WaitForDestruction();
-}
diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc
index 71619ca..df57bc8 100644
--- a/chrome/browser/profiles/profile_impl.cc
+++ b/chrome/browser/profiles/profile_impl.cc
@@ -292,10 +292,6 @@
}
}
-base::FilePath GetMediaCachePath(const base::FilePath& base) {
- return base.Append(chrome::kMediaCacheDirname);
-}
-
// Converts the kSessionExitedCleanly pref to the corresponding EXIT_TYPE.
Profile::ExitType SessionTypePrefValueToExitType(const std::string& value) {
if (value == kPrefExitTypeSessionEnded)
@@ -461,7 +457,6 @@
last_session_exit_type_(EXIT_NORMAL),
start_time_(base::Time::Now()),
delegate_(delegate),
- reporting_permissions_checker_factory_(this),
shared_cors_origin_access_list_(
content::SharedCorsOriginAccessList::Create()) {
TRACE_EVENT0("browser,startup", "ProfileImpl::ctor")
@@ -695,11 +690,6 @@
}
#endif // BUILDFLAG(ENABLE_BACKGROUND_MODE)
- base::FilePath media_cache_path = base_cache_path;
- int media_cache_max_size;
- GetMediaCacheParameters(&media_cache_path, &media_cache_max_size);
- media_cache_path = GetMediaCachePath(media_cache_path);
-
base::FilePath extensions_cookie_path = GetPath();
extensions_cookie_path =
extensions_cookie_path.Append(chrome::kExtensionsCookieFilename);
@@ -707,9 +697,7 @@
// Make sure we initialize the ProfileIOData after everything else has been
// initialized that we might be reading from the IO thread.
- io_data_.Init(media_cache_path, media_cache_max_size, extensions_cookie_path,
- GetPath(), GetSpecialStoragePolicy(),
- reporting_permissions_checker_factory_.CreateChecker());
+ io_data_.Init(extensions_cookie_path, GetPath());
#if BUILDFLAG(ENABLE_PLUGINS)
ChromePluginServiceFilter::GetInstance()->RegisterResourceContext(
@@ -1234,11 +1222,7 @@
net::URLRequestContextGetter* ProfileImpl::CreateRequestContext(
content::ProtocolHandlerMap* protocol_handlers,
content::URLRequestInterceptorScopedVector request_interceptors) {
- return io_data_
- .CreateMainRequestContextGetter(protocol_handlers,
- std::move(request_interceptors),
- g_browser_process->io_thread())
- .get();
+ return nullptr;
}
net::URLRequestContextGetter*
@@ -1247,24 +1231,18 @@
bool in_memory,
content::ProtocolHandlerMap* protocol_handlers,
content::URLRequestInterceptorScopedVector request_interceptors) {
- return io_data_
- .CreateIsolatedAppRequestContextGetter(partition_path, in_memory,
- protocol_handlers,
- std::move(request_interceptors))
- .get();
+ return nullptr;
}
net::URLRequestContextGetter* ProfileImpl::CreateMediaRequestContext() {
- return io_data_.GetMediaRequestContextGetter().get();
+ return nullptr;
}
net::URLRequestContextGetter*
ProfileImpl::CreateMediaRequestContextForStoragePartition(
const base::FilePath& partition_path,
bool in_memory) {
- return io_data_
- .GetIsolatedMediaRequestContextGetter(partition_path, in_memory)
- .get();
+ return nullptr;
}
void ProfileImpl::SetCorsOriginAccessListForOrigin(
@@ -1607,15 +1585,3 @@
GetPrefs()->GetBoolean(prefs::kForceEphemeralProfiles));
}
}
-
-// Gets the media cache parameters from the command line. |cache_path| will be
-// set to the user provided path, or will not be touched if there is not an
-// argument. |max_size| will be the user provided value or zero by default.
-void ProfileImpl::GetMediaCacheParameters(base::FilePath* cache_path,
- int* max_size) {
- base::FilePath path(prefs_->GetFilePath(prefs::kDiskCacheDir));
- if (!path.empty())
- *cache_path = path.Append(cache_path->BaseName());
-
- *max_size = prefs_->GetInteger(prefs::kMediaCacheSize);
-}
diff --git a/chrome/browser/profiles/profile_impl.h b/chrome/browser/profiles/profile_impl.h
index 2831559..49e6830b 100644
--- a/chrome/browser/profiles/profile_impl.h
+++ b/chrome/browser/profiles/profile_impl.h
@@ -226,8 +226,6 @@
void UpdateAvatarInStorage();
void UpdateIsEphemeralInStorage();
- void GetMediaCacheParameters(base::FilePath* cache_path, int* max_size);
-
policy::ConfigurationPolicyProvider* configuration_policy_provider();
PrefChangeRegistrar pref_change_registrar_;
@@ -328,8 +326,6 @@
Profile::Delegate* delegate_;
- ReportingPermissionsCheckerFactory reporting_permissions_checker_factory_;
-
scoped_refptr<content::SharedCorsOriginAccessList>
shared_cors_origin_access_list_;
diff --git a/chrome/browser/profiles/profile_impl_io_data.cc b/chrome/browser/profiles/profile_impl_io_data.cc
index ee511117..75af203acc 100644
--- a/chrome/browser/profiles/profile_impl_io_data.cc
+++ b/chrome/browser/profiles/profile_impl_io_data.cc
@@ -35,7 +35,6 @@
#include "chrome/browser/net/chrome_network_delegate.h"
#include "chrome/browser/net/profile_network_context_service.h"
#include "chrome/browser/net/profile_network_context_service_factory.h"
-#include "chrome/browser/net/reporting_permissions_checker.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_features.h"
@@ -84,29 +83,6 @@
#include "chrome/browser/offline_pages/offline_page_request_interceptor.h"
#endif
-namespace {
-
-// Returns the BackendType that the disk cache should use.
-// TODO(mmenke): Once all URLRequestContexts are set up using
-// URLRequestContextBuilders, and the media URLRequestContext is take care of
-// (In one way or another), this should be removed.
-net::BackendType ChooseCacheBackendType() {
- switch (network_session_configurator::ChooseCacheType()) {
- case net::URLRequestContextBuilder::HttpCacheParams::DISK_BLOCKFILE:
- return net::CACHE_BACKEND_BLOCKFILE;
- case net::URLRequestContextBuilder::HttpCacheParams::DISK_SIMPLE:
- return net::CACHE_BACKEND_SIMPLE;
- case net::URLRequestContextBuilder::HttpCacheParams::DISK:
- return net::CACHE_BACKEND_DEFAULT;
- case net::URLRequestContextBuilder::HttpCacheParams::IN_MEMORY:
- NOTREACHED();
- break;
- }
- return net::CACHE_BACKEND_DEFAULT;
-}
-
-} // namespace
-
using content::BrowserThread;
ProfileImplIOData::Handle::Handle(Profile* profile)
@@ -124,39 +100,27 @@
if (io_data_->data_reduction_proxy_io_data())
io_data_->data_reduction_proxy_io_data()->ShutdownOnUIThread();
- io_data_->ShutdownOnUIThread(GetAllContextGetters());
+ io_data_->ShutdownOnUIThread();
}
void ProfileImplIOData::Handle::Init(
- const base::FilePath& media_cache_path,
- int media_cache_max_size,
const base::FilePath& extensions_cookie_path,
- const base::FilePath& profile_path,
- storage::SpecialStoragePolicy* special_storage_policy,
- std::unique_ptr<ReportingPermissionsChecker>
- reporting_permissions_checker) {
+ const base::FilePath& profile_path) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(!io_data_->lazy_params_);
LazyParams* lazy_params = new LazyParams();
- lazy_params->media_cache_path = media_cache_path;
- lazy_params->media_cache_max_size = media_cache_max_size;
lazy_params->extensions_cookie_path = extensions_cookie_path;
lazy_params->restore_old_session_cookies =
profile_->ShouldRestoreOldSessionCookies();
lazy_params->persist_session_cookies =
profile_->ShouldPersistSessionCookies();
- lazy_params->special_storage_policy = special_storage_policy;
- lazy_params->reporting_permissions_checker =
- std::move(reporting_permissions_checker);
io_data_->lazy_params_.reset(lazy_params);
- // Keep track of profile path and cache sizes separately so we can use them
- // on demand when creating storage isolated URLRequestContextGetters.
+ // Keep track of profile path for data reduction proxy..
io_data_->profile_path_ = profile_path;
- io_data_->app_media_cache_max_size_ = media_cache_max_size;
io_data_->set_data_reduction_proxy_io_data(
CreateDataReductionProxyChromeIOData(
@@ -187,132 +151,6 @@
return io_data_->GetResourceContext();
}
-scoped_refptr<ChromeURLRequestContextGetter>
-ProfileImplIOData::Handle::CreateMainRequestContextGetter(
- content::ProtocolHandlerMap* protocol_handlers,
- content::URLRequestInterceptorScopedVector request_interceptors,
- IOThread* io_thread) const {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
- LazyInitialize();
-
- if (base::FeatureList::IsEnabled(network::features::kNetworkService)) {
- NOTREACHED();
- return nullptr;
- }
-
- DCHECK(!main_request_context_getter_.get());
- main_request_context_getter_ = ChromeURLRequestContextGetter::Create(
- profile_, io_data_, protocol_handlers, std::move(request_interceptors));
-
- content::NotificationService::current()->Notify(
- chrome::NOTIFICATION_PROFILE_URL_REQUEST_CONTEXT_GETTER_INITIALIZED,
- content::Source<Profile>(profile_),
- content::NotificationService::NoDetails());
- return main_request_context_getter_;
-}
-
-scoped_refptr<ChromeURLRequestContextGetter>
-ProfileImplIOData::Handle::GetMediaRequestContextGetter() const {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
- LazyInitialize();
-
- if (base::FeatureList::IsEnabled(network::features::kNetworkService)) {
- NOTREACHED();
- return nullptr;
- }
-
- if (!media_request_context_getter_.get()) {
- media_request_context_getter_ =
- ChromeURLRequestContextGetter::CreateForMedia(profile_, io_data_);
- }
- return media_request_context_getter_;
-}
-
-scoped_refptr<ChromeURLRequestContextGetter>
-ProfileImplIOData::Handle::CreateIsolatedAppRequestContextGetter(
- const base::FilePath& partition_path,
- bool in_memory,
- content::ProtocolHandlerMap* protocol_handlers,
- content::URLRequestInterceptorScopedVector request_interceptors) const {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
- // Check that the partition_path is not the same as the base profile path. We
- // expect isolated partition, which will never go to the default profile path.
- CHECK(partition_path != profile_->GetPath());
- LazyInitialize();
-
- if (base::FeatureList::IsEnabled(network::features::kNetworkService)) {
- NOTREACHED();
- return nullptr;
- }
-
- // Keep a map of request context getters, one per requested storage partition.
- StoragePartitionDescriptor descriptor(partition_path, in_memory);
- auto iter = app_request_context_getter_map_.find(descriptor);
- if (iter != app_request_context_getter_map_.end())
- return iter->second;
-
- std::unique_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>
- protocol_handler_interceptor(
- ProtocolHandlerRegistryFactory::GetForBrowserContext(profile_)
- ->CreateJobInterceptorFactory());
- base::FilePath relative_partition_path;
- // This method is passed the absolute partition path, but
- // ProfileNetworkContext works in terms of relative partition paths.
- bool result = profile_->GetPath().AppendRelativePath(
- partition_path, &relative_partition_path);
- DCHECK(result);
- network::mojom::NetworkContextRequest network_context_request;
- network::mojom::NetworkContextParamsPtr network_context_params;
- ProfileNetworkContextServiceFactory::GetForContext(profile_)
- ->SetUpProfileIODataNetworkContext(in_memory, relative_partition_path,
- &network_context_request,
- &network_context_params);
- scoped_refptr<ChromeURLRequestContextGetter> context =
- ChromeURLRequestContextGetter::CreateForIsolatedApp(
- profile_, io_data_, descriptor,
- std::move(protocol_handler_interceptor), protocol_handlers,
- std::move(request_interceptors), std::move(network_context_request),
- std::move(network_context_params));
- app_request_context_getter_map_[descriptor] = context;
-
- return context.get();
-}
-
-scoped_refptr<ChromeURLRequestContextGetter>
-ProfileImplIOData::Handle::GetIsolatedMediaRequestContextGetter(
- const base::FilePath& partition_path,
- bool in_memory) const {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
- // We must have a non-default path, or this will act like the default media
- // context.
- CHECK(partition_path != profile_->GetPath());
- LazyInitialize();
-
- if (base::FeatureList::IsEnabled(network::features::kNetworkService)) {
- NOTREACHED();
- return nullptr;
- }
-
- // Keep a map of request context getters, one per requested storage partition.
- StoragePartitionDescriptor descriptor(partition_path, in_memory);
- auto iter = isolated_media_request_context_getter_map_.find(descriptor);
- if (iter != isolated_media_request_context_getter_map_.end())
- return iter->second;
-
- // Get the app context as the starting point for the media context, so that
- // it uses the app's cookie store.
- ChromeURLRequestContextGetterMap::const_iterator app_iter =
- app_request_context_getter_map_.find(descriptor);
- DCHECK(app_iter != app_request_context_getter_map_.end());
- ChromeURLRequestContextGetter* app_context = app_iter->second.get();
- scoped_refptr<ChromeURLRequestContextGetter> context =
- ChromeURLRequestContextGetter::CreateForIsolatedMedia(
- profile_, app_context, io_data_, descriptor);
- isolated_media_request_context_getter_map_[descriptor] = context;
-
- return context;
-}
-
void ProfileImplIOData::Handle::InitializeDataReductionProxy() const {
scoped_refptr<base::SequencedTaskRunner> db_task_runner =
base::CreateSequencedTaskRunnerWithTraits(
@@ -325,10 +163,7 @@
io_data_->data_reduction_proxy_io_data(), profile_->GetPrefs(),
// TODO(crbug.com/721403) Switch DRP to mojo. For now it is disabled
// with network service.
- base::FeatureList::IsEnabled(network::features::kNetworkService)
- ? nullptr
- : main_request_context_getter_.get(),
- profile_,
+ nullptr, profile_,
content::BrowserContext::GetDefaultStoragePartition(profile_)
->GetURLLoaderFactoryForBrowserProcess(),
std::move(store),
@@ -362,90 +197,16 @@
io_data_->InitializeOnUIThread(profile_);
}
-std::unique_ptr<ProfileIOData::ChromeURLRequestContextGetterVector>
-ProfileImplIOData::Handle::GetAllContextGetters() {
- ChromeURLRequestContextGetterMap::iterator iter;
- std::unique_ptr<ChromeURLRequestContextGetterVector> context_getters(
- new ChromeURLRequestContextGetterVector());
-
- iter = isolated_media_request_context_getter_map_.begin();
- for (; iter != isolated_media_request_context_getter_map_.end(); ++iter)
- context_getters->push_back(iter->second);
-
- iter = app_request_context_getter_map_.begin();
- for (; iter != app_request_context_getter_map_.end(); ++iter)
- context_getters->push_back(iter->second);
-
- if (media_request_context_getter_.get())
- context_getters->push_back(media_request_context_getter_);
-
- if (main_request_context_getter_.get())
- context_getters->push_back(main_request_context_getter_);
-
- return context_getters;
-}
-
ProfileImplIOData::LazyParams::LazyParams()
- : media_cache_max_size(0),
- restore_old_session_cookies(false),
- persist_session_cookies(false) {}
+ : restore_old_session_cookies(false), persist_session_cookies(false) {}
ProfileImplIOData::LazyParams::~LazyParams() {}
ProfileImplIOData::ProfileImplIOData()
- : ProfileIOData(Profile::REGULAR_PROFILE),
- app_media_cache_max_size_(0) {
-}
+ : ProfileIOData(Profile::REGULAR_PROFILE) {}
ProfileImplIOData::~ProfileImplIOData() {
DestroyResourceContext();
-
- if (media_request_context_)
- media_request_context_->AssertNoURLRequests();
-}
-
-std::unique_ptr<net::NetworkDelegate>
-ProfileImplIOData::ConfigureNetworkDelegate(
- IOThread* io_thread,
- std::unique_ptr<ChromeNetworkDelegate> chrome_network_delegate) const {
-
- if (lazy_params_->reporting_permissions_checker) {
- chrome_network_delegate->set_reporting_permissions_checker(
- std::move(lazy_params_->reporting_permissions_checker));
- }
-
- return data_reduction_proxy_io_data()->CreateNetworkDelegate(
- io_thread->globals()->data_use_ascriber->CreateNetworkDelegate(
- std::move(chrome_network_delegate)),
- true);
-}
-
-void ProfileImplIOData::InitializeInternal(
- net::URLRequestContextBuilder* builder,
- ProfileParams* profile_params,
- content::ProtocolHandlerMap* protocol_handlers,
- content::URLRequestInterceptorScopedVector request_interceptors) const {
- IOThread* const io_thread = profile_params->io_thread;
- IOThread::Globals* const io_thread_globals = io_thread->globals();
-
- AddProtocolHandlersToBuilder(builder, protocol_handlers);
-
- // Install the Offline Page Interceptor.
-#if BUILDFLAG(ENABLE_OFFLINE_PAGES)
- request_interceptors.push_back(
- std::make_unique<offline_pages::OfflinePageRequestInterceptor>());
-#endif
-
- // The data reduction proxy interceptor should be as close to the network
- // as possible.
- request_interceptors.insert(
- request_interceptors.begin(),
- data_reduction_proxy_io_data()->CreateInterceptor());
- data_reduction_proxy_io_data()->SetDataUseAscriber(
- io_thread_globals->data_use_ascriber.get());
- SetUpJobFactoryDefaultsForBuilder(
- builder, std::move(request_interceptors),
- std::move(profile_params->protocol_handler_interceptor));
}
void ProfileImplIOData::OnMainRequestContextCreated(
@@ -456,14 +217,6 @@
InitializeExtensionsCookieStore(profile_params);
#endif
- if (!base::FeatureList::IsEnabled(network::features::kNetworkService)) {
- // Create a media request context based on the main context, but using a
- // media cache. It shares the same job factory as the main context.
- StoragePartitionDescriptor details(profile_path_, false);
- media_request_context_.reset(InitializeMediaRequestContext(
- main_request_context(), details, "main_media"));
- }
-
lazy_params_.reset();
}
@@ -480,72 +233,6 @@
cookie_config, profile_params->io_thread->net_log());
}
-net::URLRequestContext* ProfileImplIOData::InitializeMediaRequestContext(
- net::URLRequestContext* original_context,
- const StoragePartitionDescriptor& partition_descriptor,
- const char* name) const {
- // Copy most state from the original context.
- MediaRequestContext* context = new MediaRequestContext(name);
- context->CopyFrom(original_context);
- if (base::FeatureList::IsEnabled(features::kUseSameCacheForMedia))
- return context;
-
- // For in-memory context, return immediately after creating the new
- // context before attaching a separate cache. It is important to return
- // a new context rather than just reusing |original_context| because
- // the caller expects to take ownership of the pointer.
- if (partition_descriptor.in_memory)
- return context;
-
- using content::StoragePartition;
- base::FilePath cache_path;
- int cache_max_size = app_media_cache_max_size_;
- if (partition_descriptor.path == profile_path_) {
- // lazy_params_ is only valid for the default media context creation.
- cache_path = lazy_params_->media_cache_path;
- cache_max_size = lazy_params_->media_cache_max_size;
- } else {
- cache_path = partition_descriptor.path.Append(chrome::kMediaCacheDirname);
- }
-
- // Use a separate HTTP disk cache for isolated apps.
- std::unique_ptr<net::HttpCache::BackendFactory> media_backend(
- new net::HttpCache::DefaultBackend(net::MEDIA_CACHE,
- ChooseCacheBackendType(), cache_path,
- cache_max_size));
- std::unique_ptr<net::HttpCache> media_http_cache = CreateHttpFactory(
- main_request_context()->http_transaction_factory(),
- std::move(media_backend));
-
- // Transfer ownership of the cache to MediaRequestContext.
- context->SetHttpTransactionFactory(std::move(media_http_cache));
-
- // Note that we do not create a new URLRequestJobFactory because
- // the media context should behave exactly like its parent context
- // in all respects except for cache behavior on media subresources.
- // The CopyFrom() step above means that our media context will use
- // the same URLRequestJobFactory instance that our parent context does.
-
- return context;
-}
-
-net::URLRequestContext*
-ProfileImplIOData::AcquireMediaRequestContext() const {
- DCHECK(media_request_context_);
- return media_request_context_.get();
-}
-
-net::URLRequestContext*
-ProfileImplIOData::AcquireIsolatedMediaRequestContext(
- net::URLRequestContext* app_context,
- const StoragePartitionDescriptor& partition_descriptor) const {
- // We create per-app media contexts on demand, unlike the others above.
- net::URLRequestContext* media_request_context = InitializeMediaRequestContext(
- app_context, partition_descriptor, "isolated_media");
- DCHECK(media_request_context);
- return media_request_context;
-}
-
net::CookieStore* ProfileImplIOData::GetExtensionsCookieStore() const {
return extensions_cookie_store_.get();
}
diff --git a/chrome/browser/profiles/profile_impl_io_data.h b/chrome/browser/profiles/profile_impl_io_data.h
index c3ddbd1..c611d55 100644
--- a/chrome/browser/profiles/profile_impl_io_data.h
+++ b/chrome/browser/profiles/profile_impl_io_data.h
@@ -9,21 +9,13 @@
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "chrome/browser/custom_handlers/protocol_handler_registry.h"
-#include "chrome/browser/net/chrome_url_request_context_getter.h"
#include "chrome/browser/profiles/profile_io_data.h"
#include "components/prefs/pref_store.h"
-class ReportingPermissionsChecker;
-
namespace net {
class CookieStore;
-class URLRequestContextBuilder;
} // namespace net
-namespace storage {
-class SpecialStoragePolicy;
-} // namespace storage
-
class ProfileImplIOData : public ProfileIOData {
public:
class Handle {
@@ -31,52 +23,19 @@
explicit Handle(Profile* profile);
~Handle();
- // Init() must be called before ~Handle(). It records most of the
- // parameters needed to construct a ChromeURLRequestContextGetter.
- void Init(const base::FilePath& media_cache_path,
- int media_cache_max_size,
- const base::FilePath& extensions_cookie_path,
- const base::FilePath& profile_path,
- storage::SpecialStoragePolicy* special_storage_policy,
- std::unique_ptr<ReportingPermissionsChecker>
- reporting_permissions_checker);
-
- // These Create*ContextGetter() functions are only exposed because the
- // circular relationship between Profile, ProfileIOData::Handle, and the
- // ChromeURLRequestContextGetter factories requires Profile be able to call
- // these functions.
- scoped_refptr<ChromeURLRequestContextGetter> CreateMainRequestContextGetter(
- content::ProtocolHandlerMap* protocol_handlers,
- content::URLRequestInterceptorScopedVector request_interceptors,
- IOThread* io_thread) const;
- scoped_refptr<ChromeURLRequestContextGetter>
- CreateIsolatedAppRequestContextGetter(
- const base::FilePath& partition_path,
- bool in_memory,
- content::ProtocolHandlerMap* protocol_handlers,
- content::URLRequestInterceptorScopedVector
- request_interceptors) const;
+ // Init() must be called before ~Handle().
+ void Init(const base::FilePath& extensions_cookie_path,
+ const base::FilePath& profile_path);
content::ResourceContext* GetResourceContext() const;
// GetResourceContextNoInit() does not call LazyInitialize() so it can be
// safely be used during initialization.
content::ResourceContext* GetResourceContextNoInit() const;
- scoped_refptr<ChromeURLRequestContextGetter>
- GetMediaRequestContextGetter() const;
- scoped_refptr<ChromeURLRequestContextGetter>
- GetIsolatedMediaRequestContextGetter(
- const base::FilePath& partition_path,
- bool in_memory) const;
// Called to initialize Data Reduction Proxy.
void InitializeDataReductionProxy() const;
private:
- typedef std::map<StoragePartitionDescriptor,
- scoped_refptr<ChromeURLRequestContextGetter>,
- StoragePartitionDescriptorLess>
- ChromeURLRequestContextGetterMap;
-
// Lazily initialize ProfileParams. We do this on the calls to
// Get*RequestContextGetter(), so we only initialize ProfileParams right
// before posting a task to the IO thread to start using them. This prevents
@@ -84,20 +43,8 @@
// on the UI thread from being unnecessarily initialized.
void LazyInitialize() const;
- // Collect references to context getters in reverse order, i.e. last item
- // will be main request getter. This list is passed to |io_data_|
- // for invalidation on IO thread.
- std::unique_ptr<ChromeURLRequestContextGetterVector> GetAllContextGetters();
-
// The getters will be invalidated on the IO thread before
// ProfileIOData instance is deleted.
- mutable scoped_refptr<ChromeURLRequestContextGetter>
- main_request_context_getter_;
- mutable scoped_refptr<ChromeURLRequestContextGetter>
- media_request_context_getter_;
- mutable ChromeURLRequestContextGetterMap app_request_context_getter_map_;
- mutable ChromeURLRequestContextGetterMap
- isolated_media_request_context_getter_map_;
ProfileImplIOData* const io_data_;
Profile* const profile_;
@@ -113,40 +60,18 @@
~LazyParams();
// All of these parameters are intended to be read on the IO thread.
- base::FilePath media_cache_path;
- int media_cache_max_size;
base::FilePath extensions_cookie_path;
bool restore_old_session_cookies;
bool persist_session_cookies;
- scoped_refptr<storage::SpecialStoragePolicy> special_storage_policy;
- std::unique_ptr<ReportingPermissionsChecker> reporting_permissions_checker;
};
ProfileImplIOData();
~ProfileImplIOData() override;
- std::unique_ptr<net::NetworkDelegate> ConfigureNetworkDelegate(
- IOThread* io_thread,
- std::unique_ptr<ChromeNetworkDelegate> chrome_network_delegate)
- const override;
-
- void InitializeInternal(net::URLRequestContextBuilder* builder,
- ProfileParams* profile_params,
- content::ProtocolHandlerMap* protocol_handlers,
- content::URLRequestInterceptorScopedVector
- request_interceptors) const override;
void OnMainRequestContextCreated(
ProfileParams* profile_params) const override;
void InitializeExtensionsCookieStore(
ProfileParams* profile_params) const override;
- net::URLRequestContext* InitializeMediaRequestContext(
- net::URLRequestContext* original_context,
- const StoragePartitionDescriptor& partition_descriptor,
- const char* name) const override;
- net::URLRequestContext* AcquireMediaRequestContext() const override;
- net::URLRequestContext* AcquireIsolatedMediaRequestContext(
- net::URLRequestContext* app_context,
- const StoragePartitionDescriptor& partition_descriptor) const override;
net::CookieStore* GetExtensionsCookieStore() const override;
// Lazy initialization params.
@@ -154,11 +79,8 @@
mutable std::unique_ptr<net::CookieStore> extensions_cookie_store_;
- mutable std::unique_ptr<net::URLRequestContext> media_request_context_;
-
// Parameters needed for isolated apps.
base::FilePath profile_path_;
- int app_media_cache_max_size_;
DISALLOW_COPY_AND_ASSIGN(ProfileImplIOData);
};
diff --git a/chrome/browser/profiles/profile_io_data.cc b/chrome/browser/profiles/profile_io_data.cc
index a77de6f..ae8b1c49 100644
--- a/chrome/browser/profiles/profile_io_data.cc
+++ b/chrome/browser/profiles/profile_io_data.cc
@@ -33,7 +33,6 @@
#include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h"
#include "chrome/browser/io_thread.h"
#include "chrome/browser/net/chrome_network_delegate.h"
-#include "chrome/browser/net/chrome_url_request_context_getter.h"
#include "chrome/browser/net/profile_network_context_service.h"
#include "chrome/browser/net/profile_network_context_service_factory.h"
#include "chrome/browser/policy/cloud/policy_header_service_factory.h"
@@ -79,7 +78,6 @@
#include "net/cert/ct_policy_enforcer.h"
#include "net/cert/multi_log_ct_verifier.h"
#include "net/cert/multi_threaded_cert_verifier.h"
-#include "net/cert_net/cert_net_fetcher_impl.h"
#include "net/cookies/canonical_cookie.h"
#include "net/cookies/cookie_store.h"
#include "net/http/http_network_session.h"
@@ -314,24 +312,6 @@
}
#endif // defined(OS_CHROMEOS)
-// For safe shutdown, must be called before the ProfileIOData is destroyed.
-void NotifyContextGettersOfShutdownOnIO(
- std::unique_ptr<ProfileIOData::ChromeURLRequestContextGetterVector>
- getters) {
- DCHECK_CURRENTLY_ON(BrowserThread::IO);
- for (auto& chrome_context_getter : *getters)
- chrome_context_getter->NotifyContextShuttingDown();
-}
-
-// Wraps |inner_job_factory| with |protocol_handler_interceptor|.
-std::unique_ptr<net::URLRequestJobFactory> CreateURLRequestJobFactory(
- std::unique_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>
- protocol_handler_interceptor,
- std::unique_ptr<net::URLRequestJobFactory> inner_job_factory) {
- protocol_handler_interceptor->Chain(std::move(inner_job_factory));
- return std::move(protocol_handler_interceptor);
-}
-
} // namespace
void ProfileIOData::InitializeOnUIThread(Profile* profile) {
@@ -492,56 +472,10 @@
if (base::FeatureList::IsEnabled(network::features::kNetworkService)) {
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
- base::BindOnce(&ProfileIOData::Init, base::Unretained(this), nullptr,
- content::URLRequestInterceptorScopedVector()));
+ base::BindOnce(&ProfileIOData::Init, base::Unretained(this)));
}
}
-ProfileIOData::MediaRequestContext::MediaRequestContext(const char* name) {
- set_name(name);
-}
-
-void ProfileIOData::MediaRequestContext::SetHttpTransactionFactory(
- std::unique_ptr<net::HttpTransactionFactory> http_factory) {
- http_factory_ = std::move(http_factory);
- set_http_transaction_factory(http_factory_.get());
-}
-
-ProfileIOData::MediaRequestContext::~MediaRequestContext() {
- AssertNoURLRequests();
-}
-
-ProfileIOData::AppRequestContext::AppRequestContext() {
- set_name("app_request");
-}
-
-void ProfileIOData::AppRequestContext::SetCookieStore(
- std::unique_ptr<net::CookieStore> cookie_store) {
- cookie_store_ = std::move(cookie_store);
- set_cookie_store(cookie_store_.get());
-}
-
-void ProfileIOData::AppRequestContext::SetHttpNetworkSession(
- std::unique_ptr<net::HttpNetworkSession> http_network_session) {
- http_network_session_ = std::move(http_network_session);
-}
-
-void ProfileIOData::AppRequestContext::SetHttpTransactionFactory(
- std::unique_ptr<net::HttpTransactionFactory> http_factory) {
- http_factory_ = std::move(http_factory);
- set_http_transaction_factory(http_factory_.get());
-}
-
-void ProfileIOData::AppRequestContext::SetJobFactory(
- std::unique_ptr<net::URLRequestJobFactory> job_factory) {
- job_factory_ = std::move(job_factory);
- set_job_factory(job_factory_.get());
-}
-
-ProfileIOData::AppRequestContext::~AppRequestContext() {
- AssertNoURLRequests();
-}
-
ProfileIOData::ProfileParams::ProfileParams() = default;
ProfileIOData::ProfileParams::~ProfileParams() = default;
@@ -552,9 +486,7 @@
#if defined(OS_CHROMEOS)
system_key_slot_use_type_(SystemKeySlotUseType::kNone),
#endif
- main_request_context_(nullptr),
resource_context_(new ResourceContext(this)),
- chrome_network_delegate_unowned_(nullptr),
profile_type_(profile_type) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
}
@@ -562,64 +494,6 @@
ProfileIOData::~ProfileIOData() {
if (BrowserThread::IsThreadInitialized(BrowserThread::IO))
DCHECK_CURRENTLY_ON(BrowserThread::IO);
-
- if (cert_net_fetcher_)
- cert_net_fetcher_->Shutdown();
-
- // Pull the contents of the request context maps onto the stack for sanity
- // checking of values in a minidump. http://crbug.com/260425
- size_t num_app_contexts = app_request_context_map_.size();
- size_t num_media_contexts = isolated_media_request_context_map_.size();
- size_t current_context = 0;
- static const size_t kMaxCachedContexts = 20;
- net::URLRequestContext* app_context_cache[kMaxCachedContexts] = {0};
- void* app_context_vtable_cache[kMaxCachedContexts] = {0};
- net::URLRequestContext* media_context_cache[kMaxCachedContexts] = {0};
- void* media_context_vtable_cache[kMaxCachedContexts] = {0};
- void* tmp_vtable = NULL;
- base::debug::Alias(&num_app_contexts);
- base::debug::Alias(&num_media_contexts);
- base::debug::Alias(¤t_context);
- base::debug::Alias(app_context_cache);
- base::debug::Alias(app_context_vtable_cache);
- base::debug::Alias(media_context_cache);
- base::debug::Alias(media_context_vtable_cache);
- base::debug::Alias(&tmp_vtable);
-
- current_context = 0;
- for (URLRequestContextMap::const_iterator it =
- app_request_context_map_.begin();
- current_context < kMaxCachedContexts &&
- it != app_request_context_map_.end();
- ++it, ++current_context) {
- app_context_cache[current_context] = it->second;
- memcpy(&app_context_vtable_cache[current_context],
- static_cast<void*>(it->second), sizeof(void*));
- }
-
- current_context = 0;
- for (URLRequestContextMap::const_iterator it =
- isolated_media_request_context_map_.begin();
- current_context < kMaxCachedContexts &&
- it != isolated_media_request_context_map_.end();
- ++it, ++current_context) {
- media_context_cache[current_context] = it->second;
- memcpy(&media_context_vtable_cache[current_context],
- static_cast<void*>(it->second), sizeof(void*));
- }
-
- current_context = 0;
- for (auto it = isolated_media_request_context_map_.begin();
- it != isolated_media_request_context_map_.end(); ++it) {
- if (current_context < kMaxCachedContexts) {
- CHECK_EQ(media_context_cache[current_context], it->second);
- memcpy(&tmp_vtable, static_cast<void*>(it->second), sizeof(void*));
- CHECK_EQ(media_context_vtable_cache[current_context], tmp_vtable);
- }
- it->second->AssertNoURLRequests();
- delete it->second;
- current_context++;
- }
}
// static
@@ -672,30 +546,6 @@
}
// static
-void ProfileIOData::InstallProtocolHandlers(
- net::URLRequestJobFactoryImpl* job_factory,
- content::ProtocolHandlerMap* protocol_handlers) {
- for (auto it = protocol_handlers->begin(); it != protocol_handlers->end();
- ++it) {
- bool set_protocol =
- job_factory->SetProtocolHandler(it->first, std::move(it->second));
- DCHECK(set_protocol);
- }
- protocol_handlers->clear();
-}
-
-// static
-void ProfileIOData::AddProtocolHandlersToBuilder(
- net::URLRequestContextBuilder* builder,
- content::ProtocolHandlerMap* protocol_handlers) {
- for (auto& protocol_handler : *protocol_handlers) {
- builder->SetProtocolHandler(protocol_handler.first,
- std::move(protocol_handler.second));
- }
- protocol_handlers->clear();
-}
-
-// static
void ProfileIOData::SetCertVerifierForTesting(
net::CertVerifier* cert_verifier) {
g_cert_verifier_for_profile_io_data_testing = cert_verifier;
@@ -705,92 +555,6 @@
return resource_context_.get();
}
-net::URLRequestContext* ProfileIOData::GetMainRequestContext() const {
- DCHECK(initialized_);
- return main_request_context_;
-}
-
-net::URLRequestContext* ProfileIOData::GetMediaRequestContext() const {
- DCHECK(initialized_);
- net::URLRequestContext* context = AcquireMediaRequestContext();
- DCHECK(context);
- return context;
-}
-
-net::URLRequestContext* ProfileIOData::GetIsolatedAppRequestContext(
- IOThread* io_thread,
- const StoragePartitionDescriptor& partition_descriptor,
- std::unique_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>
- protocol_handler_interceptor,
- content::ProtocolHandlerMap* protocol_handlers,
- content::URLRequestInterceptorScopedVector request_interceptors,
- network::mojom::NetworkContextRequest network_context_request,
- network::mojom::NetworkContextParamsPtr network_context_params) const {
- DCHECK(initialized_);
- if (base::ContainsKey(app_request_context_map_, partition_descriptor))
- return app_request_context_map_[partition_descriptor];
-
- // If the network service is enabled, just re-use the same dummy
- // URLRequestContext as for other requests.
- if (base::FeatureList::IsEnabled(network::features::kNetworkService))
- return main_request_context_;
-
- std::unique_ptr<network::URLRequestContextBuilderMojo> builder =
- std::make_unique<network::URLRequestContextBuilderMojo>();
- io_thread->SetUpProxyService(builder.get());
- builder->SetSharedCertVerifier(main_request_context_->cert_verifier());
- if (data_reduction_proxy_io_data_.get()) {
- builder->set_shared_proxy_delegate(
- data_reduction_proxy_io_data_->proxy_delegate());
- }
-
- AddProtocolHandlersToBuilder(builder.get(), protocol_handlers);
-
- if (!IsOffTheRecord()) {
- // The data reduction proxy interceptor should be as close to the network
- // as possible.
- request_interceptors.insert(
- request_interceptors.begin(),
- data_reduction_proxy_io_data()->CreateInterceptor());
- }
-
- SetUpJobFactoryDefaultsForBuilder(builder.get(),
- std::move(request_interceptors),
- std::move(protocol_handler_interceptor));
-
- builder->SetCreateHttpTransactionFactoryCallback(
- base::BindOnce(&content::CreateDevToolsNetworkTransactionFactory));
- builder->set_network_delegate(
- net::LayeredNetworkDelegate::CreatePassThroughNetworkDelegate(
- chrome_network_delegate_unowned_));
-
- net::URLRequestContext* context;
- app_network_contexts_.emplace_back(
- content::GetNetworkServiceImpl()->CreateNetworkContextWithBuilder(
- std::move(network_context_request), std::move(network_context_params),
- std::move(builder), &context));
-
- app_request_context_map_[partition_descriptor] = context;
- return context;
-}
-
-net::URLRequestContext* ProfileIOData::GetIsolatedMediaRequestContext(
- net::URLRequestContext* app_context,
- const StoragePartitionDescriptor& partition_descriptor) const {
- DCHECK(initialized_);
- net::URLRequestContext* context = NULL;
- if (base::ContainsKey(isolated_media_request_context_map_,
- partition_descriptor)) {
- context = isolated_media_request_context_map_[partition_descriptor];
- } else {
- context =
- AcquireIsolatedMediaRequestContext(app_context, partition_descriptor);
- isolated_media_request_context_map_[partition_descriptor] = context;
- }
- DCHECK(context);
- return context;
-}
-
extensions::InfoMap* ProfileIOData::GetExtensionInfoMap() const {
DCHECK(initialized_) << "ExtensionSystem not initialized";
#if BUILDFLAG(ENABLE_EXTENSIONS)
@@ -877,9 +641,7 @@
ProfileIOData::ResourceContext::~ResourceContext() {}
-void ProfileIOData::Init(
- content::ProtocolHandlerMap* protocol_handlers,
- content::URLRequestInterceptorScopedVector request_interceptors) const {
+void ProfileIOData::Init() const {
// The basic logic is implemented here. The specific initialization
// is done in InitializeInternal(), implemented by subtypes. Static helper
// functions have been provided to assist in common operations.
@@ -912,255 +674,13 @@
certificate_provider_ = std::move(profile_params_->certificate_provider);
#endif
- if (base::FeatureList::IsEnabled(network::features::kNetworkService)) {
- // Do nothing, |main_request_context_| should never be accessed.
- } else {
- IOThread* const io_thread = profile_params_->io_thread;
-#if BUILDFLAG(ENABLE_EXTENSIONS)
- IOThread::Globals* const io_thread_globals = io_thread->globals();
-#endif
-
- // Create the main request context.
- std::unique_ptr<network::URLRequestContextBuilderMojo> builder =
- std::make_unique<network::URLRequestContextBuilderMojo>();
-
- std::unique_ptr<ChromeNetworkDelegate> chrome_network_delegate(
- new ChromeNetworkDelegate(
-#if BUILDFLAG(ENABLE_EXTENSIONS)
- io_thread_globals->extension_event_router_forwarder.get()));
-#else
- nullptr));
-#endif
-
-#if BUILDFLAG(ENABLE_EXTENSIONS)
- chrome_network_delegate->set_extension_info_map(
- profile_params_->extension_info_map.get());
-#endif
-
- chrome_network_delegate->set_profile(profile_params_->profile);
- chrome_network_delegate->set_profile_path(profile_params_->path);
- chrome_network_delegate->set_cookie_settings(
- profile_params_->cookie_settings.get());
- chrome_network_delegate->set_force_google_safe_search(
- &force_google_safesearch_);
-
- chrome_network_delegate_unowned_ = chrome_network_delegate.get();
-
- std::unique_ptr<net::NetworkDelegate> network_delegate =
- ConfigureNetworkDelegate(profile_params_->io_thread,
- std::move(chrome_network_delegate));
-
- builder->set_network_delegate(std::move(network_delegate));
-
- io_thread->SetUpProxyService(builder.get());
-
- if (g_cert_verifier_for_profile_io_data_testing) {
- builder->SetCertVerifier(
- std::make_unique<WrappedCertVerifierForProfileIODataTesting>());
- } else {
-#if defined(OS_ANDROID) || defined(OS_FUCHSIA) || \
- BUILDFLAG(TRIAL_COMPARISON_CERT_VERIFIER_SUPPORTED)
- cert_net_fetcher_ = base::MakeRefCounted<net::CertNetFetcherImpl>();
-#endif
- std::unique_ptr<net::CertVerifier> cert_verifier;
-#if defined(OS_CHROMEOS)
- crypto::ScopedPK11Slot public_slot =
- crypto::GetPublicSlotForChromeOSUser(username_hash_);
- // The private slot won't be ready by this point. It shouldn't be
- // necessary for cert trust purposes anyway.
- scoped_refptr<net::CertVerifyProc> verify_proc(
- new network::CertVerifyProcChromeOS(std::move(public_slot)));
- if (profile_params_->policy_cert_verifier) {
- profile_params_->policy_cert_verifier->InitializeOnIOThread(
- verify_proc);
- cert_verifier = std::move(profile_params_->policy_cert_verifier);
- } else {
- cert_verifier = std::make_unique<net::CachingCertVerifier>(
- std::make_unique<net::MultiThreadedCertVerifier>(
- verify_proc.get()));
- }
-#elif BUILDFLAG(TRIAL_COMPARISON_CERT_VERIFIER_SUPPORTED)
- auto& trial_params = profile_params_->main_network_context_params
- ->trial_comparison_cert_verifier_params;
- if (trial_params) {
- cert_verifier = std::make_unique<net::CachingCertVerifier>(
- std::make_unique<network::TrialComparisonCertVerifierMojo>(
- trial_params->initial_allowed,
- std::move(trial_params->config_client_request),
- std::move(trial_params->report_client),
- net::CertVerifyProc::CreateDefault(cert_net_fetcher_),
- net::CreateCertVerifyProcBuiltin(cert_net_fetcher_)));
- }
-#endif
- if (!cert_verifier) {
- cert_verifier = std::make_unique<net::CachingCertVerifier>(
- std::make_unique<net::MultiThreadedCertVerifier>(
- net::CertVerifyProc::CreateDefault(cert_net_fetcher_)));
- }
- const base::CommandLine& command_line =
- *base::CommandLine::ForCurrentProcess();
- cert_verifier = network::IgnoreErrorsCertVerifier::MaybeWrapCertVerifier(
- command_line, switches::kUserDataDir, std::move(cert_verifier));
- builder->SetCertVerifier(std::move(cert_verifier));
- }
-
- // Install the New Tab Page Interceptor.
- if (profile_params_->new_tab_page_interceptor.get()) {
- request_interceptors.push_back(
- std::move(profile_params_->new_tab_page_interceptor));
- }
-
- if (data_reduction_proxy_io_data_.get()) {
- builder->set_shared_proxy_delegate(
- data_reduction_proxy_io_data_->proxy_delegate());
- }
-
- InitializeInternal(builder.get(), profile_params_.get(), protocol_handlers,
- std::move(request_interceptors));
-
- builder->SetCreateHttpTransactionFactoryCallback(
- base::BindOnce(&content::CreateDevToolsNetworkTransactionFactory));
-
- main_network_context_ =
- content::GetNetworkServiceImpl()->CreateNetworkContextWithBuilder(
- std::move(profile_params_->main_network_context_request),
- std::move(profile_params_->main_network_context_params),
- std::move(builder), &main_request_context_);
-
- if (cert_net_fetcher_)
- cert_net_fetcher_->SetURLRequestContext(main_request_context_);
- }
-
OnMainRequestContextCreated(profile_params_.get());
profile_params_.reset();
initialized_ = true;
}
-std::unique_ptr<net::URLRequestJobFactory>
-ProfileIOData::SetUpJobFactoryDefaults(
- std::unique_ptr<net::URLRequestJobFactoryImpl> job_factory,
- content::URLRequestInterceptorScopedVector request_interceptors,
- std::unique_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>
- protocol_handler_interceptor,
- net::NetworkDelegate* network_delegate,
- net::HostResolver* host_resolver) const {
- // NOTE(willchan): Keep these protocol handlers in sync with
- // ProfileIOData::IsHandledProtocol().
- bool set_protocol = job_factory->SetProtocolHandler(
- url::kFileScheme,
- std::make_unique<net::FileProtocolHandler>(
- base::CreateTaskRunnerWithTraits(
- {base::MayBlock(), base::TaskPriority::USER_VISIBLE,
- base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN})));
- DCHECK(set_protocol);
-
-#if BUILDFLAG(ENABLE_EXTENSIONS)
- DCHECK(extension_info_map_.get());
- // Check only for incognito (and not Chrome OS guest mode GUEST_PROFILE).
- bool is_incognito = profile_type() == Profile::INCOGNITO_PROFILE;
- set_protocol = job_factory->SetProtocolHandler(
- extensions::kExtensionScheme,
- extensions::CreateExtensionProtocolHandler(is_incognito,
- extension_info_map_.get()));
- DCHECK(set_protocol);
-#endif
- set_protocol = job_factory->SetProtocolHandler(
- url::kDataScheme, std::make_unique<net::DataProtocolHandler>());
- DCHECK(set_protocol);
-#if defined(OS_CHROMEOS)
- if (profile_params_) {
- set_protocol = job_factory->SetProtocolHandler(
- content::kExternalFileScheme,
- std::make_unique<chromeos::ExternalFileProtocolHandler>(
- profile_params_->profile));
- DCHECK(set_protocol);
- }
-#endif // defined(OS_CHROMEOS)
-#if defined(OS_ANDROID)
- set_protocol = job_factory->SetProtocolHandler(
- url::kContentScheme,
- content::ContentProtocolHandler::Create(base::CreateTaskRunnerWithTraits(
- {base::MayBlock(), base::TaskPriority::USER_VISIBLE,
- base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN})));
-#endif
-
- job_factory->SetProtocolHandler(
- url::kAboutScheme,
- std::make_unique<about_handler::AboutProtocolHandler>());
-
-#if !BUILDFLAG(DISABLE_FTP_SUPPORT)
- job_factory->SetProtocolHandler(
- url::kFtpScheme, net::FtpProtocolHandler::Create(host_resolver));
-#endif // !BUILDFLAG(DISABLE_FTP_SUPPORT)
-
- // Set up interceptors in the reverse order.
- std::unique_ptr<net::URLRequestJobFactory> top_job_factory =
- std::move(job_factory);
- for (auto i = request_interceptors.rbegin(); i != request_interceptors.rend();
- ++i) {
- top_job_factory.reset(new net::URLRequestInterceptingJobFactory(
- std::move(top_job_factory), std::move(*i)));
- }
- request_interceptors.clear();
-
- if (protocol_handler_interceptor) {
- protocol_handler_interceptor->Chain(std::move(top_job_factory));
- return std::move(protocol_handler_interceptor);
- } else {
- return top_job_factory;
- }
-}
-
-void ProfileIOData::SetUpJobFactoryDefaultsForBuilder(
- net::URLRequestContextBuilder* builder,
- content::URLRequestInterceptorScopedVector request_interceptors,
- std::unique_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>
- protocol_handler_interceptor) const {
-// NOTE(willchan): Keep these protocol handlers in sync with
-// ProfileIOData::IsHandledProtocol().
-#if BUILDFLAG(ENABLE_EXTENSIONS)
- DCHECK(extension_info_map_.get());
- // Check only for incognito (and not Chrome OS guest mode GUEST_PROFILE).
- bool is_incognito = profile_type() == Profile::INCOGNITO_PROFILE;
- builder->SetProtocolHandler(extensions::kExtensionScheme,
- extensions::CreateExtensionProtocolHandler(
- is_incognito, extension_info_map_.get()));
-#endif
-#if defined(OS_CHROMEOS)
- if (profile_params_) {
- builder->SetProtocolHandler(
- content::kExternalFileScheme,
- std::make_unique<chromeos::ExternalFileProtocolHandler>(
- profile_params_->profile));
- }
-#endif // defined(OS_CHROMEOS)
-#if defined(OS_ANDROID)
- builder->SetProtocolHandler(
- url::kContentScheme,
- content::ContentProtocolHandler::Create(base::CreateTaskRunnerWithTraits(
- {base::MayBlock(), base::TaskPriority::USER_VISIBLE,
- base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN})));
-#endif
-
- builder->SetProtocolHandler(
- url::kAboutScheme,
- std::make_unique<about_handler::AboutProtocolHandler>());
-
- // File support is needed for PAC scripts that use file URLs.
- // TODO(crbug.com/839566): remove file support for all cases.
- builder->set_file_enabled(true);
-
- builder->SetInterceptors(std::move(request_interceptors));
-
- if (protocol_handler_interceptor) {
- builder->set_create_intercepting_job_factory(base::BindOnce(
- &CreateURLRequestJobFactory, std::move(protocol_handler_interceptor)));
- }
-}
-
-void ProfileIOData::ShutdownOnUIThread(
- std::unique_ptr<ChromeURLRequestContextGetterVector> context_getters) {
+void ProfileIOData::ShutdownOnUIThread() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
google_services_user_account_id_.Destroy();
@@ -1184,15 +704,6 @@
account_consistency_mirror_required_pref_.Destroy();
#endif
- if (!context_getters->empty()) {
- if (BrowserThread::IsThreadInitialized(BrowserThread::IO)) {
- base::PostTaskWithTraits(
- FROM_HERE, {BrowserThread::IO},
- base::BindOnce(&NotifyContextGettersOfShutdownOnIO,
- std::move(context_getters)));
- }
- }
-
bool posted = BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, this);
if (!posted)
delete this;
@@ -1201,19 +712,3 @@
void ProfileIOData::DestroyResourceContext() {
resource_context_.reset();
}
-
-std::unique_ptr<net::HttpCache> ProfileIOData::CreateHttpFactory(
- net::HttpTransactionFactory* main_http_factory,
- std::unique_ptr<net::HttpCache::BackendFactory> backend) const {
- DCHECK(main_http_factory);
- net::HttpNetworkSession* shared_session = main_http_factory->GetSession();
- return std::make_unique<net::HttpCache>(
- content::CreateDevToolsNetworkTransactionFactory(shared_session),
- std::move(backend), false /* is_main_cache */);
-}
-
-std::unique_ptr<net::NetworkDelegate> ProfileIOData::ConfigureNetworkDelegate(
- IOThread* io_thread,
- std::unique_ptr<ChromeNetworkDelegate> chrome_network_delegate) const {
- return std::move(chrome_network_delegate);
-}
diff --git a/chrome/browser/profiles/profile_io_data.h b/chrome/browser/profiles/profile_io_data.h
index 78a6561..1e98dd96 100644
--- a/chrome/browser/profiles/profile_io_data.h
+++ b/chrome/browser/profiles/profile_io_data.h
@@ -38,8 +38,6 @@
#include "services/network/public/mojom/network_service.mojom.h"
#include "services/network/url_request_context_owner.h"
-class ChromeNetworkDelegate;
-class ChromeURLRequestContextGetter;
class HostContentSettingsMap;
class ProtocolHandlerRegistry;
@@ -60,13 +58,10 @@
}
namespace net {
-class CertNetFetcherImpl;
class CertVerifier;
class ClientCertStore;
class CookieStore;
class HttpTransactionFactory;
-class URLRequestContextBuilder;
-class URLRequestJobFactoryImpl;
} // namespace net
namespace network {
@@ -80,9 +75,6 @@
// possibly in unit tests where there is no IO thread).
class ProfileIOData {
public:
- typedef std::vector<scoped_refptr<ChromeURLRequestContextGetter>>
- ChromeURLRequestContextGetterVector;
-
virtual ~ProfileIOData();
static ProfileIOData* FromResourceContext(content::ResourceContext* rc);
@@ -95,48 +87,16 @@
// net::URLRequest.
static bool IsHandledURL(const GURL& url);
- // Utility to install additional WebUI handlers into the |job_factory|.
- // Ownership of the handlers is transfered from |protocol_handlers|
- // to the |job_factory|.
- // TODO(mmenke): Remove this, once only AddProtocolHandlersToBuilder is used.
- static void InstallProtocolHandlers(
- net::URLRequestJobFactoryImpl* job_factory,
- content::ProtocolHandlerMap* protocol_handlers);
-
- // Utility to install additional WebUI handlers into |builder|. Ownership of
- // the handlers is transfered from |protocol_handlers| to |builder|.
- static void AddProtocolHandlersToBuilder(
- net::URLRequestContextBuilder* builder,
- content::ProtocolHandlerMap* protocol_handlers);
-
// Sets a global CertVerifier to use when initializing all profiles.
static void SetCertVerifierForTesting(net::CertVerifier* cert_verifier);
// Called by Profile.
content::ResourceContext* GetResourceContext() const;
- // Initializes the ProfileIOData object and primes the RequestContext
- // generation. Must be called prior to any of the Get*() methods other than
- // GetResouceContext.
- void Init(
- content::ProtocolHandlerMap* protocol_handlers,
- content::URLRequestInterceptorScopedVector request_interceptors) const;
+ // Initializes the ProfileIOData object.
+ void Init() const;
- net::URLRequestContext* GetMainRequestContext() const;
- net::URLRequestContext* GetMediaRequestContext() const;
virtual net::CookieStore* GetExtensionsCookieStore() const = 0;
- net::URLRequestContext* GetIsolatedAppRequestContext(
- IOThread* io_thread,
- const StoragePartitionDescriptor& partition_descriptor,
- std::unique_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>
- protocol_handler_interceptor,
- content::ProtocolHandlerMap* protocol_handlers,
- content::URLRequestInterceptorScopedVector request_interceptors,
- network::mojom::NetworkContextRequest network_context_request,
- network::mojom::NetworkContextParamsPtr network_context_params) const;
- net::URLRequestContext* GetIsolatedMediaRequestContext(
- net::URLRequestContext* app_context,
- const StoragePartitionDescriptor& partition_descriptor) const;
// These are useful when the Chrome layer is called from the content layer
// with a content::ResourceContext, and they want access to Chrome data for
@@ -253,46 +213,6 @@
};
#endif
- // A URLRequestContext for media that owns its HTTP factory, to ensure
- // it is deleted.
- class MediaRequestContext : public net::URLRequestContext {
- public:
- // |name| is used to describe this context. Currently there are two kinds of
- // media request context -- main media request context ("main_meda") and
- // isolated app media request context ("isolated_media").
- explicit MediaRequestContext(const char* name);
-
- void SetHttpTransactionFactory(
- std::unique_ptr<net::HttpTransactionFactory> http_factory);
-
- private:
- ~MediaRequestContext() override;
-
- std::unique_ptr<net::HttpTransactionFactory> http_factory_;
- };
-
- // A URLRequestContext for apps that owns its cookie store and HTTP factory,
- // to ensure they are deleted.
- class AppRequestContext : public net::URLRequestContext {
- public:
- AppRequestContext();
-
- void SetCookieStore(std::unique_ptr<net::CookieStore> cookie_store);
- void SetHttpNetworkSession(
- std::unique_ptr<net::HttpNetworkSession> http_network_session);
- void SetHttpTransactionFactory(
- std::unique_ptr<net::HttpTransactionFactory> http_factory);
- void SetJobFactory(std::unique_ptr<net::URLRequestJobFactory> job_factory);
-
- private:
- ~AppRequestContext() override;
-
- std::unique_ptr<net::CookieStore> cookie_store_;
- std::unique_ptr<net::HttpNetworkSession> http_network_session_;
- std::unique_ptr<net::HttpTransactionFactory> http_factory_;
- std::unique_ptr<net::URLRequestJobFactory> job_factory_;
- };
-
// Created on the UI thread, read on the IO thread during ProfileIOData lazy
// initialization.
struct ProfileParams {
@@ -343,56 +263,14 @@
void InitializeOnUIThread(Profile* profile);
- // Does common setup of the URLRequestJobFactories. Adds default
- // ProtocolHandlers to |job_factory|, adds URLRequestInterceptors in front of
- // it as needed, and returns the result.
- //
- // |protocol_handler_interceptor| is configured to intercept URLRequests
- // before all other URLRequestInterceptors, if non-null.
- // |host_resolver| is needed to set up the FtpProtocolHandler.
- //
- // TODO(mmenke): Remove this once all URLRequestContexts are set up using
- // URLRequestContextBuilders.
- std::unique_ptr<net::URLRequestJobFactory> SetUpJobFactoryDefaults(
- std::unique_ptr<net::URLRequestJobFactoryImpl> job_factory,
- content::URLRequestInterceptorScopedVector request_interceptors,
- std::unique_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>
- protocol_handler_interceptor,
- net::NetworkDelegate* network_delegate,
- net::HostResolver* host_resolver) const;
-
- // Does common setup of the URLRequestJobFactories. Adds
- // |request_interceptors| and some default ProtocolHandlers to |builder|, adds
- // URLRequestInterceptors in front of them as needed.
- //
- // Unlike SetUpJobFactoryDefaults, leaves configuring data, file, and ftp
- // support to the ProfileNetworkContextService.
- //
- // |protocol_handler_interceptor| is configured to intercept URLRequests
- // before all other URLRequestInterceptors, if non-null.
- void SetUpJobFactoryDefaultsForBuilder(
- net::URLRequestContextBuilder* builder,
- content::URLRequestInterceptorScopedVector request_interceptors,
- std::unique_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>
- protocol_handler_interceptor) const;
-
- // Called when the Profile is destroyed. |context_getters| must include all
- // URLRequestContextGetters that refer to the ProfileIOData's
- // URLRequestContexts. Triggers destruction of the ProfileIOData and shuts
- // down |context_getters| safely on the IO thread.
- // TODO(mmenke): Passing all those URLRequestContextGetters around like this
- // is really silly. Can we do something cleaner?
- void ShutdownOnUIThread(
- std::unique_ptr<ChromeURLRequestContextGetterVector> context_getters);
+ // Called when the Profile is destroyed. Triggers destruction of the
+ // ProfileIOData.
+ void ShutdownOnUIThread();
void set_data_reduction_proxy_io_data(
std::unique_ptr<data_reduction_proxy::DataReductionProxyIOData>
data_reduction_proxy_io_data) const;
- net::URLRequestContext* main_request_context() const {
- return main_request_context_;
- }
-
bool initialized() const {
return initialized_;
}
@@ -402,12 +280,6 @@
// URLRequests may be accessing.
void DestroyResourceContext();
- // Creates network transaction factory. The created factory will share
- // HttpNetworkSession with |main_http_factory|.
- std::unique_ptr<net::HttpCache> CreateHttpFactory(
- net::HttpTransactionFactory* main_http_factory,
- std::unique_ptr<net::HttpCache::BackendFactory> backend) const;
-
private:
class ResourceContext : public content::ResourceContext {
public:
@@ -420,32 +292,10 @@
ProfileIOData* const io_data_;
};
- typedef std::map<StoragePartitionDescriptor,
- net::URLRequestContext*,
- StoragePartitionDescriptorLess>
- URLRequestContextMap;
-
// --------------------------------------------
// Virtual interface for subtypes to implement:
// --------------------------------------------
- // Does any necessary additional configuration of the network delegate,
- // including composing it with other NetworkDelegates, if needed. By default,
- // just returns the input NetworkDelegate.
- virtual std::unique_ptr<net::NetworkDelegate> ConfigureNetworkDelegate(
- IOThread* io_thread,
- std::unique_ptr<ChromeNetworkDelegate> chrome_network_delegate) const;
-
- // Does the initialization of the URLRequestContextBuilder for a ProfileIOData
- // subclass. Subclasseses should use the static helper functions above to
- // implement this.
- virtual void InitializeInternal(
- net::URLRequestContextBuilder* builder,
- ProfileParams* profile_params,
- content::ProtocolHandlerMap* protocol_handlers,
- content::URLRequestInterceptorScopedVector request_interceptors)
- const = 0;
-
// Called after the main URLRequestContext has been initialized, just after
// InitializeInternal().
virtual void OnMainRequestContextCreated(
@@ -455,22 +305,6 @@
virtual void InitializeExtensionsCookieStore(
ProfileParams* profile_params) const = 0;
- // Does an on-demand initialization of a media RequestContext for the given
- // isolated app.
- virtual net::URLRequestContext* InitializeMediaRequestContext(
- net::URLRequestContext* original_context,
- const StoragePartitionDescriptor& details,
- const char* name) const = 0;
-
- // These functions are used to transfer ownership of the lazily initialized
- // context from ProfileIOData to the URLRequestContextGetter.
- virtual net::URLRequestContext*
- AcquireMediaRequestContext() const = 0;
- virtual net::URLRequestContext*
- AcquireIsolatedMediaRequestContext(
- net::URLRequestContext* app_context,
- const StoragePartitionDescriptor& partition_descriptor) const = 0;
-
// The order *DOES* matter for the majority of these member variables, so
// don't move them around unless you know what you're doing!
// General rules:
@@ -537,35 +371,12 @@
mutable std::unique_ptr<chromeos::CertificateProvider> certificate_provider_;
#endif
- // When the network service is disabled, this holds on to a
- // content::NetworkContext class that owns |main_request_context_|.
- mutable std::unique_ptr<network::mojom::NetworkContext> main_network_context_;
- // When the network service is disabled, this holds onto all the
- // NetworkContexts pointed at by the |app_request_context_map_|.
- mutable std::list<std::unique_ptr<network::mojom::NetworkContext>>
- app_network_contexts_;
- // When the network service is disabled, this owns |system_request_context|.
- mutable network::URLRequestContextOwner main_request_context_owner_;
- mutable net::URLRequestContext* main_request_context_;
- // When the network service is disabled, this holds the CertNetFetcher used
- // by the profile's CertVerifier. May be nullptr if CertNetFetcher is not
- // used by the current platform.
- mutable scoped_refptr<net::CertNetFetcherImpl> cert_net_fetcher_;
-
- // One URLRequestContext per isolated app for main and media requests.
- mutable URLRequestContextMap app_request_context_map_;
- mutable URLRequestContextMap isolated_media_request_context_map_;
-
mutable std::unique_ptr<ResourceContext> resource_context_;
mutable scoped_refptr<content_settings::CookieSettings> cookie_settings_;
mutable scoped_refptr<HostContentSettingsMap> host_content_settings_map_;
- // Owned (possibly with one or more layers of LayeredNetworkDelegate) by the
- // URLRequestContext, which is owned by the |main_network_context_|.
- mutable ChromeNetworkDelegate* chrome_network_delegate_unowned_;
-
const Profile::ProfileType profile_type_;
DISALLOW_COPY_AND_ASSIGN(ProfileIOData);
diff --git a/chrome/browser/signin/chrome_signin_helper.cc b/chrome/browser/signin/chrome_signin_helper.cc
index 5af0986..19b7532 100644
--- a/chrome/browser/signin/chrome_signin_helper.cc
+++ b/chrome/browser/signin/chrome_signin_helper.cc
@@ -431,10 +431,6 @@
ChromeRequestAdapter::~ChromeRequestAdapter() = default;
-bool ChromeRequestAdapter::IsMainRequestContext(ProfileIOData* io_data) {
- return request_->context() == io_data->GetMainRequestContext();
-}
-
content::ResourceRequestInfo::WebContentsGetter
ChromeRequestAdapter::GetWebContentsGetter() const {
auto* info = content::ResourceRequestInfo::ForRequest(request_);
@@ -510,14 +506,6 @@
if (io_data->IsOffTheRecord())
return; // Account consistency is disabled in incognito.
- if (!request->IsMainRequestContext(io_data)) {
- // Account consistency requires the AccountReconcilor, which is only
- // attached to the main request context.
- // Note: InlineLoginUI uses an isolated request context and thus bypasses
- // the account consistency flow here. See http://crbug.com/428396
- return;
- }
-
int profile_mode_mask = PROFILE_MODE_DEFAULT;
if (io_data->incognito_availibility()->GetValue() ==
IncognitoModePrefs::DISABLED ||
diff --git a/chrome/browser/signin/chrome_signin_helper.h b/chrome/browser/signin/chrome_signin_helper.h
index 940e7c0..9c3998f 100644
--- a/chrome/browser/signin/chrome_signin_helper.h
+++ b/chrome/browser/signin/chrome_signin_helper.h
@@ -36,7 +36,6 @@
explicit ChromeRequestAdapter(net::URLRequest* request);
~ChromeRequestAdapter() override;
- virtual bool IsMainRequestContext(ProfileIOData* io_data);
virtual content::ResourceRequestInfo::WebContentsGetter GetWebContentsGetter()
const;
virtual content::ResourceType GetResourceType() const;
diff --git a/chrome/browser/signin/chrome_signin_proxying_url_loader_factory.cc b/chrome/browser/signin/chrome_signin_proxying_url_loader_factory.cc
index cec9191..a15602a 100644
--- a/chrome/browser/signin/chrome_signin_proxying_url_loader_factory.cc
+++ b/chrome/browser/signin/chrome_signin_proxying_url_loader_factory.cc
@@ -205,12 +205,6 @@
~ProxyRequestAdapter() override = default;
- // signin::ChromeRequestAdapter
- bool IsMainRequestContext(ProfileIOData* io_data) override {
- // This code is never reached from other request contexts.
- return true;
- }
-
content::ResourceRequestInfo::WebContentsGetter GetWebContentsGetter()
const override {
return in_progress_request_->factory_->web_contents_getter_;
diff --git a/chrome/browser/signin/chrome_signin_proxying_url_loader_factory_unittest.cc b/chrome/browser/signin/chrome_signin_proxying_url_loader_factory_unittest.cc
index 1c0e714..0224078 100644
--- a/chrome/browser/signin/chrome_signin_proxying_url_loader_factory_unittest.cc
+++ b/chrome/browser/signin/chrome_signin_proxying_url_loader_factory_unittest.cc
@@ -159,7 +159,6 @@
.WillOnce(
Invoke([&](ChromeRequestAdapter* adapter, const GURL& redirect_url) {
EXPECT_EQ(kTestURL, adapter->GetUrl());
- EXPECT_TRUE(adapter->IsMainRequestContext(nullptr /* io_data */));
EXPECT_EQ(content::ResourceType::kMainFrame,
adapter->GetResourceType());
EXPECT_EQ(GURL("https://chrome.com"), adapter->GetReferrerOrigin());
@@ -177,7 +176,6 @@
}))
.WillOnce(
Invoke([&](ChromeRequestAdapter* adapter, const GURL& redirect_url) {
- EXPECT_TRUE(adapter->IsMainRequestContext(nullptr));
EXPECT_EQ(content::ResourceType::kMainFrame,
adapter->GetResourceType());
diff --git a/chrome/browser/signin/chrome_signin_url_loader_throttle.cc b/chrome/browser/signin/chrome_signin_url_loader_throttle.cc
index 2c54f0d..8d074f1 100644
--- a/chrome/browser/signin/chrome_signin_url_loader_throttle.cc
+++ b/chrome/browser/signin/chrome_signin_url_loader_throttle.cc
@@ -25,12 +25,6 @@
~ThrottleRequestAdapter() override = default;
// ChromeRequestAdapter
- bool IsMainRequestContext(ProfileIOData* io_data) override {
- // The <webview> check in URLLoaderThrottle::MaybeCreate means this is
- // always true.
- return true;
- }
-
content::ResourceRequestInfo::WebContentsGetter GetWebContentsGetter()
const override {
return throttle_->web_contents_getter_;
diff --git a/chrome/browser/signin/chrome_signin_url_loader_throttle_unittest.cc b/chrome/browser/signin/chrome_signin_url_loader_throttle_unittest.cc
index 66b106f..68f284e 100644
--- a/chrome/browser/signin/chrome_signin_url_loader_throttle_unittest.cc
+++ b/chrome/browser/signin/chrome_signin_url_loader_throttle_unittest.cc
@@ -70,7 +70,6 @@
.WillOnce(
Invoke([&](ChromeRequestAdapter* adapter, const GURL& redirect_url) {
EXPECT_EQ(kTestURL, adapter->GetUrl());
- EXPECT_TRUE(adapter->IsMainRequestContext(nullptr /* io_data */));
EXPECT_EQ(content::ResourceType::kMainFrame,
adapter->GetResourceType());
EXPECT_EQ(GURL("https://chrome.com"), adapter->GetReferrerOrigin());
@@ -135,7 +134,6 @@
EXPECT_CALL(*delegate, ProcessRequest(_, _))
.WillOnce(
Invoke([&](ChromeRequestAdapter* adapter, const GURL& redirect_url) {
- EXPECT_TRUE(adapter->IsMainRequestContext(nullptr));
EXPECT_EQ(content::ResourceType::kMainFrame,
adapter->GetResourceType());