summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpilgrim@chromium.org <pilgrim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-05 14:21:26 +0000
committerpilgrim@chromium.org <pilgrim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-05 14:21:26 +0000
commit63ef85512d239bd56a557a6788a887e0dd36592d (patch)
tree4e2a161fc52e4694675579bd6a183c3419d00634
parentacc30488ef4d359b5e323029f3ddba0014adbb20 (diff)
downloadchromium_src-63ef85512d239bd56a557a6788a887e0dd36592d.zip
chromium_src-63ef85512d239bd56a557a6788a887e0dd36592d.tar.gz
chromium_src-63ef85512d239bd56a557a6788a887e0dd36592d.tar.bz2
Split AppCacheService into appcache_service.h and appcache_service_impl.h
One will (eventually) go into content/public/browser/ and the other will go in content/browser/appcache/ BUG=338338 TBR=darin@chromium.org Review URL: https://codereview.chromium.org/315733004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@275093 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/browser/appcache/appcache_group_unittest.cc4
-rw-r--r--content/browser/appcache/appcache_interceptor.cc6
-rw-r--r--content/browser/appcache/appcache_interceptor.h4
-rw-r--r--content/browser/appcache/appcache_quota_client_unittest.cc2
-rw-r--r--content/browser/appcache/appcache_service_unittest.cc22
-rw-r--r--content/browser/appcache/appcache_storage_impl_unittest.cc14
-rw-r--r--content/browser/appcache/chrome_appcache_service.cc2
-rw-r--r--content/browser/appcache/chrome_appcache_service.h10
-rw-r--r--content/browser/appcache/chrome_appcache_service_unittest.cc12
-rw-r--r--content/browser/appcache/mock_appcache_service.h8
-rw-r--r--content/browser/appcache/mock_appcache_storage.cc6
-rw-r--r--content/browser/appcache/mock_appcache_storage.h12
-rw-r--r--content/browser/appcache/view_appcache_internals_job.cc26
-rw-r--r--content/browser/appcache/view_appcache_internals_job.h4
-rw-r--r--content/browser/browser_context.cc5
-rw-r--r--content/browser/storage_partition_impl_map.cc2
-rw-r--r--content/browser/webui/url_data_manager_backend.cc8
-rw-r--r--content/browser/webui/url_data_manager_backend.h4
-rw-r--r--content/test/appcache_test_helper.cc6
-rw-r--r--content/test/appcache_test_helper.h6
-rw-r--r--webkit/browser/BUILD.gn3
-rw-r--r--webkit/browser/appcache/appcache_backend_impl.cc4
-rw-r--r--webkit/browser/appcache/appcache_backend_impl.h6
-rw-r--r--webkit/browser/appcache/appcache_group.cc2
-rw-r--r--webkit/browser/appcache/appcache_host.cc2
-rw-r--r--webkit/browser/appcache/appcache_host.h12
-rw-r--r--webkit/browser/appcache/appcache_quota_client.cc4
-rw-r--r--webkit/browser/appcache/appcache_quota_client.h8
-rw-r--r--webkit/browser/appcache/appcache_service.h201
-rw-r--r--webkit/browser/appcache/appcache_service_impl.cc (renamed from webkit/browser/appcache/appcache_service.cc)86
-rw-r--r--webkit/browser/appcache/appcache_service_impl.h227
-rw-r--r--webkit/browser/appcache/appcache_storage.cc4
-rw-r--r--webkit/browser/appcache/appcache_storage.h8
-rw-r--r--webkit/browser/appcache/appcache_storage_impl.cc4
-rw-r--r--webkit/browser/appcache/appcache_storage_impl.h2
-rw-r--r--webkit/browser/appcache/appcache_update_job.cc4
-rw-r--r--webkit/browser/appcache/appcache_update_job.h10
-rw-r--r--webkit/browser/appcache/appcache_url_request_job.cc2
-rw-r--r--webkit/storage_browser.gyp3
39 files changed, 403 insertions, 352 deletions
diff --git a/content/browser/appcache/appcache_group_unittest.cc b/content/browser/appcache/appcache_group_unittest.cc
index fee6c63..b1df135 100644
--- a/content/browser/appcache/appcache_group_unittest.cc
+++ b/content/browser/appcache/appcache_group_unittest.cc
@@ -17,7 +17,7 @@ using appcache::AppCache;
using appcache::AppCacheFrontend;
using appcache::AppCacheGroup;
using appcache::AppCacheHost;
-using appcache::AppCacheService;
+using appcache::AppCacheServiceImpl;
using appcache::AppCacheUpdateJob;
namespace {
@@ -90,7 +90,7 @@ class TestUpdateObserver : public AppCacheGroup::UpdateObserver {
class TestAppCacheHost : public AppCacheHost {
public:
TestAppCacheHost(int host_id, AppCacheFrontend* frontend,
- AppCacheService* service)
+ AppCacheServiceImpl* service)
: AppCacheHost(host_id, frontend, service),
update_completed_(false) {
}
diff --git a/content/browser/appcache/appcache_interceptor.cc b/content/browser/appcache/appcache_interceptor.cc
index 3a2c2bd..069d2fd 100644
--- a/content/browser/appcache/appcache_interceptor.cc
+++ b/content/browser/appcache/appcache_interceptor.cc
@@ -7,14 +7,14 @@
#include "webkit/browser/appcache/appcache_backend_impl.h"
#include "webkit/browser/appcache/appcache_host.h"
#include "webkit/browser/appcache/appcache_request_handler.h"
-#include "webkit/browser/appcache/appcache_service.h"
+#include "webkit/browser/appcache/appcache_service_impl.h"
#include "webkit/browser/appcache/appcache_url_request_job.h"
#include "webkit/common/appcache/appcache_interfaces.h"
using appcache::AppCacheBackendImpl;
using appcache::AppCacheHost;
using appcache::AppCacheRequestHandler;
-using appcache::AppCacheService;
+using appcache::AppCacheServiceImpl;
using appcache::kNoCacheId;
using appcache::kNoHostId;
@@ -37,7 +37,7 @@ AppCacheRequestHandler* AppCacheInterceptor::GetHandler(
}
void AppCacheInterceptor::SetExtraRequestInfo(
- net::URLRequest* request, AppCacheService* service, int process_id,
+ net::URLRequest* request, AppCacheServiceImpl* service, int process_id,
int host_id, ResourceType::Type resource_type) {
if (!service || (host_id == kNoHostId))
return;
diff --git a/content/browser/appcache/appcache_interceptor.h b/content/browser/appcache/appcache_interceptor.h
index bb21b2f..d8da181 100644
--- a/content/browser/appcache/appcache_interceptor.h
+++ b/content/browser/appcache/appcache_interceptor.h
@@ -13,7 +13,7 @@
namespace appcache {
class AppCacheRequestHandler;
-class AppCacheService;
+class AppCacheServiceImpl;
}
namespace content {
@@ -31,7 +31,7 @@ class CONTENT_EXPORT AppCacheInterceptor
// Must be called to make a request eligible for retrieval from an appcache.
static void SetExtraRequestInfo(net::URLRequest* request,
- appcache::AppCacheService* service,
+ appcache::AppCacheServiceImpl* service,
int process_id,
int host_id,
ResourceType::Type resource_type);
diff --git a/content/browser/appcache/appcache_quota_client_unittest.cc b/content/browser/appcache/appcache_quota_client_unittest.cc
index 0bfed08..3a32e95 100644
--- a/content/browser/appcache/appcache_quota_client_unittest.cc
+++ b/content/browser/appcache/appcache_quota_client_unittest.cc
@@ -277,7 +277,7 @@ TEST_F(AppCacheQuotaClientTest, DeleteOriginData) {
Call_NotifyAppCacheReady(client);
// Perm deletions are short circuited in the Client and
- // should not reach the AppCacheService.
+ // should not reach the AppCacheServiceImpl.
EXPECT_EQ(quota::kQuotaStatusOk,
DeleteOriginData(client, kPerm, kOriginA));
EXPECT_EQ(0, mock_service_.delete_called_count());
diff --git a/content/browser/appcache/appcache_service_unittest.cc b/content/browser/appcache/appcache_service_unittest.cc
index f965cb3..80016a9 100644
--- a/content/browser/appcache/appcache_service_unittest.cc
+++ b/content/browser/appcache/appcache_service_unittest.cc
@@ -14,7 +14,7 @@
#include "net/http/http_response_headers.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "webkit/browser/appcache/appcache_response.h"
-#include "webkit/browser/appcache/appcache_service.h"
+#include "webkit/browser/appcache/appcache_service_impl.h"
using appcache::AppCache;
using appcache::AppCacheEntry;
@@ -23,7 +23,7 @@ using appcache::AppCacheInfo;
using appcache::AppCacheInfoCollection;
using appcache::AppCacheInfoVector;
using appcache::AppCacheResponseReader;
-using appcache::AppCacheService;
+using appcache::AppCacheServiceImpl;
using appcache::HttpResponseInfoIOBuffer;
namespace content {
@@ -90,15 +90,15 @@ class MockResponseReader : public AppCacheResponseReader {
} // namespace
-class AppCacheServiceTest : public testing::Test {
+class AppCacheServiceImplTest : public testing::Test {
public:
- AppCacheServiceTest()
+ AppCacheServiceImplTest()
: kOrigin("http://hello/"),
kManifestUrl(kOrigin.Resolve("manifest")),
- service_(new AppCacheService(NULL)),
+ service_(new AppCacheServiceImpl(NULL)),
delete_result_(net::OK), delete_completion_count_(0),
deletion_callback_(
- base::Bind(&AppCacheServiceTest::OnDeleteAppCachesComplete,
+ base::Bind(&AppCacheServiceImplTest::OnDeleteAppCachesComplete,
base::Unretained(this))) {
// Setup to use mock storage.
service_->storage_.reset(new MockAppCacheStorage(service_.get()));
@@ -180,7 +180,7 @@ class AppCacheServiceTest : public testing::Test {
const GURL kOrigin;
const GURL kManifestUrl;
- scoped_ptr<AppCacheService> service_;
+ scoped_ptr<AppCacheServiceImpl> service_;
int delete_result_;
int delete_completion_count_;
net::CompletionCallback deletion_callback_;
@@ -189,7 +189,7 @@ class AppCacheServiceTest : public testing::Test {
base::MessageLoop message_loop_;
};
-TEST_F(AppCacheServiceTest, DeleteAppCachesForOrigin) {
+TEST_F(AppCacheServiceImplTest, DeleteAppCachesForOrigin) {
// Without giving mock storage simiulated info, should fail.
service_->DeleteAppCachesForOrigin(kOrigin, deletion_callback_);
EXPECT_EQ(0, delete_completion_count_);
@@ -255,7 +255,7 @@ TEST_F(AppCacheServiceTest, DeleteAppCachesForOrigin) {
EXPECT_EQ(0, delete_completion_count_);
}
-TEST_F(AppCacheServiceTest, CheckAppCacheResponse) {
+TEST_F(AppCacheServiceImplTest, CheckAppCacheResponse) {
// Check a non-existing manifest.
EXPECT_FALSE(IsGroupStored(kManifestUrl));
service_->CheckAppCacheResponse(kManifestUrl, 1, 1);
@@ -327,14 +327,14 @@ TEST_F(AppCacheServiceTest, CheckAppCacheResponse) {
}
// Just tests the backoff scheduling function, not the actual reinit function.
-TEST_F(AppCacheServiceTest, ScheduleReinitialize) {
+TEST_F(AppCacheServiceImplTest, ScheduleReinitialize) {
const base::TimeDelta kNoDelay;
const base::TimeDelta kOneSecond(base::TimeDelta::FromSeconds(1));
const base::TimeDelta k30Seconds(base::TimeDelta::FromSeconds(30));
const base::TimeDelta kOneHour(base::TimeDelta::FromHours(1));
// Do things get initialized as expected?
- scoped_ptr<AppCacheService> service(new AppCacheService(NULL));
+ scoped_ptr<AppCacheServiceImpl> service(new AppCacheServiceImpl(NULL));
EXPECT_TRUE(service->last_reinit_time_.is_null());
EXPECT_FALSE(service->reinit_timer_.IsRunning());
EXPECT_EQ(kNoDelay, service->next_reinit_delay_);
diff --git a/content/browser/appcache/appcache_storage_impl_unittest.cc b/content/browser/appcache/appcache_storage_impl_unittest.cc
index e4a745d..16391d0 100644
--- a/content/browser/appcache/appcache_storage_impl_unittest.cc
+++ b/content/browser/appcache/appcache_storage_impl_unittest.cc
@@ -30,7 +30,7 @@
#include "webkit/browser/appcache/appcache_group.h"
#include "webkit/browser/appcache/appcache_host.h"
#include "webkit/browser/appcache/appcache_request_handler.h"
-#include "webkit/browser/appcache/appcache_service.h"
+#include "webkit/browser/appcache/appcache_service_impl.h"
#include "webkit/browser/appcache/appcache_storage_impl.h"
#include "webkit/browser/quota/quota_manager.h"
@@ -43,7 +43,7 @@ using appcache::AppCacheFrontend;
using appcache::AppCacheHost;
using appcache::AppCacheInfo;
using appcache::AppCacheGroup;
-using appcache::AppCacheService;
+using appcache::AppCacheServiceImpl;
using appcache::AppCacheStorage;
using appcache::AppCacheStorageImpl;
using appcache::AppCacheStorageReference;
@@ -420,7 +420,7 @@ class AppCacheStorageImplTest : public testing::Test {
void SetUpTest() {
DCHECK(base::MessageLoop::current() == io_thread->message_loop());
- service_.reset(new AppCacheService(NULL));
+ service_.reset(new AppCacheServiceImpl(NULL));
service_->Initialize(
base::FilePath(), db_thread->message_loop_proxy().get(), NULL);
mock_quota_manager_proxy_ = new MockQuotaManagerProxy();
@@ -1601,7 +1601,7 @@ class AppCacheStorageImplTest : public testing::Test {
// and involves other appcache classes to get some code
// coverage thruout when Reinitialize happens.
- class MockServiceObserver : public AppCacheService::Observer {
+ class MockServiceObserver : public AppCacheServiceImpl::Observer {
public:
explicit MockServiceObserver(AppCacheStorageImplTest* test)
: test_(test) {}
@@ -1715,7 +1715,7 @@ class AppCacheStorageImplTest : public testing::Test {
}
// Recreate the service to point at the db and corruption on disk.
- service_.reset(new AppCacheService(NULL));
+ service_.reset(new AppCacheServiceImpl(NULL));
service_->set_request_context(io_thread->request_context());
service_->Initialize(
temp_directory_.path(),
@@ -1826,7 +1826,7 @@ class AppCacheStorageImplTest : public testing::Test {
// Test case helpers --------------------------------------------------
- AppCacheService* service() {
+ AppCacheServiceImpl* service() {
return service_.get();
}
@@ -1883,7 +1883,7 @@ class AppCacheStorageImplTest : public testing::Test {
scoped_ptr<base::WaitableEvent> test_finished_event_;
std::stack<base::Closure> task_stack_;
- scoped_ptr<AppCacheService> service_;
+ scoped_ptr<AppCacheServiceImpl> service_;
scoped_ptr<MockStorageDelegate> delegate_;
scoped_refptr<MockQuotaManagerProxy> mock_quota_manager_proxy_;
scoped_refptr<AppCacheGroup> group_;
diff --git a/content/browser/appcache/chrome_appcache_service.cc b/content/browser/appcache/chrome_appcache_service.cc
index 006b0a3..c72c218 100644
--- a/content/browser/appcache/chrome_appcache_service.cc
+++ b/content/browser/appcache/chrome_appcache_service.cc
@@ -17,7 +17,7 @@ namespace content {
ChromeAppCacheService::ChromeAppCacheService(
quota::QuotaManagerProxy* quota_manager_proxy)
- : AppCacheService(quota_manager_proxy),
+ : AppCacheServiceImpl(quota_manager_proxy),
resource_context_(NULL) {
}
diff --git a/content/browser/appcache/chrome_appcache_service.h b/content/browser/appcache/chrome_appcache_service.h
index 61eafc1..2f33d9b 100644
--- a/content/browser/appcache/chrome_appcache_service.h
+++ b/content/browser/appcache/chrome_appcache_service.h
@@ -10,7 +10,7 @@
#include "base/sequenced_task_runner_helpers.h"
#include "content/common/content_export.h"
#include "webkit/browser/appcache/appcache_policy.h"
-#include "webkit/browser/appcache/appcache_service.h"
+#include "webkit/browser/appcache/appcache_service_impl.h"
#include "webkit/browser/quota/special_storage_policy.h"
namespace base {
@@ -26,7 +26,7 @@ class ResourceContext;
struct ChromeAppCacheServiceDeleter;
-// An AppCacheService subclass used by the chrome. There is an instance
+// An AppCacheServiceImpl subclass used by the chrome. There is an instance
// associated with each BrowserContext. This derivation adds refcounting
// semantics since a browser context has multiple URLRequestContexts which refer
// to the same object, and those URLRequestContexts are refcounted independently
@@ -35,12 +35,12 @@ struct ChromeAppCacheServiceDeleter;
// All methods, except the ctor, are expected to be called on
// the IO thread (unless specifically called out in doc comments).
//
-// TODO(dpranke): Fix dependencies on AppCacheService so that we don't have
-// to worry about clients calling AppCacheService methods.
+// TODO(dpranke): Fix dependencies on AppCacheServiceImpl so that we don't have
+// to worry about clients calling AppCacheServiceImpl methods.
class CONTENT_EXPORT ChromeAppCacheService
: public base::RefCountedThreadSafe<ChromeAppCacheService,
ChromeAppCacheServiceDeleter>,
- NON_EXPORTED_BASE(public appcache::AppCacheService),
+ NON_EXPORTED_BASE(public appcache::AppCacheServiceImpl),
NON_EXPORTED_BASE(public appcache::AppCachePolicy) {
public:
explicit ChromeAppCacheService(quota::QuotaManagerProxy* proxy);
diff --git a/content/browser/appcache/chrome_appcache_service_unittest.cc b/content/browser/appcache/chrome_appcache_service_unittest.cc
index ba0e144..1800d0b 100644
--- a/content/browser/appcache/chrome_appcache_service_unittest.cc
+++ b/content/browser/appcache/chrome_appcache_service_unittest.cc
@@ -71,7 +71,7 @@ class ChromeAppCacheServiceTest : public testing::Test {
io_thread_(BrowserThread::IO, &message_loop_) {}
protected:
- scoped_refptr<ChromeAppCacheService> CreateAppCacheService(
+ scoped_refptr<ChromeAppCacheService> CreateAppCacheServiceImpl(
const base::FilePath& appcache_path,
bool init_storage);
void InsertDataIntoAppCache(ChromeAppCacheService* appcache_service);
@@ -91,7 +91,7 @@ class ChromeAppCacheServiceTest : public testing::Test {
};
scoped_refptr<ChromeAppCacheService>
-ChromeAppCacheServiceTest::CreateAppCacheService(
+ChromeAppCacheServiceTest::CreateAppCacheServiceImpl(
const base::FilePath& appcache_path,
bool init_storage) {
scoped_refptr<ChromeAppCacheService> appcache_service =
@@ -150,7 +150,7 @@ TEST_F(ChromeAppCacheServiceTest, KeepOnDestruction) {
// Create a ChromeAppCacheService and insert data into it
scoped_refptr<ChromeAppCacheService> appcache_service =
- CreateAppCacheService(appcache_path, true);
+ CreateAppCacheServiceImpl(appcache_path, true);
ASSERT_TRUE(base::PathExists(appcache_path));
ASSERT_TRUE(base::PathExists(appcache_path.AppendASCII("Index")));
InsertDataIntoAppCache(appcache_service.get());
@@ -160,7 +160,7 @@ TEST_F(ChromeAppCacheServiceTest, KeepOnDestruction) {
message_loop_.RunUntilIdle();
// Recreate the appcache (for reading the data back)
- appcache_service = CreateAppCacheService(appcache_path, false);
+ appcache_service = CreateAppCacheServiceImpl(appcache_path, false);
// The directory is still there
ASSERT_TRUE(base::PathExists(appcache_path));
@@ -187,7 +187,7 @@ TEST_F(ChromeAppCacheServiceTest, SaveSessionState) {
// Create a ChromeAppCacheService and insert data into it
scoped_refptr<ChromeAppCacheService> appcache_service =
- CreateAppCacheService(appcache_path, true);
+ CreateAppCacheServiceImpl(appcache_path, true);
ASSERT_TRUE(base::PathExists(appcache_path));
ASSERT_TRUE(base::PathExists(appcache_path.AppendASCII("Index")));
InsertDataIntoAppCache(appcache_service.get());
@@ -200,7 +200,7 @@ TEST_F(ChromeAppCacheServiceTest, SaveSessionState) {
message_loop_.RunUntilIdle();
// Recreate the appcache (for reading the data back)
- appcache_service = CreateAppCacheService(appcache_path, false);
+ appcache_service = CreateAppCacheServiceImpl(appcache_path, false);
// The directory is still there
ASSERT_TRUE(base::PathExists(appcache_path));
diff --git a/content/browser/appcache/mock_appcache_service.h b/content/browser/appcache/mock_appcache_service.h
index 9b10598..691736b 100644
--- a/content/browser/appcache/mock_appcache_service.h
+++ b/content/browser/appcache/mock_appcache_service.h
@@ -7,18 +7,18 @@
#include "base/compiler_specific.h"
#include "content/browser/appcache/mock_appcache_storage.h"
-#include "webkit/browser/appcache/appcache_service.h"
+#include "webkit/browser/appcache/appcache_service_impl.h"
#include "webkit/browser/quota/quota_manager.h"
-using appcache::AppCacheService;
+using appcache::AppCacheServiceImpl;
namespace content {
// For use by unit tests.
-class MockAppCacheService : public AppCacheService {
+class MockAppCacheService : public AppCacheServiceImpl {
public:
MockAppCacheService()
- : AppCacheService(NULL),
+ : AppCacheServiceImpl(NULL),
mock_delete_appcaches_for_origin_result_(net::OK),
delete_called_count_(0) {
storage_.reset(new MockAppCacheStorage(this));
diff --git a/content/browser/appcache/mock_appcache_storage.cc b/content/browser/appcache/mock_appcache_storage.cc
index ab233b0..e1c5c18 100644
--- a/content/browser/appcache/mock_appcache_storage.cc
+++ b/content/browser/appcache/mock_appcache_storage.cc
@@ -13,7 +13,7 @@
#include "webkit/browser/appcache/appcache_entry.h"
#include "webkit/browser/appcache/appcache_group.h"
#include "webkit/browser/appcache/appcache_response.h"
-#include "webkit/browser/appcache/appcache_service.h"
+#include "webkit/browser/appcache/appcache_service_impl.h"
// This is a quick and easy 'mock' implementation of the storage interface
// that doesn't put anything to disk.
@@ -26,7 +26,7 @@
// background thread.
using appcache::AppCacheResponseWriter;
-using appcache::AppCacheService;
+using appcache::AppCacheServiceImpl;
using appcache::FALLBACK_NAMESPACE;
using appcache::INTERCEPT_NAMESPACE;
using appcache::kNoCacheId;
@@ -34,7 +34,7 @@ using appcache::NamespaceType;
namespace content {
-MockAppCacheStorage::MockAppCacheStorage(AppCacheService* service)
+MockAppCacheStorage::MockAppCacheStorage(AppCacheServiceImpl* service)
: AppCacheStorage(service),
simulate_make_group_obsolete_failure_(false),
simulate_store_group_and_newest_cache_failure_(false),
diff --git a/content/browser/appcache/mock_appcache_storage.h b/content/browser/appcache/mock_appcache_storage.h
index 6875b5d..a9e9582 100644
--- a/content/browser/appcache/mock_appcache_storage.h
+++ b/content/browser/appcache/mock_appcache_storage.h
@@ -27,12 +27,12 @@ using appcache::AppCacheGroup;
using appcache::AppCacheInfoCollection;
using appcache::AppCacheResponseReader;
using appcache::AppCacheResponseWriter;
-using appcache::AppCacheService;
+using appcache::AppCacheServiceImpl;
using appcache::AppCacheStorage;
using appcache::kNoCacheId;
namespace content {
-FORWARD_DECLARE_TEST(AppCacheServiceTest, DeleteAppCachesForOrigin);
+FORWARD_DECLARE_TEST(AppCacheServiceImplTest, DeleteAppCachesForOrigin);
FORWARD_DECLARE_TEST(MockAppCacheStorageTest, BasicFindMainResponse);
FORWARD_DECLARE_TEST(MockAppCacheStorageTest,
BasicFindMainFallbackResponse);
@@ -48,7 +48,7 @@ FORWARD_DECLARE_TEST(MockAppCacheStorageTest, StoreExistingGroup);
FORWARD_DECLARE_TEST(MockAppCacheStorageTest,
StoreExistingGroupExistingCache);
class AppCacheRequestHandlerTest;
-class AppCacheServiceTest;
+class AppCacheServiceImplTest;
class MockAppCacheStorageTest;
// For use in unit tests.
@@ -57,7 +57,7 @@ class MockAppCacheStorageTest;
// somewhat in parallel.
class MockAppCacheStorage : public AppCacheStorage {
public:
- explicit MockAppCacheStorage(AppCacheService* service);
+ explicit MockAppCacheStorage(AppCacheServiceImpl* service);
virtual ~MockAppCacheStorage();
virtual void GetAllInfo(Delegate* delegate) OVERRIDE;
@@ -92,7 +92,7 @@ class MockAppCacheStorage : public AppCacheStorage {
private:
friend class AppCacheRequestHandlerTest;
- friend class AppCacheServiceTest;
+ friend class AppCacheServiceImplTest;
friend class AppCacheUpdateJobTest;
friend class MockAppCacheStorageTest;
@@ -243,7 +243,7 @@ class MockAppCacheStorage : public AppCacheStorage {
StoreExistingGroup);
FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest,
StoreExistingGroupExistingCache);
- FRIEND_TEST_ALL_PREFIXES(AppCacheServiceTest,
+ FRIEND_TEST_ALL_PREFIXES(AppCacheServiceImplTest,
DeleteAppCachesForOrigin);
DISALLOW_COPY_AND_ASSIGN(MockAppCacheStorage);
diff --git a/content/browser/appcache/view_appcache_internals_job.cc b/content/browser/appcache/view_appcache_internals_job.cc
index b6a3c3f..0cc64c3 100644
--- a/content/browser/appcache/view_appcache_internals_job.cc
+++ b/content/browser/appcache/view_appcache_internals_job.cc
@@ -28,14 +28,14 @@
#include "webkit/browser/appcache/appcache_group.h"
#include "webkit/browser/appcache/appcache_policy.h"
#include "webkit/browser/appcache/appcache_response.h"
-#include "webkit/browser/appcache/appcache_service.h"
+#include "webkit/browser/appcache/appcache_service_impl.h"
#include "webkit/browser/appcache/appcache_storage.h"
using appcache::AppCacheGroup;
using appcache::AppCacheInfo;
using appcache::AppCacheInfoCollection;
using appcache::AppCacheInfoVector;
-using appcache::AppCacheService;
+using appcache::AppCacheServiceImpl;
using appcache::AppCacheStorage;
using appcache::AppCacheStorageReference;
using appcache::AppCacheResourceInfo;
@@ -116,7 +116,7 @@ void EmitCommandAnchor(const char* label,
}
void EmitAppCacheInfo(const GURL& base_url,
- AppCacheService* service,
+ AppCacheServiceImpl* service,
const AppCacheInfo* info,
std::string* out) {
std::string manifest_url_base64;
@@ -159,7 +159,7 @@ void EmitAppCacheInfo(const GURL& base_url,
void EmitAppCacheInfoVector(
const GURL& base_url,
- AppCacheService* service,
+ AppCacheServiceImpl* service,
const AppCacheInfoVector& appcaches,
std::string* out) {
for (std::vector<AppCacheInfo>::const_iterator info =
@@ -321,11 +321,11 @@ GURL ClearQuery(const GURL& url) {
// Simple base class for the job subclasses defined here.
class BaseInternalsJob : public net::URLRequestSimpleJob,
- public AppCacheService::Observer {
+ public AppCacheServiceImpl::Observer {
protected:
BaseInternalsJob(net::URLRequest* request,
net::NetworkDelegate* network_delegate,
- AppCacheService* service)
+ AppCacheServiceImpl* service)
: URLRequestSimpleJob(request, network_delegate),
appcache_service_(service),
appcache_storage_(service->storage()) {
@@ -342,7 +342,7 @@ class BaseInternalsJob : public net::URLRequestSimpleJob,
disabled_storage_reference_ = old_storage_ref;
}
- AppCacheService* appcache_service_;
+ AppCacheServiceImpl* appcache_service_;
AppCacheStorage* appcache_storage_;
scoped_refptr<AppCacheStorageReference> disabled_storage_reference_;
};
@@ -352,7 +352,7 @@ class MainPageJob : public BaseInternalsJob {
public:
MainPageJob(net::URLRequest* request,
net::NetworkDelegate* network_delegate,
- AppCacheService* service)
+ AppCacheServiceImpl* service)
: BaseInternalsJob(request, network_delegate, service),
weak_factory_(this) {
}
@@ -417,7 +417,7 @@ class RedirectToMainPageJob : public BaseInternalsJob {
public:
RedirectToMainPageJob(net::URLRequest* request,
net::NetworkDelegate* network_delegate,
- AppCacheService* service)
+ AppCacheServiceImpl* service)
: BaseInternalsJob(request, network_delegate, service) {}
virtual int GetData(std::string* mime_type,
@@ -444,7 +444,7 @@ class RemoveAppCacheJob : public RedirectToMainPageJob {
RemoveAppCacheJob(
net::URLRequest* request,
net::NetworkDelegate* network_delegate,
- AppCacheService* service,
+ AppCacheServiceImpl* service,
const GURL& manifest_url)
: RedirectToMainPageJob(request, network_delegate, service),
manifest_url_(manifest_url),
@@ -478,7 +478,7 @@ class ViewAppCacheJob : public BaseInternalsJob,
ViewAppCacheJob(
net::URLRequest* request,
net::NetworkDelegate* network_delegate,
- AppCacheService* service,
+ AppCacheServiceImpl* service,
const GURL& manifest_url)
: BaseInternalsJob(request, network_delegate, service),
manifest_url_(manifest_url) {}
@@ -549,7 +549,7 @@ class ViewEntryJob : public BaseInternalsJob,
ViewEntryJob(
net::URLRequest* request,
net::NetworkDelegate* network_delegate,
- AppCacheService* service,
+ AppCacheServiceImpl* service,
const GURL& manifest_url,
const GURL& entry_url,
int64 response_id, int64 group_id)
@@ -647,7 +647,7 @@ class ViewEntryJob : public BaseInternalsJob,
net::URLRequestJob* ViewAppCacheInternalsJobFactory::CreateJobForRequest(
net::URLRequest* request,
net::NetworkDelegate* network_delegate,
- AppCacheService* service) {
+ AppCacheServiceImpl* service) {
if (!request->url().has_query())
return new MainPageJob(request, network_delegate, service);
diff --git a/content/browser/appcache/view_appcache_internals_job.h b/content/browser/appcache/view_appcache_internals_job.h
index 44aa72c..f11b68e 100644
--- a/content/browser/appcache/view_appcache_internals_job.h
+++ b/content/browser/appcache/view_appcache_internals_job.h
@@ -14,7 +14,7 @@ class URLRequestJob;
}
namespace appcache {
-class AppCacheService;
+class AppCacheServiceImpl;
}
namespace content {
@@ -24,7 +24,7 @@ class ViewAppCacheInternalsJobFactory {
static net::URLRequestJob* CreateJobForRequest(
net::URLRequest* request,
net::NetworkDelegate* network_delegate,
- appcache::AppCacheService* service);
+ appcache::AppCacheServiceImpl* service);
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(ViewAppCacheInternalsJobFactory);
diff --git a/content/browser/browser_context.cc b/content/browser/browser_context.cc
index 2758c5d..dbc5949 100644
--- a/content/browser/browser_context.cc
+++ b/content/browser/browser_context.cc
@@ -69,7 +69,7 @@ StoragePartition* GetStoragePartitionFromConfig(
void SaveSessionStateOnIOThread(
const scoped_refptr<net::URLRequestContextGetter>& context_getter,
- appcache::AppCacheService* appcache_service) {
+ appcache::AppCacheServiceImpl* appcache_service) {
net::URLRequestContext* context = context_getter->GetURLRequestContext();
context->cookie_store()->GetCookieMonster()->
SetForceKeepSessionState();
@@ -236,7 +236,8 @@ void BrowserContext::SaveSessionState(BrowserContext* browser_context) {
base::Bind(
&SaveSessionStateOnIOThread,
make_scoped_refptr(browser_context->GetRequestContext()),
- storage_partition->GetAppCacheService()));
+ static_cast<appcache::AppCacheServiceImpl*>(
+ storage_partition->GetAppCacheService())));
}
DOMStorageContextWrapper* dom_storage_context_proxy =
diff --git a/content/browser/storage_partition_impl_map.cc b/content/browser/storage_partition_impl_map.cc
index 16fc2fe..74a212f 100644
--- a/content/browser/storage_partition_impl_map.cc
+++ b/content/browser/storage_partition_impl_map.cc
@@ -40,7 +40,7 @@
#include "webkit/browser/fileapi/file_system_url_request_job_factory.h"
#include "webkit/common/blob/blob_data.h"
-using appcache::AppCacheService;
+using appcache::AppCacheServiceImpl;
using fileapi::FileSystemContext;
using webkit_blob::BlobStorageContext;
diff --git a/content/browser/webui/url_data_manager_backend.cc b/content/browser/webui/url_data_manager_backend.cc
index e9b66ef..9f661af 100644
--- a/content/browser/webui/url_data_manager_backend.cc
+++ b/content/browser/webui/url_data_manager_backend.cc
@@ -44,7 +44,7 @@
#include "net/url_request/url_request_job_factory.h"
#include "url/url_util.h"
-using appcache::AppCacheService;
+using appcache::AppCacheServiceImpl;
namespace content {
@@ -428,7 +428,7 @@ class ChromeProtocolHandler
// |is_incognito| should be set for incognito profiles.
ChromeProtocolHandler(ResourceContext* resource_context,
bool is_incognito,
- AppCacheService* appcache_service,
+ AppCacheServiceImpl* appcache_service,
ChromeBlobStorageContext* blob_storage_context)
: resource_context_(resource_context),
is_incognito_(is_incognito),
@@ -489,7 +489,7 @@ class ChromeProtocolHandler
// True when generated from an incognito profile.
const bool is_incognito_;
- AppCacheService* appcache_service_;
+ AppCacheServiceImpl* appcache_service_;
ChromeBlobStorageContext* blob_storage_context_;
DISALLOW_COPY_AND_ASSIGN(ChromeProtocolHandler);
@@ -518,7 +518,7 @@ net::URLRequestJobFactory::ProtocolHandler*
URLDataManagerBackend::CreateProtocolHandler(
content::ResourceContext* resource_context,
bool is_incognito,
- AppCacheService* appcache_service,
+ AppCacheServiceImpl* appcache_service,
ChromeBlobStorageContext* blob_storage_context) {
DCHECK(resource_context);
return new ChromeProtocolHandler(
diff --git a/content/browser/webui/url_data_manager_backend.h b/content/browser/webui/url_data_manager_backend.h
index ff9d097..a307cdb 100644
--- a/content/browser/webui/url_data_manager_backend.h
+++ b/content/browser/webui/url_data_manager_backend.h
@@ -19,7 +19,7 @@
class GURL;
namespace appcache {
-class AppCacheService;
+class AppCacheServiceImpl;
}
namespace base {
@@ -48,7 +48,7 @@ class URLDataManagerBackend : public base::SupportsUserData::Data {
static net::URLRequestJobFactory::ProtocolHandler* CreateProtocolHandler(
content::ResourceContext* resource_context,
bool is_incognito,
- appcache::AppCacheService* appcache_service,
+ appcache::AppCacheServiceImpl* appcache_service,
ChromeBlobStorageContext* blob_storage_context);
// Adds a DataSource to the collection of data sources.
diff --git a/content/test/appcache_test_helper.cc b/content/test/appcache_test_helper.cc
index 717b84f..087c721 100644
--- a/content/test/appcache_test_helper.cc
+++ b/content/test/appcache_test_helper.cc
@@ -11,7 +11,7 @@
#include "webkit/browser/appcache/appcache.h"
#include "webkit/browser/appcache/appcache_entry.h"
#include "webkit/browser/appcache/appcache_group.h"
-#include "webkit/browser/appcache/appcache_service.h"
+#include "webkit/browser/appcache/appcache_service_impl.h"
namespace content {
@@ -32,7 +32,7 @@ void AppCacheTestHelper::OnGroupAndNewestCacheStored(
base::MessageLoop::current()->Quit();
}
-void AppCacheTestHelper::AddGroupAndCache(appcache::AppCacheService*
+void AppCacheTestHelper::AddGroupAndCache(appcache::AppCacheServiceImpl*
appcache_service, const GURL& manifest_url) {
appcache::AppCacheGroup* appcache_group =
new appcache::AppCacheGroup(appcache_service->storage(),
@@ -52,7 +52,7 @@ void AppCacheTestHelper::AddGroupAndCache(appcache::AppCacheService*
base::MessageLoop::current()->Run();
}
-void AppCacheTestHelper::GetOriginsWithCaches(appcache::AppCacheService*
+void AppCacheTestHelper::GetOriginsWithCaches(appcache::AppCacheServiceImpl*
appcache_service, std::set<GURL>* origins) {
appcache_info_ = new appcache::AppCacheInfoCollection;
origins_ = origins;
diff --git a/content/test/appcache_test_helper.h b/content/test/appcache_test_helper.h
index 184e427..f93424b 100644
--- a/content/test/appcache_test_helper.h
+++ b/content/test/appcache_test_helper.h
@@ -10,7 +10,7 @@
#include "webkit/browser/appcache/appcache_storage.h"
namespace appcache {
-class AppCacheService;
+class AppCacheServiceImpl;
}
namespace content {
@@ -21,10 +21,10 @@ class AppCacheTestHelper : public appcache::AppCacheStorage::Delegate {
public:
AppCacheTestHelper();
virtual ~AppCacheTestHelper();
- void AddGroupAndCache(appcache::AppCacheService* appcache_service,
+ void AddGroupAndCache(appcache::AppCacheServiceImpl* appcache_service,
const GURL& manifest_url);
- void GetOriginsWithCaches(appcache::AppCacheService* appcache_service,
+ void GetOriginsWithCaches(appcache::AppCacheServiceImpl* appcache_service,
std::set<GURL>* origins);
private:
virtual void OnGroupAndNewestCacheStored(
diff --git a/webkit/browser/BUILD.gn b/webkit/browser/BUILD.gn
index 0760d0e..e06af088 100644
--- a/webkit/browser/BUILD.gn
+++ b/webkit/browser/BUILD.gn
@@ -35,7 +35,8 @@ component("storage") {
"appcache/appcache_request_handler.h",
"appcache/appcache_response.cc",
"appcache/appcache_response.h",
- "appcache/appcache_service.cc",
+ "appcache/appcache_service_impl.cc",
+ "appcache/appcache_service_impl.h",
"appcache/appcache_service.h",
"appcache/appcache_storage.cc",
"appcache/appcache_storage.h",
diff --git a/webkit/browser/appcache/appcache_backend_impl.cc b/webkit/browser/appcache/appcache_backend_impl.cc
index 17b0b0c..376724e 100644
--- a/webkit/browser/appcache/appcache_backend_impl.cc
+++ b/webkit/browser/appcache/appcache_backend_impl.cc
@@ -7,7 +7,7 @@
#include "base/stl_util.h"
#include "webkit/browser/appcache/appcache.h"
#include "webkit/browser/appcache/appcache_group.h"
-#include "webkit/browser/appcache/appcache_service.h"
+#include "webkit/browser/appcache/appcache_service_impl.h"
namespace appcache {
@@ -23,7 +23,7 @@ AppCacheBackendImpl::~AppCacheBackendImpl() {
service_->UnregisterBackend(this);
}
-void AppCacheBackendImpl::Initialize(AppCacheService* service,
+void AppCacheBackendImpl::Initialize(AppCacheServiceImpl* service,
AppCacheFrontend* frontend,
int process_id) {
DCHECK(!service_ && !frontend_ && frontend && service);
diff --git a/webkit/browser/appcache/appcache_backend_impl.h b/webkit/browser/appcache/appcache_backend_impl.h
index 0d1779f..cc85a76 100644
--- a/webkit/browser/appcache/appcache_backend_impl.h
+++ b/webkit/browser/appcache/appcache_backend_impl.h
@@ -11,14 +11,14 @@
namespace appcache {
-class AppCacheService;
+class AppCacheServiceImpl;
class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheBackendImpl {
public:
AppCacheBackendImpl();
~AppCacheBackendImpl();
- void Initialize(AppCacheService* service,
+ void Initialize(AppCacheServiceImpl* service,
AppCacheFrontend* frontend,
int process_id);
@@ -64,7 +64,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheBackendImpl {
void TransferHostIn(int new_host_id, scoped_ptr<AppCacheHost> host);
private:
- AppCacheService* service_;
+ AppCacheServiceImpl* service_;
AppCacheFrontend* frontend_;
int process_id_;
HostMap hosts_;
diff --git a/webkit/browser/appcache/appcache_group.cc b/webkit/browser/appcache/appcache_group.cc
index e467516..c62eaea 100644
--- a/webkit/browser/appcache/appcache_group.cc
+++ b/webkit/browser/appcache/appcache_group.cc
@@ -11,7 +11,7 @@
#include "base/message_loop/message_loop.h"
#include "webkit/browser/appcache/appcache.h"
#include "webkit/browser/appcache/appcache_host.h"
-#include "webkit/browser/appcache/appcache_service.h"
+#include "webkit/browser/appcache/appcache_service_impl.h"
#include "webkit/browser/appcache/appcache_storage.h"
#include "webkit/browser/appcache/appcache_update_job.h"
diff --git a/webkit/browser/appcache/appcache_host.cc b/webkit/browser/appcache/appcache_host.cc
index b4b4222..7f69137 100644
--- a/webkit/browser/appcache/appcache_host.cc
+++ b/webkit/browser/appcache/appcache_host.cc
@@ -43,7 +43,7 @@ void FillCacheInfo(const AppCache* cache,
} // Anonymous namespace
AppCacheHost::AppCacheHost(int host_id, AppCacheFrontend* frontend,
- AppCacheService* service)
+ AppCacheServiceImpl* service)
: host_id_(host_id),
spawning_host_id_(kNoHostId), spawning_process_id_(0),
parent_host_id_(kNoHostId), parent_process_id_(0),
diff --git a/webkit/browser/appcache/appcache_host.h b/webkit/browser/appcache/appcache_host.h
index 2f0f068..9ca13ad 100644
--- a/webkit/browser/appcache/appcache_host.h
+++ b/webkit/browser/appcache/appcache_host.h
@@ -11,7 +11,7 @@
#include "base/observer_list.h"
#include "url/gurl.h"
#include "webkit/browser/appcache/appcache_group.h"
-#include "webkit/browser/appcache/appcache_service.h"
+#include "webkit/browser/appcache/appcache_service_impl.h"
#include "webkit/browser/appcache/appcache_storage.h"
#include "webkit/browser/webkit_storage_browser_export.h"
#include "webkit/common/appcache/appcache_interfaces.h"
@@ -56,7 +56,7 @@ typedef base::Callback<void(bool, void*)> SwapCacheCallback;
class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheHost
: public AppCacheStorage::Delegate,
public AppCacheGroup::UpdateObserver,
- public AppCacheService::Observer {
+ public AppCacheServiceImpl::Observer {
public:
class WEBKIT_STORAGE_BROWSER_EXPORT Observer {
@@ -71,7 +71,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheHost
};
AppCacheHost(int host_id, AppCacheFrontend* frontend,
- AppCacheService* service);
+ AppCacheServiceImpl* service);
virtual ~AppCacheHost();
// Adds/removes an observer, the AppCacheHost does not take
@@ -161,7 +161,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheHost
}
int host_id() const { return host_id_; }
- AppCacheService* service() const { return service_; }
+ AppCacheServiceImpl* service() const { return service_; }
AppCacheStorage* storage() const { return storage_; }
AppCacheFrontend* frontend() const { return frontend_; }
AppCache* associated_cache() const { return associated_cache_.get(); }
@@ -194,7 +194,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheHost
virtual void OnCacheLoaded(AppCache* cache, int64 cache_id) OVERRIDE;
virtual void OnGroupLoaded(AppCacheGroup* group,
const GURL& manifest_url) OVERRIDE;
- // AppCacheService::Observer impl
+ // AppCacheServiceImpl::Observer impl
virtual void OnServiceReinitialized(
AppCacheStorageReference* old_storage_ref) OVERRIDE;
@@ -275,7 +275,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheHost
AppCacheFrontend* frontend_;
// Our central service object.
- AppCacheService* service_;
+ AppCacheServiceImpl* service_;
// And the equally central storage object, with a twist. In some error
// conditions the storage object gets recreated and reinitialized. The
diff --git a/webkit/browser/appcache/appcache_quota_client.cc b/webkit/browser/appcache/appcache_quota_client.cc
index ec44a28..039b554 100644
--- a/webkit/browser/appcache/appcache_quota_client.cc
+++ b/webkit/browser/appcache/appcache_quota_client.cc
@@ -10,7 +10,7 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
-#include "webkit/browser/appcache/appcache_service.h"
+#include "webkit/browser/appcache/appcache_service_impl.h"
using quota::QuotaClient;
@@ -33,7 +33,7 @@ void RunFront(appcache::AppCacheQuotaClient::RequestQueue* queue) {
namespace appcache {
-AppCacheQuotaClient::AppCacheQuotaClient(AppCacheService* service)
+AppCacheQuotaClient::AppCacheQuotaClient(AppCacheServiceImpl* service)
: service_(service),
appcache_is_ready_(false),
quota_manager_is_destroyed_(false) {
diff --git a/webkit/browser/appcache/appcache_quota_client.h b/webkit/browser/appcache/appcache_quota_client.h
index 90ba852..825f38e 100644
--- a/webkit/browser/appcache/appcache_quota_client.h
+++ b/webkit/browser/appcache/appcache_quota_client.h
@@ -25,7 +25,7 @@ class AppCacheQuotaClientTest;
namespace appcache {
-class AppCacheService;
+class AppCacheServiceImpl;
class AppCacheStorageImpl;
class AppCacheQuotaClientTest;
@@ -58,11 +58,11 @@ class AppCacheQuotaClient : public quota::QuotaClient {
private:
friend class content::AppCacheQuotaClientTest;
- friend class AppCacheService; // for NotifyAppCacheIsDestroyed
+ friend class AppCacheServiceImpl; // for NotifyAppCacheIsDestroyed
friend class AppCacheStorageImpl; // for NotifyAppCacheIsReady
WEBKIT_STORAGE_BROWSER_EXPORT
- explicit AppCacheQuotaClient(AppCacheService* service);
+ explicit AppCacheQuotaClient(AppCacheServiceImpl* service);
void DidDeleteAppCachesForOrigin(int rv);
void GetOriginsHelper(quota::StorageType type,
@@ -87,7 +87,7 @@ class AppCacheQuotaClient : public quota::QuotaClient {
DeletionCallback current_delete_request_callback_;
scoped_ptr<net::CancelableCompletionCallback> service_delete_callback_;
- AppCacheService* service_;
+ AppCacheServiceImpl* service_;
bool appcache_is_ready_;
bool quota_manager_is_destroyed_;
diff --git a/webkit/browser/appcache/appcache_service.h b/webkit/browser/appcache/appcache_service.h
index 4f9ae4b..dc6e33b 100644
--- a/webkit/browser/appcache/appcache_service.h
+++ b/webkit/browser/appcache/appcache_service.h
@@ -8,43 +8,13 @@
#include <map>
#include <set>
-#include "base/gtest_prod_util.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
-#include "base/observer_list.h"
-#include "base/time/time.h"
-#include "base/timer/timer.h"
-#include "net/base/completion_callback.h"
-#include "net/base/net_errors.h"
-#include "webkit/browser/quota/quota_manager_proxy.h"
#include "webkit/browser/webkit_storage_browser_export.h"
#include "webkit/common/appcache/appcache_interfaces.h"
-namespace net {
-class URLRequestContext;
-} // namespace net
-
-namespace base {
-class FilePath;
-class MessageLoopProxy;
-}
-
-namespace content {
-FORWARD_DECLARE_TEST(AppCacheServiceTest, ScheduleReinitialize);
-class AppCacheServiceTest;
-class AppCacheStorageImplTest;
-}
-
-namespace quota {
-class SpecialStoragePolicy;
-}
-
namespace appcache {
-class AppCacheBackendImpl;
-class AppCacheExecutableHandlerFactory;
-class AppCacheQuotaClient;
-class AppCachePolicy;
class AppCacheStorage;
// Refcounted container to avoid copying the collection in callbacks.
@@ -59,185 +29,34 @@ struct WEBKIT_STORAGE_BROWSER_EXPORT AppCacheInfoCollection
virtual ~AppCacheInfoCollection();
};
-// Refcounted container to manage the lifetime of the old storage instance
-// during Reinitialization.
-class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheStorageReference :
- public base::RefCounted<AppCacheStorageReference> {
- public:
- AppCacheStorage* storage() const { return storage_.get(); }
- private:
- friend class AppCacheService;
- friend class base::RefCounted<AppCacheStorageReference>;
- AppCacheStorageReference(scoped_ptr<AppCacheStorage> storage);
- ~AppCacheStorageReference();
-
- scoped_ptr<AppCacheStorage> storage_;
-};
-
// Class that manages the application cache service. Sends notifications
-// to many frontends. One instance per user-profile. Each instance has
+// to many frontends. One instance per user-profile. Each instance has
// exclusive access to its cache_directory on disk.
class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheService {
public:
-
- class WEBKIT_STORAGE_BROWSER_EXPORT Observer {
- public:
- // An observer method to inform consumers of reinitialzation. Managing
- // the lifetime of the old storage instance is a delicate process.
- // Consumers can keep the old disabled instance alive by hanging on to the
- // ref provided.
- virtual void OnServiceReinitialized(
- AppCacheStorageReference* old_storage_ref) = 0;
- virtual ~Observer() {}
- };
-
- // If not using quota management, the proxy may be NULL.
- explicit AppCacheService(quota::QuotaManagerProxy* quota_manager_proxy);
- virtual ~AppCacheService();
-
- void Initialize(const base::FilePath& cache_directory,
- base::MessageLoopProxy* db_thread,
- base::MessageLoopProxy* cache_thread);
-
- void AddObserver(Observer* observer) {
- observers_.AddObserver(observer);
- }
-
- void RemoveObserver(Observer* observer) {
- observers_.RemoveObserver(observer);
- }
-
- // For use in catastrophic failure modes to reboot the appcache system
- // without relaunching the browser.
- void ScheduleReinitialize();
+ virtual ~AppCacheService() { }
// Determines if a request for 'url' can be satisfied while offline.
// This method always completes asynchronously.
- void CanHandleMainResourceOffline(const GURL& url,
- const GURL& first_party,
- const net::CompletionCallback& callback);
+ virtual void CanHandleMainResourceOffline(const GURL& url,
+ const GURL& first_party,
+ const net::CompletionCallback&
+ callback) = 0;
// Populates 'collection' with info about all of the appcaches stored
// within the service, 'callback' is invoked upon completion. The service
// acquires a reference to the 'collection' until until completion.
// This method always completes asynchronously.
- void GetAllAppCacheInfo(AppCacheInfoCollection* collection,
- const net::CompletionCallback& callback);
+ virtual void GetAllAppCacheInfo(AppCacheInfoCollection* collection,
+ const net::CompletionCallback& callback) = 0;
// Deletes the group identified by 'manifest_url', 'callback' is
// invoked upon completion. Upon completion, the cache group and
// any resources within the group are no longer loadable and all
// subresource loads for pages associated with a deleted group
// will fail. This method always completes asynchronously.
- void DeleteAppCacheGroup(const GURL& manifest_url,
- const net::CompletionCallback& callback);
-
- // Deletes all appcaches for the origin, 'callback' is invoked upon
- // completion. This method always completes asynchronously.
- // (virtual for unit testing)
- virtual void DeleteAppCachesForOrigin(
- const GURL& origin, const net::CompletionCallback& callback);
-
- // Checks the integrity of 'response_id' by reading the headers and data.
- // If it cannot be read, the cache group for 'manifest_url' is deleted.
- void CheckAppCacheResponse(const GURL& manifest_url, int64 cache_id,
- int64 response_id);
-
- // Context for use during cache updates, should only be accessed
- // on the IO thread. We do NOT add a reference to the request context,
- // it is the callers responsibility to ensure that the pointer
- // remains valid while set.
- net::URLRequestContext* request_context() const { return request_context_; }
- void set_request_context(net::URLRequestContext* context) {
- request_context_ = context;
- }
-
- // The appcache policy, may be null, in which case access is always allowed.
- // The service does NOT assume ownership of the policy, it is the callers
- // responsibility to ensure that the pointer remains valid while set.
- AppCachePolicy* appcache_policy() const { return appcache_policy_; }
- void set_appcache_policy(AppCachePolicy* policy) {
- appcache_policy_ = policy;
- }
-
- // The factory may be null, in which case invocations of exe handlers
- // will result in an error response.
- // The service does NOT assume ownership of the factory, it is the callers
- // responsibility to ensure that the pointer remains valid while set.
- AppCacheExecutableHandlerFactory* handler_factory() const {
- return handler_factory_;
- }
- void set_handler_factory(
- AppCacheExecutableHandlerFactory* factory) {
- handler_factory_ = factory;
- }
-
- quota::SpecialStoragePolicy* special_storage_policy() const {
- return special_storage_policy_.get();
- }
- void set_special_storage_policy(quota::SpecialStoragePolicy* policy);
-
- quota::QuotaManagerProxy* quota_manager_proxy() const {
- return quota_manager_proxy_.get();
- }
-
- AppCacheQuotaClient* quota_client() const {
- return quota_client_;
- }
-
- // Each child process in chrome uses a distinct backend instance.
- // See chrome/browser/AppCacheDispatcherHost.
- void RegisterBackend(AppCacheBackendImpl* backend_impl);
- void UnregisterBackend(AppCacheBackendImpl* backend_impl);
- AppCacheBackendImpl* GetBackend(int id) const {
- BackendMap::const_iterator it = backends_.find(id);
- return (it != backends_.end()) ? it->second : NULL;
- }
-
- AppCacheStorage* storage() const { return storage_.get(); }
-
- // Disables the exit-time deletion of session-only data.
- void set_force_keep_session_state() { force_keep_session_state_ = true; }
- bool force_keep_session_state() const { return force_keep_session_state_; }
-
- protected:
- friend class content::AppCacheServiceTest;
- friend class content::AppCacheStorageImplTest;
- FRIEND_TEST_ALL_PREFIXES(content::AppCacheServiceTest, ScheduleReinitialize);
-
- class AsyncHelper;
- class CanHandleOfflineHelper;
- class DeleteHelper;
- class DeleteOriginHelper;
- class GetInfoHelper;
- class CheckResponseHelper;
-
- typedef std::set<AsyncHelper*> PendingAsyncHelpers;
- typedef std::map<int, AppCacheBackendImpl*> BackendMap;
-
- void Reinitialize();
-
- base::FilePath cache_directory_;
- scoped_refptr<base::MessageLoopProxy> db_thread_;
- scoped_refptr<base::MessageLoopProxy> cache_thread_;
- AppCachePolicy* appcache_policy_;
- AppCacheQuotaClient* quota_client_;
- AppCacheExecutableHandlerFactory* handler_factory_;
- scoped_ptr<AppCacheStorage> storage_;
- scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_;
- scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_;
- PendingAsyncHelpers pending_helpers_;
- BackendMap backends_; // One 'backend' per child process.
- // Context for use during cache updates.
- net::URLRequestContext* request_context_;
- // If true, nothing (not even session-only data) should be deleted on exit.
- bool force_keep_session_state_;
- base::Time last_reinit_time_;
- base::TimeDelta next_reinit_delay_;
- base::OneShotTimer<AppCacheService> reinit_timer_;
- ObserverList<Observer> observers_;
-
- DISALLOW_COPY_AND_ASSIGN(AppCacheService);
+ virtual void DeleteAppCacheGroup(const GURL& manifest_url,
+ const net::CompletionCallback& callback) = 0;
};
} // namespace appcache
diff --git a/webkit/browser/appcache/appcache_service.cc b/webkit/browser/appcache/appcache_service_impl.cc
index f330519..3091a5c 100644
--- a/webkit/browser/appcache/appcache_service.cc
+++ b/webkit/browser/appcache/appcache_service_impl.cc
@@ -1,8 +1,8 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// 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 "webkit/browser/appcache/appcache_service.h"
+#include "webkit/browser/appcache/appcache_service_impl.h"
#include <functional>
@@ -21,6 +21,7 @@
#include "webkit/browser/appcache/appcache_policy.h"
#include "webkit/browser/appcache/appcache_quota_client.h"
#include "webkit/browser/appcache/appcache_response.h"
+#include "webkit/browser/appcache/appcache_service_impl.h"
#include "webkit/browser/appcache/appcache_storage_impl.h"
#include "webkit/browser/quota/special_storage_policy.h"
@@ -40,10 +41,10 @@ AppCacheInfoCollection::~AppCacheInfoCollection() {}
// AsyncHelper -------
-class AppCacheService::AsyncHelper
+class AppCacheServiceImpl::AsyncHelper
: public AppCacheStorage::Delegate {
public:
- AsyncHelper(AppCacheService* service,
+ AsyncHelper(AppCacheServiceImpl* service,
const net::CompletionCallback& callback)
: service_(service), callback_(callback) {
service_->pending_helpers_.insert(this);
@@ -67,11 +68,11 @@ class AppCacheService::AsyncHelper
callback_.Reset();
}
- AppCacheService* service_;
+ AppCacheServiceImpl* service_;
net::CompletionCallback callback_;
};
-void AppCacheService::AsyncHelper::Cancel() {
+void AppCacheServiceImpl::AsyncHelper::Cancel() {
if (!callback_.is_null()) {
callback_.Run(net::ERR_ABORTED);
callback_.Reset();
@@ -82,10 +83,10 @@ void AppCacheService::AsyncHelper::Cancel() {
// CanHandleOfflineHelper -------
-class AppCacheService::CanHandleOfflineHelper : AsyncHelper {
+class AppCacheServiceImpl::CanHandleOfflineHelper : AsyncHelper {
public:
CanHandleOfflineHelper(
- AppCacheService* service, const GURL& url,
+ AppCacheServiceImpl* service, const GURL& url,
const GURL& first_party, const net::CompletionCallback& callback)
: AsyncHelper(service, callback),
url_(url),
@@ -116,7 +117,7 @@ class AppCacheService::CanHandleOfflineHelper : AsyncHelper {
DISALLOW_COPY_AND_ASSIGN(CanHandleOfflineHelper);
};
-void AppCacheService::CanHandleOfflineHelper::OnMainResponseFound(
+void AppCacheServiceImpl::CanHandleOfflineHelper::OnMainResponseFound(
const GURL& url, const AppCacheEntry& entry,
const GURL& fallback_url, const AppCacheEntry& fallback_entry,
int64 cache_id, int64 group_id, const GURL& manifest_url) {
@@ -127,10 +128,10 @@ void AppCacheService::CanHandleOfflineHelper::OnMainResponseFound(
// DeleteHelper -------
-class AppCacheService::DeleteHelper : public AsyncHelper {
+class AppCacheServiceImpl::DeleteHelper : public AsyncHelper {
public:
DeleteHelper(
- AppCacheService* service, const GURL& manifest_url,
+ AppCacheServiceImpl* service, const GURL& manifest_url,
const net::CompletionCallback& callback)
: AsyncHelper(service, callback), manifest_url_(manifest_url) {
}
@@ -151,7 +152,7 @@ class AppCacheService::DeleteHelper : public AsyncHelper {
DISALLOW_COPY_AND_ASSIGN(DeleteHelper);
};
-void AppCacheService::DeleteHelper::OnGroupLoaded(
+void AppCacheServiceImpl::DeleteHelper::OnGroupLoaded(
appcache::AppCacheGroup* group, const GURL& manifest_url) {
if (group) {
group->set_being_deleted(true);
@@ -163,7 +164,7 @@ void AppCacheService::DeleteHelper::OnGroupLoaded(
}
}
-void AppCacheService::DeleteHelper::OnGroupMadeObsolete(
+void AppCacheServiceImpl::DeleteHelper::OnGroupMadeObsolete(
appcache::AppCacheGroup* group,
bool success,
int response_code) {
@@ -173,10 +174,10 @@ void AppCacheService::DeleteHelper::OnGroupMadeObsolete(
// DeleteOriginHelper -------
-class AppCacheService::DeleteOriginHelper : public AsyncHelper {
+class AppCacheServiceImpl::DeleteOriginHelper : public AsyncHelper {
public:
DeleteOriginHelper(
- AppCacheService* service, const GURL& origin,
+ AppCacheServiceImpl* service, const GURL& origin,
const net::CompletionCallback& callback)
: AsyncHelper(service, callback), origin_(origin),
num_caches_to_delete_(0), successes_(0), failures_(0) {
@@ -206,7 +207,7 @@ class AppCacheService::DeleteOriginHelper : public AsyncHelper {
DISALLOW_COPY_AND_ASSIGN(DeleteOriginHelper);
};
-void AppCacheService::DeleteOriginHelper::OnAllInfo(
+void AppCacheServiceImpl::DeleteOriginHelper::OnAllInfo(
AppCacheInfoCollection* collection) {
if (!collection) {
// Failed to get a listing.
@@ -235,7 +236,7 @@ void AppCacheService::DeleteOriginHelper::OnAllInfo(
}
}
-void AppCacheService::DeleteOriginHelper::OnGroupLoaded(
+void AppCacheServiceImpl::DeleteOriginHelper::OnGroupLoaded(
appcache::AppCacheGroup* group, const GURL& manifest_url) {
if (group) {
group->set_being_deleted(true);
@@ -246,14 +247,14 @@ void AppCacheService::DeleteOriginHelper::OnGroupLoaded(
}
}
-void AppCacheService::DeleteOriginHelper::OnGroupMadeObsolete(
+void AppCacheServiceImpl::DeleteOriginHelper::OnGroupMadeObsolete(
appcache::AppCacheGroup* group,
bool success,
int response_code) {
CacheCompleted(success);
}
-void AppCacheService::DeleteOriginHelper::CacheCompleted(bool success) {
+void AppCacheServiceImpl::DeleteOriginHelper::CacheCompleted(bool success) {
if (success)
++successes_;
else
@@ -268,10 +269,10 @@ void AppCacheService::DeleteOriginHelper::CacheCompleted(bool success) {
// GetInfoHelper -------
-class AppCacheService::GetInfoHelper : AsyncHelper {
+class AppCacheServiceImpl::GetInfoHelper : AsyncHelper {
public:
GetInfoHelper(
- AppCacheService* service, AppCacheInfoCollection* collection,
+ AppCacheServiceImpl* service, AppCacheInfoCollection* collection,
const net::CompletionCallback& callback)
: AsyncHelper(service, callback), collection_(collection) {
}
@@ -289,7 +290,7 @@ class AppCacheService::GetInfoHelper : AsyncHelper {
DISALLOW_COPY_AND_ASSIGN(GetInfoHelper);
};
-void AppCacheService::GetInfoHelper::OnAllInfo(
+void AppCacheServiceImpl::GetInfoHelper::OnAllInfo(
AppCacheInfoCollection* collection) {
if (collection)
collection->infos_by_origin.swap(collection_->infos_by_origin);
@@ -299,10 +300,10 @@ void AppCacheService::GetInfoHelper::OnAllInfo(
// CheckResponseHelper -------
-class AppCacheService::CheckResponseHelper : AsyncHelper {
+class AppCacheServiceImpl::CheckResponseHelper : AsyncHelper {
public:
CheckResponseHelper(
- AppCacheService* service, const GURL& manifest_url, int64 cache_id,
+ AppCacheServiceImpl* service, const GURL& manifest_url, int64 cache_id,
int64 response_id)
: AsyncHelper(service, net::CompletionCallback()),
manifest_url_(manifest_url),
@@ -348,7 +349,7 @@ class AppCacheService::CheckResponseHelper : AsyncHelper {
DISALLOW_COPY_AND_ASSIGN(CheckResponseHelper);
};
-void AppCacheService::CheckResponseHelper::OnGroupLoaded(
+void AppCacheServiceImpl::CheckResponseHelper::OnGroupLoaded(
AppCacheGroup* group, const GURL& manifest_url) {
DCHECK_EQ(manifest_url_, manifest_url);
if (!group || !group->newest_complete_cache() || group->is_being_deleted() ||
@@ -385,7 +386,7 @@ void AppCacheService::CheckResponseHelper::OnGroupLoaded(
base::Unretained(this)));
}
-void AppCacheService::CheckResponseHelper::OnReadInfoComplete(int result) {
+void AppCacheServiceImpl::CheckResponseHelper::OnReadInfoComplete(int result) {
if (result < 0) {
AppCacheHistograms::CountCheckResponseResult(
AppCacheHistograms::READ_HEADERS_ERROR);
@@ -404,7 +405,7 @@ void AppCacheService::CheckResponseHelper::OnReadInfoComplete(int result) {
base::Unretained(this)));
}
-void AppCacheService::CheckResponseHelper::OnReadDataComplete(int result) {
+void AppCacheServiceImpl::CheckResponseHelper::OnReadDataComplete(int result) {
if (result > 0) {
// Keep reading until we've read thru everything or failed to read.
amount_data_read_ += result;
@@ -438,9 +439,10 @@ AppCacheStorageReference::AppCacheStorageReference(
: storage_(storage.Pass()) {}
AppCacheStorageReference::~AppCacheStorageReference() {}
-// AppCacheService -------
+// AppCacheServiceImpl -------
-AppCacheService::AppCacheService(quota::QuotaManagerProxy* quota_manager_proxy)
+AppCacheServiceImpl::AppCacheServiceImpl(quota::QuotaManagerProxy*
+ quota_manager_proxy)
: appcache_policy_(NULL), quota_client_(NULL), handler_factory_(NULL),
quota_manager_proxy_(quota_manager_proxy),
request_context_(NULL),
@@ -451,7 +453,7 @@ AppCacheService::AppCacheService(quota::QuotaManagerProxy* quota_manager_proxy)
}
}
-AppCacheService::~AppCacheService() {
+AppCacheServiceImpl::~AppCacheServiceImpl() {
DCHECK(backends_.empty());
std::for_each(pending_helpers_.begin(),
pending_helpers_.end(),
@@ -465,7 +467,7 @@ AppCacheService::~AppCacheService() {
storage_.reset();
}
-void AppCacheService::Initialize(const base::FilePath& cache_directory,
+void AppCacheServiceImpl::Initialize(const base::FilePath& cache_directory,
base::MessageLoopProxy* db_thread,
base::MessageLoopProxy* cache_thread) {
DCHECK(!storage_.get());
@@ -477,7 +479,7 @@ void AppCacheService::Initialize(const base::FilePath& cache_directory,
storage_.reset(storage);
}
-void AppCacheService::ScheduleReinitialize() {
+void AppCacheServiceImpl::ScheduleReinitialize() {
if (reinit_timer_.IsRunning())
return;
@@ -497,14 +499,14 @@ void AppCacheService::ScheduleReinitialize() {
next_reinit_delay_ = kZeroDelta;
reinit_timer_.Start(FROM_HERE, next_reinit_delay_,
- this, &AppCacheService::Reinitialize);
+ this, &AppCacheServiceImpl::Reinitialize);
// Adjust the delay for next time.
base::TimeDelta increment = std::max(k30Seconds, next_reinit_delay_);
next_reinit_delay_ = std::min(next_reinit_delay_ + increment, kOneHour);
}
-void AppCacheService::Reinitialize() {
+void AppCacheServiceImpl::Reinitialize() {
AppCacheHistograms::CountReinitAttempt(!last_reinit_time_.is_null());
last_reinit_time_ = base::Time::Now();
@@ -518,7 +520,7 @@ void AppCacheService::Reinitialize() {
Initialize(cache_directory_, db_thread_, cache_thread_);
}
-void AppCacheService::CanHandleMainResourceOffline(
+void AppCacheServiceImpl::CanHandleMainResourceOffline(
const GURL& url,
const GURL& first_party,
const net::CompletionCallback& callback) {
@@ -527,7 +529,7 @@ void AppCacheService::CanHandleMainResourceOffline(
helper->Start();
}
-void AppCacheService::GetAllAppCacheInfo(
+void AppCacheServiceImpl::GetAllAppCacheInfo(
AppCacheInfoCollection* collection,
const net::CompletionCallback& callback) {
DCHECK(collection);
@@ -535,20 +537,20 @@ void AppCacheService::GetAllAppCacheInfo(
helper->Start();
}
-void AppCacheService::DeleteAppCacheGroup(
+void AppCacheServiceImpl::DeleteAppCacheGroup(
const GURL& manifest_url,
const net::CompletionCallback& callback) {
DeleteHelper* helper = new DeleteHelper(this, manifest_url, callback);
helper->Start();
}
-void AppCacheService::DeleteAppCachesForOrigin(
+void AppCacheServiceImpl::DeleteAppCachesForOrigin(
const GURL& origin, const net::CompletionCallback& callback) {
DeleteOriginHelper* helper = new DeleteOriginHelper(this, origin, callback);
helper->Start();
}
-void AppCacheService::CheckAppCacheResponse(const GURL& manifest_url,
+void AppCacheServiceImpl::CheckAppCacheResponse(const GURL& manifest_url,
int64 cache_id,
int64 response_id) {
CheckResponseHelper* helper = new CheckResponseHelper(
@@ -556,19 +558,19 @@ void AppCacheService::CheckAppCacheResponse(const GURL& manifest_url,
helper->Start();
}
-void AppCacheService::set_special_storage_policy(
+void AppCacheServiceImpl::set_special_storage_policy(
quota::SpecialStoragePolicy* policy) {
special_storage_policy_ = policy;
}
-void AppCacheService::RegisterBackend(
+void AppCacheServiceImpl::RegisterBackend(
AppCacheBackendImpl* backend_impl) {
DCHECK(backends_.find(backend_impl->process_id()) == backends_.end());
backends_.insert(
BackendMap::value_type(backend_impl->process_id(), backend_impl));
}
-void AppCacheService::UnregisterBackend(
+void AppCacheServiceImpl::UnregisterBackend(
AppCacheBackendImpl* backend_impl) {
backends_.erase(backend_impl->process_id());
}
diff --git a/webkit/browser/appcache/appcache_service_impl.h b/webkit/browser/appcache/appcache_service_impl.h
new file mode 100644
index 0000000..12524ec
--- /dev/null
+++ b/webkit/browser/appcache/appcache_service_impl.h
@@ -0,0 +1,227 @@
+// 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 WEBKIT_BROWSER_APPCACHE_APPCACHE_SERVICE_IMPL_H_
+#define WEBKIT_BROWSER_APPCACHE_APPCACHE_SERVICE_IMPL_H_
+
+#include <map>
+#include <set>
+
+#include "base/gtest_prod_util.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/observer_list.h"
+#include "base/time/time.h"
+#include "base/timer/timer.h"
+#include "net/base/completion_callback.h"
+#include "net/base/net_errors.h"
+#include "webkit/browser/appcache/appcache_service.h"
+#include "webkit/browser/quota/quota_manager_proxy.h"
+#include "webkit/browser/webkit_storage_browser_export.h"
+#include "webkit/common/appcache/appcache_interfaces.h"
+
+namespace net {
+class URLRequestContext;
+} // namespace net
+
+namespace base {
+class FilePath;
+class MessageLoopProxy;
+}
+
+namespace content {
+FORWARD_DECLARE_TEST(AppCacheServiceImplTest, ScheduleReinitialize);
+class AppCacheServiceImplTest;
+class AppCacheStorageImplTest;
+}
+
+namespace quota {
+class SpecialStoragePolicy;
+}
+
+namespace appcache {
+
+class AppCacheBackendImpl;
+class AppCacheExecutableHandlerFactory;
+class AppCacheQuotaClient;
+class AppCachePolicy;
+class AppCacheStorage;
+
+// Refcounted container to manage the lifetime of the old storage instance
+// during Reinitialization.
+class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheStorageReference
+ : public base::RefCounted<AppCacheStorageReference> {
+public:
+ AppCacheStorage* storage() const { return storage_.get(); }
+private:
+ friend class AppCacheServiceImpl;
+ friend class base::RefCounted<AppCacheStorageReference>;
+ AppCacheStorageReference(scoped_ptr<AppCacheStorage> storage);
+ ~AppCacheStorageReference();
+
+ scoped_ptr<AppCacheStorage> storage_;
+};
+
+// Class that manages the application cache service. Sends notifications
+// to many frontends. One instance per user-profile. Each instance has
+// exclusive access to its cache_directory on disk.
+class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheServiceImpl
+ : public AppCacheService {
+ public:
+
+ class WEBKIT_STORAGE_BROWSER_EXPORT Observer {
+ public:
+ // An observer method to inform consumers of reinitialzation. Managing
+ // the lifetime of the old storage instance is a delicate process.
+ // Consumers can keep the old disabled instance alive by hanging on to the
+ // ref provided.
+ virtual void OnServiceReinitialized(
+ AppCacheStorageReference* old_storage_ref) = 0;
+ virtual ~Observer() {}
+ };
+
+ // If not using quota management, the proxy may be NULL.
+ explicit AppCacheServiceImpl(quota::QuotaManagerProxy* quota_manager_proxy);
+ virtual ~AppCacheServiceImpl();
+
+ void Initialize(const base::FilePath& cache_directory,
+ base::MessageLoopProxy* db_thread,
+ base::MessageLoopProxy* cache_thread);
+
+ void AddObserver(Observer* observer) {
+ observers_.AddObserver(observer);
+ }
+
+ void RemoveObserver(Observer* observer) {
+ observers_.RemoveObserver(observer);
+ }
+
+ // For use in catastrophic failure modes to reboot the appcache system
+ // without relaunching the browser.
+ void ScheduleReinitialize();
+
+ // AppCacheService implementation:
+ virtual void CanHandleMainResourceOffline(
+ const GURL& url,
+ const GURL& first_party,
+ const net::CompletionCallback& callback) OVERRIDE;
+ virtual void GetAllAppCacheInfo(
+ AppCacheInfoCollection* collection,
+ const net::CompletionCallback& callback) OVERRIDE;
+ virtual void DeleteAppCacheGroup(
+ const GURL& manifest_url,
+ const net::CompletionCallback& callback) OVERRIDE;
+
+ // Deletes all appcaches for the origin, 'callback' is invoked upon
+ // completion. This method always completes asynchronously.
+ // (virtual for unit testing)
+ virtual void DeleteAppCachesForOrigin(
+ const GURL& origin, const net::CompletionCallback& callback);
+
+ // Checks the integrity of 'response_id' by reading the headers and data.
+ // If it cannot be read, the cache group for 'manifest_url' is deleted.
+ void CheckAppCacheResponse(const GURL& manifest_url, int64 cache_id,
+ int64 response_id);
+
+ // Context for use during cache updates, should only be accessed
+ // on the IO thread. We do NOT add a reference to the request context,
+ // it is the callers responsibility to ensure that the pointer
+ // remains valid while set.
+ net::URLRequestContext* request_context() const { return request_context_; }
+ void set_request_context(net::URLRequestContext* context) {
+ request_context_ = context;
+ }
+
+ // The appcache policy, may be null, in which case access is always allowed.
+ // The service does NOT assume ownership of the policy, it is the callers
+ // responsibility to ensure that the pointer remains valid while set.
+ AppCachePolicy* appcache_policy() const { return appcache_policy_; }
+ void set_appcache_policy(AppCachePolicy* policy) {
+ appcache_policy_ = policy;
+ }
+
+ // The factory may be null, in which case invocations of exe handlers
+ // will result in an error response.
+ // The service does NOT assume ownership of the factory, it is the callers
+ // responsibility to ensure that the pointer remains valid while set.
+ AppCacheExecutableHandlerFactory* handler_factory() const {
+ return handler_factory_;
+ }
+ void set_handler_factory(
+ AppCacheExecutableHandlerFactory* factory) {
+ handler_factory_ = factory;
+ }
+
+ quota::SpecialStoragePolicy* special_storage_policy() const {
+ return special_storage_policy_.get();
+ }
+ void set_special_storage_policy(quota::SpecialStoragePolicy* policy);
+
+ quota::QuotaManagerProxy* quota_manager_proxy() const {
+ return quota_manager_proxy_.get();
+ }
+
+ AppCacheQuotaClient* quota_client() const {
+ return quota_client_;
+ }
+
+ // Each child process in chrome uses a distinct backend instance.
+ // See chrome/browser/AppCacheDispatcherHost.
+ void RegisterBackend(AppCacheBackendImpl* backend_impl);
+ void UnregisterBackend(AppCacheBackendImpl* backend_impl);
+ AppCacheBackendImpl* GetBackend(int id) const {
+ BackendMap::const_iterator it = backends_.find(id);
+ return (it != backends_.end()) ? it->second : NULL;
+ }
+
+ AppCacheStorage* storage() const { return storage_.get(); }
+
+ // Disables the exit-time deletion of session-only data.
+ void set_force_keep_session_state() { force_keep_session_state_ = true; }
+ bool force_keep_session_state() const { return force_keep_session_state_; }
+
+ protected:
+ friend class content::AppCacheServiceImplTest;
+ friend class content::AppCacheStorageImplTest;
+ FRIEND_TEST_ALL_PREFIXES(content::AppCacheServiceImplTest,
+ ScheduleReinitialize);
+
+ class AsyncHelper;
+ class CanHandleOfflineHelper;
+ class DeleteHelper;
+ class DeleteOriginHelper;
+ class GetInfoHelper;
+ class CheckResponseHelper;
+
+ typedef std::set<AsyncHelper*> PendingAsyncHelpers;
+ typedef std::map<int, AppCacheBackendImpl*> BackendMap;
+
+ void Reinitialize();
+
+ base::FilePath cache_directory_;
+ scoped_refptr<base::MessageLoopProxy> db_thread_;
+ scoped_refptr<base::MessageLoopProxy> cache_thread_;
+ AppCachePolicy* appcache_policy_;
+ AppCacheQuotaClient* quota_client_;
+ AppCacheExecutableHandlerFactory* handler_factory_;
+ scoped_ptr<AppCacheStorage> storage_;
+ scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_;
+ scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_;
+ PendingAsyncHelpers pending_helpers_;
+ BackendMap backends_; // One 'backend' per child process.
+ // Context for use during cache updates.
+ net::URLRequestContext* request_context_;
+ // If true, nothing (not even session-only data) should be deleted on exit.
+ bool force_keep_session_state_;
+ base::Time last_reinit_time_;
+ base::TimeDelta next_reinit_delay_;
+ base::OneShotTimer<AppCacheServiceImpl> reinit_timer_;
+ ObserverList<Observer> observers_;
+
+ DISALLOW_COPY_AND_ASSIGN(AppCacheServiceImpl);
+};
+
+} // namespace appcache
+
+#endif // WEBKIT_BROWSER_APPCACHE_APPCACHE_SERVICE_IMPL_H_
diff --git a/webkit/browser/appcache/appcache_storage.cc b/webkit/browser/appcache/appcache_storage.cc
index 3f6e09c..ce4f01e 100644
--- a/webkit/browser/appcache/appcache_storage.cc
+++ b/webkit/browser/appcache/appcache_storage.cc
@@ -8,7 +8,7 @@
#include "base/bind_helpers.h"
#include "base/stl_util.h"
#include "webkit/browser/appcache/appcache_response.h"
-#include "webkit/browser/appcache/appcache_service.h"
+#include "webkit/browser/appcache/appcache_service_impl.h"
#include "webkit/browser/quota/quota_client.h"
#include "webkit/browser/quota/quota_manager_proxy.h"
@@ -17,7 +17,7 @@ namespace appcache {
// static
const int64 AppCacheStorage::kUnitializedId = -1;
-AppCacheStorage::AppCacheStorage(AppCacheService* service)
+AppCacheStorage::AppCacheStorage(AppCacheServiceImpl* service)
: last_cache_id_(kUnitializedId), last_group_id_(kUnitializedId),
last_response_id_(kUnitializedId), service_(service) {
}
diff --git a/webkit/browser/appcache/appcache_storage.h b/webkit/browser/appcache/appcache_storage.h
index caf68e2..a2c66eb 100644
--- a/webkit/browser/appcache/appcache_storage.h
+++ b/webkit/browser/appcache/appcache_storage.h
@@ -34,7 +34,7 @@ class AppCacheEntry;
class AppCacheGroup;
class AppCacheResponseReader;
class AppCacheResponseWriter;
-class AppCacheService;
+class AppCacheServiceImpl;
struct AppCacheInfoCollection;
struct HttpResponseInfoIOBuffer;
@@ -83,7 +83,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheStorage {
virtual ~Delegate() {}
};
- explicit AppCacheStorage(AppCacheService* service);
+ explicit AppCacheStorage(AppCacheServiceImpl* service);
virtual ~AppCacheStorage();
// Schedules a task to retrieve basic info about all groups and caches
@@ -199,7 +199,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheStorage {
const UsageMap* usage_map() { return &usage_map_; }
// Simple ptr back to the service object that owns us.
- AppCacheService* service() { return service_; }
+ AppCacheServiceImpl* service() { return service_; }
protected:
friend class content::AppCacheQuotaClientTest;
@@ -312,7 +312,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheStorage {
UsageMap usage_map_; // maps origin to usage
AppCacheWorkingSet working_set_;
- AppCacheService* service_;
+ AppCacheServiceImpl* service_;
DelegateReferenceMap delegate_references_;
PendingResponseInfoLoads pending_info_loads_;
diff --git a/webkit/browser/appcache/appcache_storage_impl.cc b/webkit/browser/appcache/appcache_storage_impl.cc
index 1b0c039..96c0b67 100644
--- a/webkit/browser/appcache/appcache_storage_impl.cc
+++ b/webkit/browser/appcache/appcache_storage_impl.cc
@@ -27,7 +27,7 @@
#include "webkit/browser/appcache/appcache_histograms.h"
#include "webkit/browser/appcache/appcache_quota_client.h"
#include "webkit/browser/appcache/appcache_response.h"
-#include "webkit/browser/appcache/appcache_service.h"
+#include "webkit/browser/appcache/appcache_service_impl.h"
#include "webkit/browser/quota/quota_client.h"
#include "webkit/browser/quota/quota_manager.h"
#include "webkit/browser/quota/quota_manager_proxy.h"
@@ -1311,7 +1311,7 @@ void AppCacheStorageImpl::UpdateGroupLastAccessTimeTask::Run() {
// AppCacheStorageImpl ---------------------------------------------------
-AppCacheStorageImpl::AppCacheStorageImpl(AppCacheService* service)
+AppCacheStorageImpl::AppCacheStorageImpl(AppCacheServiceImpl* service)
: AppCacheStorage(service),
is_incognito_(false),
is_response_deletion_scheduled_(false),
diff --git a/webkit/browser/appcache/appcache_storage_impl.h b/webkit/browser/appcache/appcache_storage_impl.h
index 38f71b5..a5103a6 100644
--- a/webkit/browser/appcache/appcache_storage_impl.h
+++ b/webkit/browser/appcache/appcache_storage_impl.h
@@ -29,7 +29,7 @@ namespace appcache {
class AppCacheStorageImpl : public AppCacheStorage {
public:
- explicit AppCacheStorageImpl(AppCacheService* service);
+ explicit AppCacheStorageImpl(AppCacheServiceImpl* service);
virtual ~AppCacheStorageImpl();
void Initialize(const base::FilePath& cache_directory,
diff --git a/webkit/browser/appcache/appcache_update_job.cc b/webkit/browser/appcache/appcache_update_job.cc
index 6589e3a..16ee1c9 100644
--- a/webkit/browser/appcache/appcache_update_job.cc
+++ b/webkit/browser/appcache/appcache_update_job.cc
@@ -340,7 +340,7 @@ bool AppCacheUpdateJob::URLFetcher::MaybeRetryRequest() {
return true;
}
-AppCacheUpdateJob::AppCacheUpdateJob(AppCacheService* service,
+AppCacheUpdateJob::AppCacheUpdateJob(AppCacheServiceImpl* service,
AppCacheGroup* group)
: service_(service),
manifest_url_(group->manifest_url()),
@@ -1042,7 +1042,7 @@ void AppCacheUpdateJob::CheckIfManifestChanged() {
// http://code.google.com/p/chromium/issues/detail?id=95101
if (service_->storage() == storage_) {
// Use a local variable because service_ is reset in HandleCacheFailure.
- AppCacheService* service = service_;
+ AppCacheServiceImpl* service = service_;
HandleCacheFailure(
ErrorDetails("Manifest entry not found in existing cache",
UNKNOWN_ERROR,
diff --git a/webkit/browser/appcache/appcache_update_job.h b/webkit/browser/appcache/appcache_update_job.h
index 2287729..cf96409 100644
--- a/webkit/browser/appcache/appcache_update_job.h
+++ b/webkit/browser/appcache/appcache_update_job.h
@@ -21,7 +21,7 @@
#include "webkit/browser/appcache/appcache.h"
#include "webkit/browser/appcache/appcache_host.h"
#include "webkit/browser/appcache/appcache_response.h"
-#include "webkit/browser/appcache/appcache_service.h"
+#include "webkit/browser/appcache/appcache_service_impl.h"
#include "webkit/browser/appcache/appcache_storage.h"
#include "webkit/browser/webkit_storage_browser_export.h"
#include "webkit/common/appcache/appcache_interfaces.h"
@@ -40,7 +40,7 @@ class HostNotifier;
class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheUpdateJob
: public AppCacheStorage::Delegate,
public AppCacheHost::Observer,
- public AppCacheService::Observer {
+ public AppCacheServiceImpl::Observer {
public:
// Used for uma stats only for now, so new values are append only.
enum ResultType {
@@ -49,7 +49,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheUpdateJob
NUM_UPDATE_JOB_RESULT_TYPES
};
- AppCacheUpdateJob(AppCacheService* service, AppCacheGroup* group);
+ AppCacheUpdateJob(AppCacheServiceImpl* service, AppCacheGroup* group);
virtual ~AppCacheUpdateJob();
// Triggers the update process or adds more info if this update is already
@@ -183,7 +183,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheUpdateJob
virtual void OnCacheSelectionComplete(AppCacheHost* host) OVERRIDE {} // N/A
virtual void OnDestructionImminent(AppCacheHost* host) OVERRIDE;
- // Methods for AppCacheService::Observer.
+ // Methods for AppCacheServiceImpl::Observer.
virtual void OnServiceReinitialized(
AppCacheStorageReference* old_storage) OVERRIDE;
@@ -269,7 +269,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheUpdateJob
bool IsTerminating() { return internal_state_ >= REFETCH_MANIFEST ||
stored_state_ != UNSTORED; }
- AppCacheService* service_;
+ AppCacheServiceImpl* service_;
const GURL manifest_url_; // here for easier access
// Defined prior to refs to AppCaches and Groups because destruction
diff --git a/webkit/browser/appcache/appcache_url_request_job.cc b/webkit/browser/appcache/appcache_url_request_job.cc
index afef477..088dafa 100644
--- a/webkit/browser/appcache/appcache_url_request_job.cc
+++ b/webkit/browser/appcache/appcache_url_request_job.cc
@@ -25,7 +25,7 @@
#include "webkit/browser/appcache/appcache_group.h"
#include "webkit/browser/appcache/appcache_histograms.h"
#include "webkit/browser/appcache/appcache_host.h"
-#include "webkit/browser/appcache/appcache_service.h"
+#include "webkit/browser/appcache/appcache_service_impl.h"
namespace appcache {
diff --git a/webkit/storage_browser.gyp b/webkit/storage_browser.gyp
index f6eda76..6f510d9 100644
--- a/webkit/storage_browser.gyp
+++ b/webkit/storage_browser.gyp
@@ -50,8 +50,9 @@
'browser/appcache/appcache_request_handler.h',
'browser/appcache/appcache_response.cc',
'browser/appcache/appcache_response.h',
- 'browser/appcache/appcache_service.cc',
'browser/appcache/appcache_service.h',
+ 'browser/appcache/appcache_service_impl.cc',
+ 'browser/appcache/appcache_service_impl.h',
'browser/appcache/appcache_storage.cc',
'browser/appcache/appcache_storage.h',
'browser/appcache/appcache_storage_impl.cc',