Commit a7a6fec8 authored by Justin Donnelly's avatar Justin Donnelly Committed by Commit Bot

Test ChromeAutocompleteProviderClient::StartServiceWorker.

Introduces two new test classes in content/public/test. Also, moves the
incognito check from the call site to the method itself,for both
testability and safety.

Bug: 748068
Change-Id: I3b9b883a47e35ee229f811bb524b3f1a4621b22d
Reviewed-on: https://chromium-review.googlesource.com/585295
Commit-Queue: Justin Donnelly <jdonnelly@chromium.org>
Reviewed-by: default avatarMark Pearson <mpearson@chromium.org>
Reviewed-by: default avatarBernhard Bauer <bauerb@chromium.org>
Reviewed-by: default avatarPaweł Hajdan Jr. <phajdan.jr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#490994}
parent e069cdfa
...@@ -293,8 +293,12 @@ void ChromeAutocompleteProviderClient::PrefetchImage(const GURL& url) { ...@@ -293,8 +293,12 @@ void ChromeAutocompleteProviderClient::PrefetchImage(const GURL& url) {
void ChromeAutocompleteProviderClient::StartServiceWorker( void ChromeAutocompleteProviderClient::StartServiceWorker(
const GURL& destination_url) { const GURL& destination_url) {
content::StoragePartition* partition = if (profile_->IsOffTheRecord())
content::BrowserContext::GetDefaultStoragePartition(profile_); return;
content::StoragePartition* partition = storage_partition_;
if (!partition)
partition = content::BrowserContext::GetDefaultStoragePartition(profile_);
if (!partition) if (!partition)
return; return;
......
...@@ -12,6 +12,10 @@ ...@@ -12,6 +12,10 @@
class Profile; class Profile;
namespace content {
class StoragePartition;
}
class ChromeAutocompleteProviderClient : public AutocompleteProviderClient { class ChromeAutocompleteProviderClient : public AutocompleteProviderClient {
public: public:
explicit ChromeAutocompleteProviderClient(Profile* profile); explicit ChromeAutocompleteProviderClient(Profile* profile);
...@@ -57,11 +61,19 @@ class ChromeAutocompleteProviderClient : public AutocompleteProviderClient { ...@@ -57,11 +61,19 @@ class ChromeAutocompleteProviderClient : public AutocompleteProviderClient {
void OnAutocompleteControllerResultReady( void OnAutocompleteControllerResultReady(
AutocompleteController* controller) override; AutocompleteController* controller) override;
// For testing.
void set_storage_partition(content::StoragePartition* storage_partition) {
storage_partition_ = storage_partition;
}
private: private:
Profile* profile_; Profile* profile_;
ChromeAutocompleteSchemeClassifier scheme_classifier_; ChromeAutocompleteSchemeClassifier scheme_classifier_;
UIThreadSearchTermsData search_terms_data_; UIThreadSearchTermsData search_terms_data_;
// Injectable storage partitiion, used for testing.
content::StoragePartition* storage_partition_;
DISALLOW_COPY_AND_ASSIGN(ChromeAutocompleteProviderClient); DISALLOW_COPY_AND_ASSIGN(ChromeAutocompleteProviderClient);
}; };
......
// Copyright 2017 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/autocomplete/chrome_autocomplete_provider_client.h"
#include "base/memory/ptr_util.h"
#include "chrome/test/base/testing_profile.h"
#include "content/public/test/mock_service_worker_context.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "content/public/test/test_storage_partition.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
using ::testing::_;
class ChromeAutocompleteProviderClientTest : public testing::Test {
public:
void SetUp() override {
client_ = base::MakeUnique<ChromeAutocompleteProviderClient>(&profile_);
storage_partition_.set_service_worker_context(&service_worker_context_);
client_->set_storage_partition(&storage_partition_);
}
// Replaces the client with one using an incognito profile. Note that this is
// a one-way operation. Once a TEST_F calls this, all interactions with
// |client_| will be off the record.
void GoOffTheRecord() {
client_ = base::MakeUnique<ChromeAutocompleteProviderClient>(
profile_.GetOffTheRecordProfile());
}
protected:
content::TestBrowserThreadBundle test_browser_thread_bundle_;
std::unique_ptr<ChromeAutocompleteProviderClient> client_;
content::MockServiceWorkerContext service_worker_context_;
private:
TestingProfile profile_;
content::TestStoragePartition storage_partition_;
};
TEST_F(ChromeAutocompleteProviderClientTest, StartServiceWorker) {
GURL destination_url("https://google.com/search?q=puppies");
EXPECT_CALL(service_worker_context_,
StartServiceWorkerForNavigationHint(destination_url, _))
.Times(1);
client_->StartServiceWorker(destination_url);
}
TEST_F(ChromeAutocompleteProviderClientTest,
DontStartServiceWorkerInIncognito) {
GURL destination_url("https://google.com/search?q=puppies");
GoOffTheRecord();
EXPECT_CALL(service_worker_context_,
StartServiceWorkerForNavigationHint(destination_url, _))
.Times(0);
client_->StartServiceWorker(destination_url);
}
...@@ -3024,6 +3024,7 @@ test("unit_tests") { ...@@ -3024,6 +3024,7 @@ test("unit_tests") {
"../browser/android/webapk/webapk_web_manifest_checker_unittest.cc", "../browser/android/webapk/webapk_web_manifest_checker_unittest.cc",
"../browser/android/webapps/add_to_homescreen_data_fetcher_unittest.cc", "../browser/android/webapps/add_to_homescreen_data_fetcher_unittest.cc",
"../browser/app_controller_mac_unittest.mm", "../browser/app_controller_mac_unittest.mm",
"../browser/autocomplete/chrome_autocomplete_provider_client_unittest.cc",
"../browser/autocomplete/search_provider_unittest.cc", "../browser/autocomplete/search_provider_unittest.cc",
"../browser/autocomplete/shortcuts_provider_extension_unittest.cc", "../browser/autocomplete/shortcuts_provider_extension_unittest.cc",
"../browser/background_sync/background_sync_controller_impl_unittest.cc", "../browser/background_sync/background_sync_controller_impl_unittest.cc",
......
...@@ -343,17 +343,16 @@ void AutocompleteController::Start(const AutocompleteInput& input) { ...@@ -343,17 +343,16 @@ void AutocompleteController::Start(const AutocompleteInput& input) {
// need the edit model to update the display. // need the edit model to update the display.
UpdateResult(false, true); UpdateResult(false, true);
// If the input looks like a query and we're not in incognito mode, send a // If the input looks like a query, send a signal predicting that the user is
// signal predicting that the user is going to issue a search (either to the // going to issue a search (either to the default search engine or to a
// default search engine or to a keyword search engine, as indicated by the // keyword search engine, as indicated by the destination_url). This allows
// destination_url). This allows any associated service worker to start up // any associated service worker to start up early and reduce the latency of a
// early and reduce the latency of a resulting search. However, to avoid a // resulting search. However, to avoid a potentially expensive operation, we
// potentially expensive operation, we only do this once per session. // only do this once per session. Additionally, a default match is expected to
// Additionally, a default match is expected to be available at this point but // be available at this point but we check anyway to guard against an invalid
// we check anyway to guard against an invalid dereference. // dereference.
if (base::FeatureList::IsEnabled( if (base::FeatureList::IsEnabled(
omnibox::kSpeculativeServiceWorkerStartOnQueryInput) && omnibox::kSpeculativeServiceWorkerStartOnQueryInput) &&
!provider_client_->IsOffTheRecord() &&
(input.type() == metrics::OmniboxInputType::QUERY) && (input.type() == metrics::OmniboxInputType::QUERY) &&
!search_service_worker_signal_sent_ && !search_service_worker_signal_sent_ &&
(result_.default_match() != result_.end())) { (result_.default_match() != result_.end())) {
......
...@@ -111,9 +111,9 @@ class AutocompleteProviderClient { ...@@ -111,9 +111,9 @@ class AutocompleteProviderClient {
virtual void PrefetchImage(const GURL& url) = 0; virtual void PrefetchImage(const GURL& url) = 0;
// Sends a hint to the service worker context that navigation to // Sends a hint to the service worker context that navigation to
// |desination_url| is likely. On platforms where this is supported, the // |desination_url| is likely, unless the current profile is in incognito
// service worker lookup can be expensive so this method should only be // mode. On platforms where this is supported, the service worker lookup can
// called once per input session. // be expensive so this method should only be called once per input session.
virtual void StartServiceWorker(const GURL& destination_url) {} virtual void StartServiceWorker(const GURL& destination_url) {}
// Called by |controller| when its results have changed and all providers are // Called by |controller| when its results have changed and all providers are
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include "base/task/cancelable_task_tracker.h" #include "base/task/cancelable_task_tracker.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "build/build_config.h"
#include "content/browser/browsing_data/browsing_data_remover_impl.h" #include "content/browser/browsing_data/browsing_data_remover_impl.h"
#include "content/public/browser/browser_context.h" #include "content/public/browser/browser_context.h"
#include "content/public/browser/browsing_data_filter_builder.h" #include "content/public/browser/browsing_data_filter_builder.h"
...@@ -41,6 +40,7 @@ ...@@ -41,6 +40,7 @@
#include "content/public/test/test_browser_context.h" #include "content/public/test/test_browser_context.h"
#include "content/public/test/test_browser_thread.h" #include "content/public/test/test_browser_thread.h"
#include "content/public/test/test_browser_thread_bundle.h" #include "content/public/test/test_browser_thread_bundle.h"
#include "content/public/test/test_storage_partition.h"
#include "content/public/test/test_utils.h" #include "content/public/test/test_utils.h"
#include "net/cookies/cookie_store.h" #include "net/cookies/cookie_store.h"
#include "net/http/http_network_session.h" #include "net/http/http_network_session.h"
...@@ -126,38 +126,11 @@ net::CanonicalCookie CreateCookieWithHost(const GURL& source) { ...@@ -126,38 +126,11 @@ net::CanonicalCookie CreateCookieWithHost(const GURL& source) {
return *cookie; return *cookie;
} }
class TestStoragePartition : public StoragePartition { class StoragePartitionRemovalTestStoragePartition
: public TestStoragePartition {
public: public:
TestStoragePartition() {} StoragePartitionRemovalTestStoragePartition() {}
~TestStoragePartition() override {} ~StoragePartitionRemovalTestStoragePartition() override {}
// StoragePartition implementation.
base::FilePath GetPath() override { return base::FilePath(); }
net::URLRequestContextGetter* GetURLRequestContext() override {
return nullptr;
}
net::URLRequestContextGetter* GetMediaURLRequestContext() override {
return nullptr;
}
mojom::NetworkContext* GetNetworkContext() override { return nullptr; }
storage::QuotaManager* GetQuotaManager() override { return nullptr; }
AppCacheService* GetAppCacheService() override { return nullptr; }
storage::FileSystemContext* GetFileSystemContext() override {
return nullptr;
}
storage::DatabaseTracker* GetDatabaseTracker() override { return nullptr; }
DOMStorageContext* GetDOMStorageContext() override { return nullptr; }
IndexedDBContext* GetIndexedDBContext() override { return nullptr; }
ServiceWorkerContext* GetServiceWorkerContext() override { return nullptr; }
CacheStorageContext* GetCacheStorageContext() override { return nullptr; }
PlatformNotificationContext* GetPlatformNotificationContext() override {
return nullptr;
}
#if !defined(OS_ANDROID)
HostZoomMap* GetHostZoomMap() override { return nullptr; }
HostZoomLevelContext* GetHostZoomLevelContext() override { return nullptr; }
ZoomLevelDelegate* GetZoomLevelDelegate() override { return nullptr; }
#endif // !defined(OS_ANDROID)
void ClearDataForOrigin(uint32_t remove_mask, void ClearDataForOrigin(uint32_t remove_mask,
uint32_t quota_storage_remove_mask, uint32_t quota_storage_remove_mask,
...@@ -166,8 +139,9 @@ class TestStoragePartition : public StoragePartition { ...@@ -166,8 +139,9 @@ class TestStoragePartition : public StoragePartition {
const base::Closure& callback) override { const base::Closure& callback) override {
BrowserThread::PostTask( BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE, BrowserThread::UI, FROM_HERE,
base::BindOnce(&TestStoragePartition::AsyncRunCallback, base::BindOnce(
base::Unretained(this), callback)); &StoragePartitionRemovalTestStoragePartition::AsyncRunCallback,
base::Unretained(this), callback));
} }
void ClearData(uint32_t remove_mask, void ClearData(uint32_t remove_mask,
...@@ -187,8 +161,9 @@ class TestStoragePartition : public StoragePartition { ...@@ -187,8 +161,9 @@ class TestStoragePartition : public StoragePartition {
BrowserThread::PostTask( BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE, BrowserThread::UI, FROM_HERE,
base::BindOnce(&TestStoragePartition::AsyncRunCallback, base::BindOnce(
base::Unretained(this), callback)); &StoragePartitionRemovalTestStoragePartition::AsyncRunCallback,
base::Unretained(this), callback));
} }
void ClearData(uint32_t remove_mask, void ClearData(uint32_t remove_mask,
...@@ -209,22 +184,11 @@ class TestStoragePartition : public StoragePartition { ...@@ -209,22 +184,11 @@ class TestStoragePartition : public StoragePartition {
BrowserThread::PostTask( BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE, BrowserThread::UI, FROM_HERE,
base::BindOnce(&TestStoragePartition::AsyncRunCallback, base::BindOnce(
base::Unretained(this), callback)); &StoragePartitionRemovalTestStoragePartition::AsyncRunCallback,
base::Unretained(this), callback));
} }
void ClearHttpAndMediaCaches(
const base::Time begin,
const base::Time end,
const base::Callback<bool(const GURL&)>& url_matcher,
const base::Closure& callback) override {
// Not needed in this test.
}
void Flush() override {}
void ClearBluetoothAllowedDevicesMapForTesting() override {}
StoragePartitionRemovalData GetStoragePartitionRemovalData() { StoragePartitionRemovalData GetStoragePartitionRemovalData() {
return storage_partition_removal_data_; return storage_partition_removal_data_;
} }
...@@ -234,7 +198,7 @@ class TestStoragePartition : public StoragePartition { ...@@ -234,7 +198,7 @@ class TestStoragePartition : public StoragePartition {
StoragePartitionRemovalData storage_partition_removal_data_; StoragePartitionRemovalData storage_partition_removal_data_;
DISALLOW_COPY_AND_ASSIGN(TestStoragePartition); DISALLOW_COPY_AND_ASSIGN(StoragePartitionRemovalTestStoragePartition);
}; };
// Custom matcher to test the equivalence of two URL filters. Since those are // Custom matcher to test the equivalence of two URL filters. Since those are
...@@ -540,7 +504,7 @@ class BrowsingDataRemoverImplTest : public testing::Test { ...@@ -540,7 +504,7 @@ class BrowsingDataRemoverImplTest : public testing::Test {
const base::Time& delete_end, const base::Time& delete_end,
int remove_mask, int remove_mask,
bool include_protected_origins) { bool include_protected_origins) {
TestStoragePartition storage_partition; StoragePartitionRemovalTestStoragePartition storage_partition;
remover_->OverrideStoragePartitionForTesting(&storage_partition); remover_->OverrideStoragePartitionForTesting(&storage_partition);
int origin_type_mask = BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB; int origin_type_mask = BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB;
...@@ -562,7 +526,7 @@ class BrowsingDataRemoverImplTest : public testing::Test { ...@@ -562,7 +526,7 @@ class BrowsingDataRemoverImplTest : public testing::Test {
const base::Time& delete_end, const base::Time& delete_end,
int remove_mask, int remove_mask,
std::unique_ptr<BrowsingDataFilterBuilder> filter_builder) { std::unique_ptr<BrowsingDataFilterBuilder> filter_builder) {
TestStoragePartition storage_partition; StoragePartitionRemovalTestStoragePartition storage_partition;
remover_->OverrideStoragePartitionForTesting(&storage_partition); remover_->OverrideStoragePartitionForTesting(&storage_partition);
BrowsingDataRemoverCompletionObserver completion_observer(remover_); BrowsingDataRemoverCompletionObserver completion_observer(remover_);
......
// Copyright 2017 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 "content/public/test/mock_service_worker_context.h"
#include "base/callback.h"
#include "base/logging.h"
namespace content {
MockServiceWorkerContext::MockServiceWorkerContext() {}
MockServiceWorkerContext::~MockServiceWorkerContext() {}
void MockServiceWorkerContext::StartActiveWorkerForPattern(
const GURL& pattern,
ServiceWorkerContext::StartActiveWorkerCallback info_callback,
base::OnceClosure failure_callback) {
NOTREACHED() << "No mock for StartActiveWorkerForPattern";
}
} // namespace content
// Copyright 2017 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 CONTENT_PUBLIC_TEST_MOCK_SERVICE_WORKER_CONTEXT_H_
#define CONTENT_PUBLIC_TEST_MOCK_SERVICE_WORKER_CONTEXT_H_
#include "base/callback_forward.h"
#include "content/public/browser/service_worker_context.h"
#include "testing/gmock/include/gmock/gmock.h"
class GURL;
namespace content {
class ServiceWorkerContextObserver;
// Mock implementation of ServiceWorkerContext.
class MockServiceWorkerContext : public ServiceWorkerContext {
public:
MockServiceWorkerContext();
virtual ~MockServiceWorkerContext();
MOCK_METHOD1(AddObserver, void(ServiceWorkerContextObserver*));
MOCK_METHOD1(RemoveObserver, void(ServiceWorkerContextObserver*));
MOCK_METHOD3(RegisterServiceWorker,
void(const ServiceWorkerContext::Scope&,
const GURL&,
const ServiceWorkerContext::ResultCallback&));
MOCK_METHOD2(StartingExternalRequest, bool(int64_t, const std::string&));
MOCK_METHOD2(FinishedExternalRequest, bool(int64_t, const std::string&));
// StartActiveWorkerForPattern cannot be mocked because OnceClosure is not
// copyable.
void StartActiveWorkerForPattern(
const GURL& pattern,
ServiceWorkerContext::StartActiveWorkerCallback info_callback,
base::OnceClosure failure_callback) override;
MOCK_METHOD2(UnregisterServiceWorker,
void(const ServiceWorkerContext::Scope&,
const ServiceWorkerContext::ResultCallback&));
MOCK_METHOD1(GetAllOriginsInfo,
void(const ServiceWorkerContext::GetUsageInfoCallback&));
MOCK_METHOD2(DeleteForOrigin,
void(const GURL&, const ServiceWorkerContext::ResultCallback&));
MOCK_METHOD3(
CheckHasServiceWorker,
void(const GURL&,
const GURL&,
const ServiceWorkerContext::CheckHasServiceWorkerCallback&));
MOCK_METHOD2(
CountExternalRequestsForTest,
void(const GURL&,
const ServiceWorkerContext::CountExternalRequestsCallback&));
MOCK_METHOD1(StopAllServiceWorkersForOrigin, void(const GURL&));
MOCK_METHOD1(ClearAllServiceWorkersForTest, void(const base::Closure&));
MOCK_METHOD2(StartServiceWorkerForNavigationHint,
void(const GURL&,
const StartServiceWorkerForNavigationHintCallback&));
private:
DISALLOW_COPY_AND_ASSIGN(MockServiceWorkerContext);
};
} // namespace content
#endif // CONTENT_PUBLIC_TEST_MOCK_SERVICE_WORKER_CONTEXT_H_
// Copyright 2017 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 "content/public/test/test_storage_partition.h"
namespace content {
TestStoragePartition::TestStoragePartition() {}
TestStoragePartition::~TestStoragePartition() {}
base::FilePath TestStoragePartition::GetPath() {
return file_path_;
}
net::URLRequestContextGetter* TestStoragePartition::GetURLRequestContext() {
return url_request_context_getter_;
}
net::URLRequestContextGetter*
TestStoragePartition::GetMediaURLRequestContext() {
return media_url_request_context_getter_;
}
mojom::NetworkContext* TestStoragePartition::GetNetworkContext() {
return network_context_;
}
storage::QuotaManager* TestStoragePartition::GetQuotaManager() {
return quota_manager_;
}
AppCacheService* TestStoragePartition::GetAppCacheService() {
return app_cache_service_;
}
storage::FileSystemContext* TestStoragePartition::GetFileSystemContext() {
return file_system_context_;
}
storage::DatabaseTracker* TestStoragePartition::GetDatabaseTracker() {
return database_tracker_;
}
DOMStorageContext* TestStoragePartition::GetDOMStorageContext() {
return dom_storage_context_;
}
IndexedDBContext* TestStoragePartition::GetIndexedDBContext() {
return indexed_db_context_;
}
ServiceWorkerContext* TestStoragePartition::GetServiceWorkerContext() {
return service_worker_context_;
}
CacheStorageContext* TestStoragePartition::GetCacheStorageContext() {
return cache_storage_context_;
}
PlatformNotificationContext*
TestStoragePartition::GetPlatformNotificationContext() {
return nullptr;
}
#if !defined(OS_ANDROID)
HostZoomMap* TestStoragePartition::GetHostZoomMap() {
return host_zoom_map_;
}
HostZoomLevelContext* TestStoragePartition::GetHostZoomLevelContext() {
return host_zoom_level_context_;
}
ZoomLevelDelegate* TestStoragePartition::GetZoomLevelDelegate() {
return zoom_level_delegate_;
}
#endif // !defined(OS_ANDROID)
void TestStoragePartition::ClearDataForOrigin(
uint32_t remove_mask,
uint32_t quota_storage_remove_mask,
const GURL& storage_origin,
net::URLRequestContextGetter* rq_context,
const base::Closure& callback) {}
void TestStoragePartition::ClearData(
uint32_t remove_mask,
uint32_t quota_storage_remove_mask,
const GURL& storage_origin,
const OriginMatcherFunction& origin_matcher,
const base::Time begin,
const base::Time end,
const base::Closure& callback) {}
void TestStoragePartition::ClearData(
uint32_t remove_mask,
uint32_t quota_storage_remove_mask,
const OriginMatcherFunction& origin_matcher,
const CookieMatcherFunction& cookie_matcher,
const base::Time begin,
const base::Time end,
const base::Closure& callback) {}
void TestStoragePartition::ClearHttpAndMediaCaches(
const base::Time begin,
const base::Time end,
const base::Callback<bool(const GURL&)>& url_matcher,
const base::Closure& callback) {}
void TestStoragePartition::Flush() {}
void TestStoragePartition::ClearBluetoothAllowedDevicesMapForTesting() {}
} // namespace content
// Copyright 2017 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 CONTENT_PUBLIC_TEST_TEST_STORAGE_PARTITION_H_
#define CONTENT_PUBLIC_TEST_TEST_STORAGE_PARTITION_H_
#include "base/callback_forward.h"
#include "base/files/file_path.h"
#include "build/build_config.h"
#include "content/public/browser/storage_partition.h"
namespace net {
class URLRequestContextGetter;
}
namespace content {
class AppCacheService;
class DOMStorageContext;
class IndexedDBContext;
class PlatformNotificationContext;
class ServiceWorkerContext;
#if !defined(OS_ANDROID)
class HostZoomLevelContext;
class HostZoomMap;
class ZoomLevelDelegate;
#endif // !defined(OS_ANDROID)
namespace mojom {
class NetworkContext;
}
// Fake implementation of StoragePartition.
class TestStoragePartition : public StoragePartition {
public:
TestStoragePartition();
~TestStoragePartition() override;
void set_path(base::FilePath file_path) { file_path_ = file_path; }
base::FilePath GetPath() override;
void set_url_request_context(net::URLRequestContextGetter* getter) {
url_request_context_getter_ = getter;
}
net::URLRequestContextGetter* GetURLRequestContext() override;
void set_media_url_request_context(net::URLRequestContextGetter* getter) {
media_url_request_context_getter_ = getter;
}
net::URLRequestContextGetter* GetMediaURLRequestContext() override;
void set_network_context(mojom::NetworkContext* context) {
network_context_ = context;
}
mojom::NetworkContext* GetNetworkContext() override;
void set_quota_manager(storage::QuotaManager* manager) {
quota_manager_ = manager;
}
storage::QuotaManager* GetQuotaManager() override;
void set_app_cache_service(AppCacheService* service) {
app_cache_service_ = service;
}
AppCacheService* GetAppCacheService() override;
void set_file_system_context(storage::FileSystemContext* context) {
file_system_context_ = context;
}
storage::FileSystemContext* GetFileSystemContext() override;
void set_database_tracker(storage::DatabaseTracker* tracker) {
database_tracker_ = tracker;
}
storage::DatabaseTracker* GetDatabaseTracker() override;
void set_dom_storage_context(DOMStorageContext* context) {
dom_storage_context_ = context;
}
DOMStorageContext* GetDOMStorageContext() override;
void set_indexed_db_context(IndexedDBContext* context) {
indexed_db_context_ = context;
}
IndexedDBContext* GetIndexedDBContext() override;
void set_service_worker_context(ServiceWorkerContext* context) {
service_worker_context_ = context;
}
ServiceWorkerContext* GetServiceWorkerContext() override;
void set_cache_storage_context(CacheStorageContext* context) {
cache_storage_context_ = context;
}
CacheStorageContext* GetCacheStorageContext() override;
void set_platform_notification_context(PlatformNotificationContext* context) {
platform_notification_context_ = context;
}
PlatformNotificationContext* GetPlatformNotificationContext() override;
#if !defined(OS_ANDROID)
void set_host_zoom_map(HostZoomMap* map) { host_zoom_map_ = map; }
HostZoomMap* GetHostZoomMap() override;
void set_host_zoom_level_context(HostZoomLevelContext* context) {
host_zoom_level_context_ = context;
}
HostZoomLevelContext* GetHostZoomLevelContext() override;
void set_zoom_level_delegate(ZoomLevelDelegate* delegate) {
zoom_level_delegate_ = delegate;
}
ZoomLevelDelegate* GetZoomLevelDelegate() override;
#endif // !defined(OS_ANDROID)
void ClearDataForOrigin(uint32_t remove_mask,
uint32_t quota_storage_remove_mask,
const GURL& storage_origin,
net::URLRequestContextGetter* rq_context,
const base::Closure& callback) override;
void ClearData(uint32_t remove_mask,
uint32_t quota_storage_remove_mask,
const GURL& storage_origin,
const OriginMatcherFunction& origin_matcher,
const base::Time begin,
const base::Time end,
const base::Closure& callback) override;
void ClearData(uint32_t remove_mask,
uint32_t quota_storage_remove_mask,
const OriginMatcherFunction& origin_matcher,
const CookieMatcherFunction& cookie_matcher,
const base::Time begin,
const base::Time end,
const base::Closure& callback) override;
void ClearHttpAndMediaCaches(
const base::Time begin,
const base::Time end,
const base::Callback<bool(const GURL&)>& url_matcher,
const base::Closure& callback) override;
void Flush() override;
void ClearBluetoothAllowedDevicesMapForTesting() override;
private:
base::FilePath file_path_;
net::URLRequestContextGetter* url_request_context_getter_;
net::URLRequestContextGetter* media_url_request_context_getter_;
mojom::NetworkContext* network_context_;
storage::QuotaManager* quota_manager_;
AppCacheService* app_cache_service_;
storage::FileSystemContext* file_system_context_;
storage::DatabaseTracker* database_tracker_;
DOMStorageContext* dom_storage_context_;
IndexedDBContext* indexed_db_context_;
ServiceWorkerContext* service_worker_context_;
CacheStorageContext* cache_storage_context_;
PlatformNotificationContext* platform_notification_context_;
#if !defined(OS_ANDROID)
HostZoomMap* host_zoom_map_;
HostZoomLevelContext* host_zoom_level_context_;
ZoomLevelDelegate* zoom_level_delegate_;
#endif // !defined(OS_ANDROID)
DISALLOW_COPY_AND_ASSIGN(TestStoragePartition);
};
} // namespace content
#endif // CONTENT_PUBLIC_TEST_TEST_STORAGE_PARTITION_H_
...@@ -90,6 +90,8 @@ static_library("test_support") { ...@@ -90,6 +90,8 @@ static_library("test_support") {
"../public/test/mock_render_thread.h", "../public/test/mock_render_thread.h",
"../public/test/mock_resource_context.cc", "../public/test/mock_resource_context.cc",
"../public/test/mock_resource_context.h", "../public/test/mock_resource_context.h",
"../public/test/mock_service_worker_context.cc",
"../public/test/mock_service_worker_context.h",
"../public/test/navigation_handle_observer.cc", "../public/test/navigation_handle_observer.cc",
"../public/test/navigation_handle_observer.h", "../public/test/navigation_handle_observer.h",
"../public/test/navigation_simulator.cc", "../public/test/navigation_simulator.cc",
...@@ -130,6 +132,8 @@ static_library("test_support") { ...@@ -130,6 +132,8 @@ static_library("test_support") {
"../public/test/test_service.h", "../public/test/test_service.h",
"../public/test/test_service_manager_context.cc", "../public/test/test_service_manager_context.cc",
"../public/test/test_service_manager_context.h", "../public/test/test_service_manager_context.h",
"../public/test/test_storage_partition.cc",
"../public/test/test_storage_partition.h",
"../public/test/test_synchronous_compositor_android.cc", "../public/test/test_synchronous_compositor_android.cc",
"../public/test/test_synchronous_compositor_android.h", "../public/test/test_synchronous_compositor_android.h",
"../public/test/test_url_loader_client.cc", "../public/test/test_url_loader_client.cc",
......
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