Commit b175a615 authored by John Abd-El-Malek's avatar John Abd-El-Malek Committed by Commit Bot

DCHECK if StoragePartition::GetRequestContext is called with the network service enabled.

There are a few instances remaining which use it, for those use a temporary friend class to disable the DCHECK.

Bug: 837753
Change-Id: I186488d87e44411a131f59b1b0def2133c7e2339
Reviewed-on: https://chromium-review.googlesource.com/c/1355136
Commit-Queue: John Abd-El-Malek <jam@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Reviewed-by: default avatarClark DuVall <cduvall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#613208}
parent 257151ca
......@@ -162,6 +162,7 @@ DeprecatedProfileInvalidationProviderFactory::BuildServiceInstanceFor(
IdentityManagerFactory::GetForProfile(profile)));
}
content::ScopedAllowGetURLRequestContext scoped_allow_get_url_request_context;
std::unique_ptr<TiclInvalidationService> service =
std::make_unique<TiclInvalidationService>(
GetUserAgent(), identity_provider.get(),
......
......@@ -13,6 +13,7 @@
#include "components/net_log/chrome_net_log.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/common/service_manager_connection.h"
#include "media/cast/net/cast_transport.h"
#include "media/cast/net/udp_transport_impl.h"
......@@ -122,9 +123,10 @@ void CastBindConnectorRequest(
namespace cast {
CastTransportHostFilter::CastTransportHostFilter(Profile* profile)
: BrowserMessageFilter(CastMsgStart),
url_request_context_getter_(profile->GetRequestContext()),
weak_factory_(this) {}
: BrowserMessageFilter(CastMsgStart), weak_factory_(this) {
content::ScopedAllowGetURLRequestContext scoped_allow_get_url_request_context;
url_request_context_getter_ = profile->GetRequestContext();
}
CastTransportHostFilter::~CastTransportHostFilter() {}
......
......@@ -18,6 +18,7 @@
#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;
......@@ -250,6 +251,7 @@ ChromeURLRequestContextGetter::CreateForIsolatedApp(
content::URLRequestInterceptorScopedVector request_interceptors,
network::mojom::NetworkContextRequest network_context_request,
network::mojom::NetworkContextParamsPtr network_context_params) {
content::ScopedAllowGetURLRequestContext scoped_allow_get_url_request_context;
ChromeURLRequestContextGetter* main_context =
static_cast<ChromeURLRequestContextGetter*>(profile->GetRequestContext());
return ChromeURLRequestContextGetter::CreateAndInit(
......
......@@ -6,8 +6,9 @@
#include "base/macros.h"
#include "content/public/browser/client_certificate_delegate.h"
#include "net/cert/x509_certificate.h"
#include "net/ssl/ssl_cert_request_info.h"
#include "net/url_request/url_request.h"
#include "net/ssl/ssl_private_key.h"
namespace {
......@@ -38,7 +39,6 @@ class FakeClientCertificateDelegate
} // namespace
SSLClientAuthRequestorMock::SSLClientAuthRequestorMock(
net::URLRequest* request,
const scoped_refptr<net::SSLCertRequestInfo>& cert_request_info)
: cert_request_info_(cert_request_info) {
}
......
......@@ -17,15 +17,13 @@ class ClientCertificateDelegate;
namespace net {
class SSLCertRequestInfo;
class SSLPrivateKey;
class URLRequest;
class X509Certificate;
}
class SSLClientAuthRequestorMock
: public base::RefCountedThreadSafe<SSLClientAuthRequestorMock> {
public:
SSLClientAuthRequestorMock(
net::URLRequest* request,
explicit SSLClientAuthRequestorMock(
const scoped_refptr<net::SSLCertRequestInfo>& cert_request_info);
std::unique_ptr<content::ClientCertificateDelegate> CreateDelegate();
......
......@@ -19,8 +19,6 @@
#include "net/ssl/ssl_cert_request_info.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "net/url_request/url_request.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_getter.h"
using ::testing::Mock;
using ::testing::StrictMock;
......@@ -40,8 +38,6 @@ void SSLClientCertificateSelectorTestBase::SetUpInProcessBrowserTestFixture() {
}
void SSLClientCertificateSelectorTestBase::SetUpOnMainThread() {
url_request_context_getter_ = browser()->profile()->GetRequestContext();
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(&SSLClientCertificateSelectorTestBase::SetUpOnIOThread,
......@@ -67,26 +63,12 @@ void SSLClientCertificateSelectorTestBase::TearDownOnMainThread() {
}
void SSLClientCertificateSelectorTestBase::SetUpOnIOThread() {
url_request_ = MakeURLRequest(url_request_context_getter_.get()).release();
auth_requestor_ = new StrictMock<SSLClientAuthRequestorMock>(
url_request_, cert_request_info_.get());
auth_requestor_ =
new StrictMock<SSLClientAuthRequestorMock>(cert_request_info_.get());
io_loop_finished_event_.Signal();
}
void SSLClientCertificateSelectorTestBase::TearDownOnIOThread() {
delete url_request_;
io_loop_finished_event_.Signal();
}
std::unique_ptr<net::URLRequest>
SSLClientCertificateSelectorTestBase::MakeURLRequest(
net::URLRequestContextGetter* context_getter) {
std::unique_ptr<net::URLRequest> request =
context_getter->GetURLRequestContext()->CreateRequest(
GURL("https://example"), net::DEFAULT_PRIORITY, NULL,
TRAFFIC_ANNOTATION_FOR_TESTS);
return request;
}
......@@ -12,10 +12,6 @@
#include "chrome/test/base/in_process_browser_test.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace net {
class URLRequestContextGetter;
}
class SSLClientCertificateSelectorTestBase : public InProcessBrowserTest {
public:
SSLClientCertificateSelectorTestBase();
......@@ -30,14 +26,8 @@ class SSLClientCertificateSelectorTestBase : public InProcessBrowserTest {
virtual void TearDownOnIOThread();
protected:
std::unique_ptr<net::URLRequest> MakeURLRequest(
net::URLRequestContextGetter* context_getter);
base::WaitableEvent io_loop_finished_event_;
scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_;
net::URLRequest* url_request_;
scoped_refptr<net::SSLCertRequestInfo> cert_request_info_;
scoped_refptr<testing::StrictMock<SSLClientAuthRequestorMock> >
auth_requestor_;
......
......@@ -49,7 +49,6 @@ class SSLClientCertificateSelectorTest : public InProcessBrowserTest {
: io_loop_finished_event_(
base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED),
url_request_(NULL),
selector_(NULL) {}
void SetUpInProcessBrowserTestFixture() override {
......@@ -67,8 +66,6 @@ class SSLClientCertificateSelectorTest : public InProcessBrowserTest {
}
void SetUpOnMainThread() override {
url_request_context_getter_ = browser()->profile()->GetRequestContext();
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(&SSLClientCertificateSelectorTest::SetUpOnIOThread,
......@@ -94,10 +91,7 @@ class SSLClientCertificateSelectorTest : public InProcessBrowserTest {
}
virtual void SetUpOnIOThread() {
url_request_ = MakeURLRequest(url_request_context_getter_.get()).release();
auth_requestor_ = new StrictMock<SSLClientAuthRequestorMock>(
url_request_,
cert_request_info_);
io_loop_finished_event_.Signal();
......@@ -117,8 +111,6 @@ class SSLClientCertificateSelectorTest : public InProcessBrowserTest {
}
virtual void CleanUpOnIOThread() {
delete url_request_;
io_loop_finished_event_.Signal();
}
......@@ -132,9 +124,6 @@ class SSLClientCertificateSelectorTest : public InProcessBrowserTest {
base::WaitableEvent io_loop_finished_event_;
scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_;
net::URLRequest* url_request_;
std::unique_ptr<net::FakeClientCertIdentity> cert_identity_1_;
std::unique_ptr<net::FakeClientCertIdentity> cert_identity_2_;
scoped_refptr<net::SSLCertRequestInfo> cert_request_info_;
......@@ -198,16 +187,9 @@ class SSLClientCertificateSelectorMultiTabTest
}
void SetUpOnIOThread() override {
url_request_1_ =
MakeURLRequest(url_request_context_getter_.get()).release();
url_request_2_ =
MakeURLRequest(url_request_context_getter_.get()).release();
auth_requestor_1_ = new StrictMock<SSLClientAuthRequestorMock>(
url_request_1_,
cert_request_info_1_);
auth_requestor_2_ = new StrictMock<SSLClientAuthRequestorMock>(
url_request_2_,
cert_request_info_2_);
SSLClientCertificateSelectorTest::SetUpOnIOThread();
......@@ -220,14 +202,10 @@ class SSLClientCertificateSelectorMultiTabTest
}
void CleanUpOnIOThread() override {
delete url_request_1_;
delete url_request_2_;
SSLClientCertificateSelectorTest::CleanUpOnIOThread();
}
protected:
net::URLRequest* url_request_1_;
net::URLRequest* url_request_2_;
scoped_refptr<net::SSLCertRequestInfo> cert_request_info_1_;
scoped_refptr<net::SSLCertRequestInfo> cert_request_info_2_;
scoped_refptr<StrictMock<SSLClientAuthRequestorMock> > auth_requestor_1_;
......@@ -251,7 +229,6 @@ class SSLClientCertificateSelectorMultiProfileTest
void SetUpOnMainThread() override {
browser_1_ = CreateIncognitoBrowser();
url_request_context_getter_1_ = browser_1_->profile()->GetRequestContext();
// Also calls SetUpOnIOThread.
SSLClientCertificateSelectorTest::SetUpOnMainThread();
......@@ -278,11 +255,7 @@ class SSLClientCertificateSelectorMultiProfileTest
}
void SetUpOnIOThread() override {
url_request_1_ =
MakeURLRequest(url_request_context_getter_1_.get()).release();
auth_requestor_1_ = new StrictMock<SSLClientAuthRequestorMock>(
url_request_1_,
cert_request_info_1_);
SSLClientCertificateSelectorTest::SetUpOnIOThread();
......@@ -294,14 +267,11 @@ class SSLClientCertificateSelectorMultiProfileTest
}
void CleanUpOnIOThread() override {
delete url_request_1_;
SSLClientCertificateSelectorTest::CleanUpOnIOThread();
}
protected:
Browser* browser_1_;
scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_1_;
net::URLRequest* url_request_1_;
scoped_refptr<net::SSLCertRequestInfo> cert_request_info_1_;
scoped_refptr<StrictMock<SSLClientAuthRequestorMock> > auth_requestor_1_;
SSLClientCertificateSelector* selector_1_;
......
......@@ -44,6 +44,7 @@
#include "net/test/embedded_test_server/request_handler_util.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_getter.h"
#include "services/network/public/cpp/features.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
......@@ -204,6 +205,12 @@ void NetInternalsTest::MessageHandler::AddCacheEntry(
ASSERT_TRUE(list_value->GetDouble(3, &expire_days_from_now));
ASSERT_TRUE(browser());
if (base::FeatureList::IsEnabled(network::features::kNetworkService)) {
// TODO(mattm): implement this with a ForTesting method on NetworkContext
// when it's needed.
return;
}
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(
......
......@@ -22,6 +22,7 @@
#include "components/download/public/common/download_url_parameters.h"
#include "components/download/public/common/download_utils.h"
#include "components/download/public/common/input_stream.h"
#include "services/network/public/cpp/features.h"
#include "services/network/public/cpp/resource_request.h"
#include "services/network/public/cpp/resource_response.h"
......@@ -370,10 +371,15 @@ void InProgressDownloadManager::StartDownloadWithItem(
// so that the DownloadItem can salvage what it can out of a failed
// resumption attempt.
download->Start(
std::move(download_file), std::move(info->request_handle), *info,
std::move(url_loader_factory_getter),
delegate_ ? delegate_->GetURLRequestContextGetter(*info) : nullptr);
net::URLRequestContextGetter* url_request_context_getter = nullptr;
if (delegate_ &&
!base::FeatureList::IsEnabled(network::features::kNetworkService)) {
url_request_context_getter = delegate_->GetURLRequestContextGetter(*info);
}
download->Start(std::move(download_file), std::move(info->request_handle),
*info, std::move(url_loader_factory_getter),
url_request_context_getter);
if (download_start_observer_)
download_start_observer_->OnDownloadStarted(download);
......
......@@ -219,10 +219,12 @@ StoragePartition* GetStoragePartitionFromConfig(
void SaveSessionStateOnIOThread(
const scoped_refptr<net::URLRequestContextGetter>& context_getter,
AppCacheServiceImpl* appcache_service) {
net::URLRequestContext* context = context_getter->GetURLRequestContext();
context->cookie_store()->SetForceKeepSessionState();
context->channel_id_service()->GetChannelIDStore()->
SetForceKeepSessionState();
if (context_getter) {
net::URLRequestContext* context = context_getter->GetURLRequestContext();
context->channel_id_service()
->GetChannelIDStore()
->SetForceKeepSessionState();
}
appcache_service->set_force_keep_session_state();
}
......@@ -557,13 +559,15 @@ void BrowserContext::SaveSessionState(BrowserContext* browser_context) {
base::WrapRefCounted(database_tracker)));
if (BrowserThread::IsThreadInitialized(BrowserThread::IO)) {
scoped_refptr<net::URLRequestContextGetter> context_getter;
// Channel ID isn't supported with network service.
if (!base::FeatureList::IsEnabled(network::features::kNetworkService))
context_getter = storage_partition->GetURLRequestContext();
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(
&SaveSessionStateOnIOThread,
base::WrapRefCounted(storage_partition->GetURLRequestContext()),
static_cast<AppCacheServiceImpl*>(
storage_partition->GetAppCacheService())));
base::BindOnce(&SaveSessionStateOnIOThread, context_getter,
static_cast<AppCacheServiceImpl*>(
storage_partition->GetAppCacheService())));
}
storage_partition->GetCookieManagerForBrowserProcess()
......
......@@ -208,17 +208,6 @@ class ClearSiteDataHandlerBrowserTest : public ContentBrowserTest {
base::BindRepeating(&ClearSiteDataHandlerBrowserTest::HandleRequest,
base::Unretained(this)));
ASSERT_TRUE(https_server_->Start());
// Initialize the cookie store pointer on the IO thread.
base::RunLoop run_loop;
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(
&ClearSiteDataHandlerBrowserTest::InitializeCookieStore,
base::Unretained(this),
base::Unretained(storage_partition()->GetURLRequestContext()),
run_loop.QuitClosure()));
run_loop.Run();
}
BrowserContext* browser_context() {
......@@ -229,14 +218,6 @@ class ClearSiteDataHandlerBrowserTest : public ContentBrowserTest {
return BrowserContext::GetDefaultStoragePartition(browser_context());
}
void InitializeCookieStore(
net::URLRequestContextGetter* request_context_getter,
base::Closure callback) {
cookie_store_ =
request_context_getter->GetURLRequestContext()->cookie_store();
std::move(callback).Run();
}
// Adds a cookie for the |url|. Used in the cookie integration tests.
void AddCookie(const GURL& url) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
......@@ -514,8 +495,6 @@ class ClearSiteDataHandlerBrowserTest : public ContentBrowserTest {
std::unique_ptr<net::EmbeddedTestServer> https_server_;
TestBrowsingDataRemoverDelegate embedder_delegate_;
net::CookieStore* cookie_store_;
};
// Tests that the header is recognized on the beginning, in the middle, and on
......
......@@ -22,6 +22,7 @@
#include "base/strings/utf_string_conversions.h"
#include "base/syslog_logging.h"
#include "base/task/post_task.h"
#include "build/build_config.h"
#include "content/browser/background_fetch/background_fetch_context.h"
#include "content/browser/blob_storage/blob_registry_wrapper.h"
#include "content/browser/blob_storage/chrome_blob_storage_context.h"
......@@ -84,6 +85,9 @@ namespace content {
namespace {
// Only used when the network service is enabled.
bool g_allow_get_url_request_context = false;
base::LazyInstance<StoragePartitionImpl::CreateNetworkFactoryCallback>::Leaky
g_url_loader_factory_callback_for_test = LAZY_INSTANCE_INITIALIZER;
......@@ -254,6 +258,20 @@ void ClearSessionStorageOnUIThread(
} // namespace
ScopedAllowGetURLRequestContext::ScopedAllowGetURLRequestContext() {
if (!base::FeatureList::IsEnabled(network::features::kNetworkService))
return;
DCHECK(!g_allow_get_url_request_context);
g_allow_get_url_request_context = true;
}
ScopedAllowGetURLRequestContext::~ScopedAllowGetURLRequestContext() {
if (!base::FeatureList::IsEnabled(network::features::kNetworkService))
return;
DCHECK(g_allow_get_url_request_context);
g_allow_get_url_request_context = false;
}
// Class to own the NetworkContext wrapping a storage partitions
// URLRequestContext, when the ContentBrowserClient doesn't provide a
// NetworkContext itself.
......@@ -475,7 +493,6 @@ class StoragePartitionImpl::DataDeletionHelper {
const OriginMatcherFunction& origin_matcher,
CookieDeletionFilterPtr cookie_deletion_filter,
const base::FilePath& path,
net::URLRequestContextGetter* rq_context,
DOMStorageContextWrapper* dom_storage_context,
storage::QuotaManager* quota_manager,
storage::SpecialStoragePolicy* special_storage_policy,
......@@ -747,11 +764,20 @@ base::FilePath StoragePartitionImpl::GetPath() {
}
net::URLRequestContextGetter* StoragePartitionImpl::GetURLRequestContext() {
// TODO(jam): enable for all, still used on WebView and Chromecast
#if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX)
if (base::FeatureList::IsEnabled(network::features::kNetworkService))
DCHECK(g_allow_get_url_request_context);
#endif
return url_request_context_.get();
}
net::URLRequestContextGetter*
StoragePartitionImpl::GetMediaURLRequestContext() {
#if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX)
if (base::FeatureList::IsEnabled(network::features::kNetworkService))
DCHECK(g_allow_get_url_request_context);
#endif
return media_url_request_context_.get();
}
......@@ -958,10 +984,9 @@ void StoragePartitionImpl::ClearDataImpl(
deletion_helpers_running_++;
helper->ClearDataOnUIThread(
storage_origin, origin_matcher, std::move(cookie_deletion_filter),
GetPath(), GetURLRequestContext(), dom_storage_context_.get(),
quota_manager_.get(), special_storage_policy_.get(),
filesystem_context_.get(), GetCookieManagerForBrowserProcess(),
perform_cleanup, begin, end);
GetPath(), dom_storage_context_.get(), quota_manager_.get(),
special_storage_policy_.get(), filesystem_context_.get(),
GetCookieManagerForBrowserProcess(), perform_cleanup, begin, end);
}
void StoragePartitionImpl::DeletionHelperDone(base::OnceClosure callback) {
......@@ -1112,7 +1137,6 @@ void StoragePartitionImpl::DataDeletionHelper::ClearDataOnUIThread(
const OriginMatcherFunction& origin_matcher,
CookieDeletionFilterPtr cookie_deletion_filter,
const base::FilePath& path,
net::URLRequestContextGetter* rq_context,
DOMStorageContextWrapper* dom_storage_context,
storage::QuotaManager* quota_manager,
storage::SpecialStoragePolicy* special_storage_policy,
......
......@@ -429,11 +429,15 @@ StoragePartitionImpl* StoragePartitionImplMap::Get(
partition->GetPath(), in_memory, &protocol_handlers,
std::move(request_interceptors)));
}
partition->SetMediaURLRequestContext(
partition_domain.empty() ?
browser_context_->CreateMediaRequestContext() :
browser_context_->CreateMediaRequestContextForStoragePartition(
partition->GetPath(), in_memory));
// A separate media cache isn't used with the network service.
if (!base::FeatureList::IsEnabled(network::features::kNetworkService)) {
partition->SetMediaURLRequestContext(
partition_domain.empty()
? browser_context_->CreateMediaRequestContext()
: browser_context_->CreateMediaRequestContextForStoragePartition(
partition->GetPath(), in_memory));
}
partition->GetCookieStoreContext()->ListenToCookieChanges(
partition->GetNetworkContext(), base::DoNothing());
......
......@@ -147,6 +147,7 @@
#include "ppapi/buildflags/buildflags.h"
#include "services/device/public/mojom/constants.mojom.h"
#include "services/metrics/public/cpp/ukm_recorder.h"
#include "services/network/public/cpp/features.h"
#include "services/service_manager/public/cpp/connector.h"
#include "services/service_manager/public/cpp/interface_provider.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
......@@ -4345,7 +4346,9 @@ void WebContentsImpl::OnDidLoadResourceFromMemoryCache(
for (auto& observer : observers_)
observer.DidLoadResourceFromMemoryCache(url, mime_type, resource_type);
if (url.is_valid() && url.SchemeIsHTTPOrHTTPS()) {
if (url.is_valid() && url.SchemeIsHTTPOrHTTPS() &&
// http://crbug.com/893323: get this working with network service.
!base::FeatureList::IsEnabled(network::features::kNetworkService)) {
StoragePartition* partition = source->GetProcess()->GetStoragePartition();
scoped_refptr<net::URLRequestContextGetter> request_context(
resource_type == RESOURCE_TYPE_MEDIA
......
......@@ -17,12 +17,25 @@
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "services/network/public/mojom/cookie_manager.mojom.h"
class ChromeURLRequestContextGetter;
class GURL;
namespace base {
class Time;
}
namespace cast {
class CastTransportHostFilter;
}
namespace extensions {
class MessagePropertyProvider;
}
namespace invalidation {
class DeprecatedProfileInvalidationProviderFactory;
}
namespace storage {
class FileSystemContext;
}
......@@ -65,6 +78,22 @@ class HostZoomMap;
class ZoomLevelDelegate;
#endif // !defined(OS_ANDROID)
// See comment below on GetURLRequestContext.
class CONTENT_EXPORT ScopedAllowGetURLRequestContext {
private:
// https://crbug.com/806817
friend class cast::CastTransportHostFilter;
// https://crbug.com/875032
friend class invalidation::DeprecatedProfileInvalidationProviderFactory;
// ChannelID is being removed now.
friend class extensions::MessagePropertyProvider;
// Uses URLRequestContextGetter to cast to a derived class.
friend class ::ChromeURLRequestContextGetter;
ScopedAllowGetURLRequestContext();
~ScopedAllowGetURLRequestContext();
DISALLOW_COPY_AND_ASSIGN(ScopedAllowGetURLRequestContext);
};
// Defines what persistent state a child process can access.
//
// The StoragePartition defines the view each child process has of the
......@@ -74,6 +103,10 @@ class ZoomLevelDelegate;
class CONTENT_EXPORT StoragePartition {
public:
virtual base::FilePath GetPath() = 0;
// http://crbug.com/837753 these methods shouldn't be called when the network
// service is enabled. There are a few remaining callers which have to
// instantiate a ScopedAllowGetURLRequestContext object while they make this
// call.
virtual net::URLRequestContextGetter* GetURLRequestContext() = 0;
virtual net::URLRequestContextGetter* GetMediaURLRequestContext() = 0;
......
......@@ -129,8 +129,7 @@ void WebTestContentBrowserClient::RenderProcessWillLaunch(
BrowserContext::GetDefaultStoragePartition(browser_context());
host->AddFilter(new WebTestMessageFilter(
host->GetID(), partition->GetDatabaseTracker(),
partition->GetQuotaManager(), partition->GetURLRequestContext(),
partition->GetNetworkContext()));
partition->GetQuotaManager(), partition->GetNetworkContext()));
}
void WebTestContentBrowserClient::ExposeInterfacesToRenderer(
......
......@@ -24,9 +24,6 @@
#include "content/shell/test_runner/web_test_delegate.h"
#include "content/test/mock_platform_notification_service.h"
#include "net/base/net_errors.h"
#include "net/cookies/cookie_store.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_getter.h"
#include "storage/browser/database/database_tracker.h"
#include "storage/browser/fileapi/isolated_context.h"
#include "storage/browser/quota/quota_manager.h"
......@@ -37,16 +34,13 @@ WebTestMessageFilter::WebTestMessageFilter(
int render_process_id,
storage::DatabaseTracker* database_tracker,
storage::QuotaManager* quota_manager,
net::URLRequestContextGetter* request_context_getter,
network::mojom::NetworkContext* network_context)
: BrowserMessageFilter(LayoutTestMsgStart),
render_process_id_(render_process_id),
database_tracker_(database_tracker),
quota_manager_(quota_manager),
request_context_getter_(request_context_getter) {
quota_manager_(quota_manager) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (network_context)
network_context->GetCookieManager(mojo::MakeRequest(&cookie_manager_));
network_context->GetCookieManager(mojo::MakeRequest(&cookie_manager_));
}
WebTestMessageFilter::~WebTestMessageFilter() {}
......@@ -68,7 +62,7 @@ base::TaskRunner* WebTestMessageFilter::OverrideTaskRunnerForMessage(
case LayoutTestHostMsg_TestFinishedInSecondaryRenderer::ID:
case LayoutTestHostMsg_InitiateCaptureDump::ID:
case LayoutTestHostMsg_InspectSecondaryWindow::ID:
case LayoutTestHostMsg_DeleteAllCookiesForNetworkService::ID:
case LayoutTestHostMsg_DeleteAllCookies::ID:
return base::CreateSingleThreadTaskRunnerWithTraits({BrowserThread::UI})
.get();
}
......@@ -89,8 +83,6 @@ bool WebTestMessageFilter::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(LayoutTestHostMsg_SimulateWebNotificationClose,
OnSimulateWebNotificationClose)
IPC_MESSAGE_HANDLER(LayoutTestHostMsg_DeleteAllCookies, OnDeleteAllCookies)
IPC_MESSAGE_HANDLER(LayoutTestHostMsg_DeleteAllCookiesForNetworkService,
OnDeleteAllCookiesForNetworkService)
IPC_MESSAGE_HANDLER(LayoutTestHostMsg_SetPermission, OnSetPermission)
IPC_MESSAGE_HANDLER(LayoutTestHostMsg_ResetPermissions, OnResetPermissions)
IPC_MESSAGE_HANDLER(LayoutTestHostMsg_LayoutTestRuntimeFlagsChanged,
......@@ -172,19 +164,9 @@ void WebTestMessageFilter::OnSimulateWebNotificationClose(
}
void WebTestMessageFilter::OnDeleteAllCookies() {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
net::URLRequestContext* context =
request_context_getter_->GetURLRequestContext();
if (context)
context->cookie_store()->DeleteAllAsync(net::CookieStore::DeleteCallback());
}
void WebTestMessageFilter::OnDeleteAllCookiesForNetworkService() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (cookie_manager_) {
cookie_manager_->DeleteCookies(network::mojom::CookieDeletionFilter::New(),
base::BindOnce([](uint32_t) {}));
}
cookie_manager_->DeleteCookies(network::mojom::CookieDeletionFilter::New(),
base::BindOnce([](uint32_t) {}));
}
void WebTestMessageFilter::OnSetPermission(
......
......@@ -23,10 +23,6 @@ namespace base {
class DictionaryValue;
}
namespace net {
class URLRequestContextGetter;
}
namespace network {
namespace mojom {
class NetworkContext;
......@@ -48,7 +44,6 @@ class WebTestMessageFilter : public BrowserMessageFilter {
WebTestMessageFilter(int render_process_id,
storage::DatabaseTracker* database_tracker,
storage::QuotaManager* quota_manager,
net::URLRequestContextGetter* request_context_getter,
network::mojom::NetworkContext* network_context);
private:
......@@ -77,7 +72,6 @@ class WebTestMessageFilter : public BrowserMessageFilter {
const base::Optional<base::string16>& reply);
void OnSimulateWebNotificationClose(const std::string& title, bool by_user);
void OnDeleteAllCookies();
void OnDeleteAllCookiesForNetworkService();
void OnSetPermission(const std::string& name,
blink::mojom::PermissionStatus status,
const GURL& origin,
......@@ -94,7 +88,6 @@ class WebTestMessageFilter : public BrowserMessageFilter {
scoped_refptr<storage::DatabaseTracker> database_tracker_;
scoped_refptr<storage::QuotaManager> quota_manager_;
scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
network::mojom::CookieManagerPtr cookie_manager_;
DISALLOW_COPY_AND_ASSIGN(WebTestMessageFilter);
......
......@@ -38,7 +38,6 @@ IPC_MESSAGE_ROUTED2(LayoutTestHostMsg_SimulateWebNotificationClose,
IPC_MESSAGE_ROUTED1(LayoutTestHostMsg_BlockThirdPartyCookies,
bool /* block */)
IPC_MESSAGE_ROUTED0(LayoutTestHostMsg_DeleteAllCookies)
IPC_MESSAGE_ROUTED0(LayoutTestHostMsg_DeleteAllCookiesForNetworkService)
IPC_MESSAGE_ROUTED4(LayoutTestHostMsg_SetPermission,
std::string /* name */,
blink::mojom::PermissionStatus /* status */,
......
......@@ -586,7 +586,6 @@ void BlinkTestRunner::CloseRemainingWindows() {
void BlinkTestRunner::DeleteAllCookies() {
Send(new LayoutTestHostMsg_DeleteAllCookies(routing_id()));
Send(new LayoutTestHostMsg_DeleteAllCookiesForNetworkService(routing_id()));
}
int BlinkTestRunner::NavigationEntryCount() {
......
......@@ -40,6 +40,7 @@ void MessagePropertyProvider::GetChannelID(
return;
}
content::ScopedAllowGetURLRequestContext scoped_allow_get_url_request_context;
scoped_refptr<net::URLRequestContextGetter> request_context_getter =
storage_partition->GetURLRequestContext();
base::PostTaskWithTraits(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment