summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authormichaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-01 22:30:30 +0000
committermichaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-01 22:30:30 +0000
commit23f1ef1a445a53bcefc8ddab9f4184b1db7321c5 (patch)
treec9f17a33025ed5b5c5dee76a7b4fef9104e9a995 /chrome
parente143c823ce66af5a83a9a17b6f5938eb16e49392 (diff)
downloadchromium_src-23f1ef1a445a53bcefc8ddab9f4184b1db7321c5.zip
chromium_src-23f1ef1a445a53bcefc8ddab9f4184b1db7321c5.tar.gz
chromium_src-23f1ef1a445a53bcefc8ddab9f4184b1db7321c5.tar.bz2
Plumb request interception into the appcache library for both chrome and test_shell.
AppCache library: * Added AppCacheInterceptor, which is derived from URLRequest::Interceptor. Chrome: * Each UserProfile instantiates a ChromeAppCacheService, which is derived from an appcache library class. * Each ChromeURLRequestContext associated with that profile has a reference to that instance. * ResourceDispatcherHost pokes AppCacheInterceptor when initiating URLRequests and when returning the response head. TestShell: * Added SimpleAppCacheSystem which bundles together appcache lib components for use in a single process with an UI and IO thread. * TestShellWebKit instantiates and initializes an instance of the above, aimed at at temp directory that will get cleaned up when the test run is over. * SimpleResourceLoaderBridge pokes the system when initiating URLRequests and when returning the response head. TEST=none, although many existing tests exercise this stuff BUG=none Review URL: http://codereview.chromium.org/173406 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25099 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/automation/automation_profile_impl.h3
-rw-r--r--chrome/browser/net/chrome_url_request_context.cc3
-rw-r--r--chrome/browser/net/chrome_url_request_context.h9
-rw-r--r--chrome/browser/profile.cc32
-rw-r--r--chrome/browser/profile.h8
-rw-r--r--chrome/browser/renderer_host/resource_dispatcher_host.cc15
-rw-r--r--chrome/browser/renderer_host/resource_message_filter.cc5
-rw-r--r--chrome/chrome.gyp1
-rw-r--r--chrome/common/appcache/appcache_backend_proxy.cc7
-rw-r--r--chrome/common/appcache/appcache_dispatcher_host.cc85
-rw-r--r--chrome/common/appcache/appcache_dispatcher_host.h20
-rw-r--r--chrome/common/appcache/appcache_frontend_proxy.cc1
-rw-r--r--chrome/common/appcache/chrome_appcache_service.h67
-rw-r--r--chrome/common/chrome_constants.cc1
-rw-r--r--chrome/common/chrome_constants.h1
-rw-r--r--chrome/test/testing_profile.h5
16 files changed, 231 insertions, 32 deletions
diff --git a/chrome/browser/automation/automation_profile_impl.h b/chrome/browser/automation/automation_profile_impl.h
index c0f2592..7a22fc3 100644
--- a/chrome/browser/automation/automation_profile_impl.h
+++ b/chrome/browser/automation/automation_profile_impl.h
@@ -45,6 +45,9 @@ class AutomationProfileImpl : public Profile {
virtual Profile* GetOriginalProfile() {
return original_profile_->GetOriginalProfile();
}
+ virtual ChromeAppCacheService* GetAppCacheService() {
+ return original_profile_->GetAppCacheService();
+ }
virtual VisitedLinkMaster* GetVisitedLinkMaster() {
return original_profile_->GetVisitedLinkMaster();
}
diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context.cc
index 65671d4..0bc5572 100644
--- a/chrome/browser/net/chrome_url_request_context.cc
+++ b/chrome/browser/net/chrome_url_request_context.cc
@@ -354,6 +354,8 @@ ChromeURLRequestContext::ChromeURLRequestContext(Profile* profile)
}
ssl_config_service_ = profile->GetSSLConfigService();
+
+ appcache_service_ = profile->GetAppCacheService();
}
ChromeURLRequestContext::ChromeURLRequestContext(
@@ -378,6 +380,7 @@ ChromeURLRequestContext::ChromeURLRequestContext(
blacklist_ = other->blacklist_;
is_media_ = other->is_media_;
is_off_the_record_ = other->is_off_the_record_;
+ appcache_service_ = other->appcache_service_;
}
// NotificationObserver implementation.
diff --git a/chrome/browser/net/chrome_url_request_context.h b/chrome/browser/net/chrome_url_request_context.h
index f4baea6..d0303d7 100644
--- a/chrome/browser/net/chrome_url_request_context.h
+++ b/chrome/browser/net/chrome_url_request_context.h
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "base/file_path.h"
+#include "chrome/common/appcache/chrome_appcache_service.h"
#include "chrome/common/net/cookie_monster_sqlite.h"
#include "chrome/common/notification_registrar.h"
#include "chrome/common/pref_service.h"
@@ -65,6 +66,12 @@ class ChromeURLRequestContext : public URLRequestContext,
return user_script_dir_path_;
}
+ // Gets the appcache service to be used for requests in this context.
+ // May be NULL if requests for this context aren't subject to appcaching.
+ ChromeAppCacheService* appcache_service() const {
+ return appcache_service_.get();
+ }
+
virtual const std::string& GetUserAgent(const GURL& url) const;
virtual bool InterceptCookie(const URLRequest* request, std::string* cookie);
@@ -118,6 +125,8 @@ class ChromeURLRequestContext : public URLRequestContext,
// Path to the directory user scripts are stored in.
FilePath user_script_dir_path_;
+ scoped_refptr<ChromeAppCacheService> appcache_service_;
+
scoped_ptr<SQLitePersistentCookieStore> cookie_db_;
PrefService* prefs_;
const Blacklist* blacklist_;
diff --git a/chrome/browser/profile.cc b/chrome/browser/profile.cc
index fb92549..1aa04e8 100644
--- a/chrome/browser/profile.cc
+++ b/chrome/browser/profile.cc
@@ -39,6 +39,7 @@
#include "chrome/browser/visitedlink_master.h"
#include "chrome/browser/visitedlink_event_listener.h"
#include "chrome/browser/webdata/web_data_service.h"
+#include "chrome/common/appcache/chrome_appcache_service.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
@@ -115,6 +116,16 @@ static void CleanupRequestContext(ChromeURLRequestContext* context) {
}
}
+static void CleanupAppCacheService(ChromeAppCacheService* service) {
+ if (service) {
+ MessageLoop* io_thread = ChromeThread::GetMessageLoop(ChromeThread::IO);
+ if (io_thread)
+ io_thread->ReleaseSoon(FROM_HERE, service);
+ else
+ service->Release();
+ }
+}
+
// static
void Profile::RegisterUserPrefs(PrefService* prefs) {
prefs->RegisterBooleanPref(prefs::kSearchSuggestEnabled, true);
@@ -187,6 +198,7 @@ class OffTheRecordProfileImpl : public Profile,
virtual ~OffTheRecordProfileImpl() {
CleanupRequestContext(request_context_);
CleanupRequestContext(extensions_request_context_);
+ CleanupAppCacheService(appcache_service_.release());
}
virtual FilePath GetPath() { return profile_->GetPath(); }
@@ -208,6 +220,14 @@ class OffTheRecordProfileImpl : public Profile,
return profile_;
}
+ virtual ChromeAppCacheService* GetAppCacheService() {
+ if (!appcache_service_.get()) {
+ appcache_service_ = new ChromeAppCacheService();
+ appcache_service_->InitializeOnUIThread(GetPath(), true);
+ }
+ return appcache_service_.get();
+ }
+
virtual VisitedLinkMaster* GetVisitedLinkMaster() {
// We don't provide access to the VisitedLinkMaster when we're OffTheRecord
// because we don't want to leak the sites that the user has visited before.
@@ -484,6 +504,9 @@ class OffTheRecordProfileImpl : public Profile,
ChromeURLRequestContext* extensions_request_context_;
+ // Use a seperate appcache service for OTR.
+ scoped_refptr<ChromeAppCacheService> appcache_service_;
+
// The download manager that only stores downloaded items in memory.
scoped_refptr<DownloadManager> download_manager_;
@@ -700,6 +723,7 @@ ProfileImpl::~ProfileImpl() {
CleanupRequestContext(request_context_);
CleanupRequestContext(media_request_context_);
CleanupRequestContext(extensions_request_context_);
+ CleanupAppCacheService(appcache_service_.release());
// When the request contexts are gone, the blacklist wont be needed anymore.
delete blacklist_;
@@ -749,6 +773,14 @@ Profile* ProfileImpl::GetOriginalProfile() {
return this;
}
+ChromeAppCacheService* ProfileImpl::GetAppCacheService() {
+ if (!appcache_service_.get()) {
+ appcache_service_ = new ChromeAppCacheService();
+ appcache_service_->InitializeOnUIThread(GetPath(), false);
+ }
+ return appcache_service_.get();
+}
+
VisitedLinkMaster* ProfileImpl::GetVisitedLinkMaster() {
if (!visited_link_master_.get()) {
scoped_ptr<VisitedLinkMaster> visited_links(
diff --git a/chrome/browser/profile.h b/chrome/browser/profile.h
index 36679a7..83ae64c 100644
--- a/chrome/browser/profile.h
+++ b/chrome/browser/profile.h
@@ -25,6 +25,7 @@ class SSLConfigService;
class Blacklist;
class BookmarkModel;
class BrowserThemeProvider;
+class ChromeAppCacheService;
class ChromeURLRequestContext;
class DownloadManager;
class Extension;
@@ -117,6 +118,11 @@ class Profile {
// profile is not off the record.
virtual Profile* GetOriginalProfile() = 0;
+ // Retrieves a pointer to the AppCacheService for this profile.
+ // Chrome request contexts associated with this profile also have
+ // a reference to this instance.
+ virtual ChromeAppCacheService* GetAppCacheService() = 0;
+
// Retrieves a pointer to the VisitedLinkMaster associated with this
// profile. The VisitedLinkMaster is lazily created the first time
// that this method is called.
@@ -359,6 +365,7 @@ class ProfileImpl : public Profile,
virtual Profile* GetOffTheRecordProfile();
virtual void DestroyOffTheRecordProfile();
virtual Profile* GetOriginalProfile();
+ virtual ChromeAppCacheService* GetAppCacheService();
virtual VisitedLinkMaster* GetVisitedLinkMaster();
virtual UserScriptMaster* GetUserScriptMaster();
virtual SSLHostState* GetSSLHostState();
@@ -444,6 +451,7 @@ class ProfileImpl : public Profile,
FilePath path_;
FilePath base_cache_path_;
+ scoped_refptr<ChromeAppCacheService> appcache_service_;
scoped_ptr<VisitedLinkEventListener> visited_link_event_listener_;
scoped_ptr<VisitedLinkMaster> visited_link_master_;
scoped_refptr<ExtensionsService> extensions_service_;
diff --git a/chrome/browser/renderer_host/resource_dispatcher_host.cc b/chrome/browser/renderer_host/resource_dispatcher_host.cc
index 7d42929..669118b 100644
--- a/chrome/browser/renderer_host/resource_dispatcher_host.cc
+++ b/chrome/browser/renderer_host/resource_dispatcher_host.cc
@@ -54,6 +54,7 @@
#include "net/base/ssl_cert_request_info.h"
#include "net/url_request/url_request.h"
#include "net/url_request/url_request_context.h"
+#include "webkit/appcache/appcache_interceptor.h"
#include "webkit/appcache/appcache_interfaces.h"
// TODO(port): Move these includes to the above section when porting is done.
@@ -239,9 +240,11 @@ void PopulateResourceResponse(URLRequest* request,
request->GetCharset(&response->response_head.charset);
response->response_head.filter_policy = filter_policy;
response->response_head.content_length = request->GetExpectedContentSize();
- response->response_head.appcache_id = appcache::kNoCacheId;
- response->response_head.appcache_manifest_url = GURL();
request->GetMimeType(&response->response_head.mime_type);
+ appcache::AppCacheInterceptor::GetExtraResponseInfo(
+ request,
+ &response->response_head.appcache_id,
+ &response->response_head.appcache_manifest_url);
}
} // namespace
@@ -294,6 +297,9 @@ void ResourceDispatcherHost::Initialize() {
DCHECK(MessageLoop::current() == ui_loop_);
download_file_manager_->Initialize();
safe_browsing_->Initialize(io_loop_);
+ io_loop_->PostTask(
+ FROM_HERE,
+ NewRunnableFunction(&appcache::AppCacheInterceptor::EnsureRegistered));
}
void ResourceDispatcherHost::Shutdown() {
@@ -582,6 +588,11 @@ void ResourceDispatcherHost::BeginRequest(
chrome_browser_net::SetOriginProcessUniqueIDForRequest(
request_data.origin_child_id, request);
+ // Have the appcache associate its extra info with the request.
+ appcache::AppCacheInterceptor::SetExtraRequestInfo(
+ request, context ? context->appcache_service() : NULL, child_id,
+ request_data.appcache_host_id, request_data.resource_type);
+
BeginRequestInternal(request);
}
diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc
index 61debd5..b211f67 100644
--- a/chrome/browser/renderer_host/resource_message_filter.cc
+++ b/chrome/browser/renderer_host/resource_message_filter.cc
@@ -156,7 +156,8 @@ ResourceMessageFilter::ResourceMessageFilter(
profile_(profile),
render_widget_helper_(render_widget_helper),
audio_renderer_host_(audio_renderer_host),
- appcache_dispatcher_host_(new AppCacheDispatcherHost),
+ appcache_dispatcher_host_(
+ new AppCacheDispatcherHost(profile->GetAppCacheService())),
ALLOW_THIS_IN_INITIALIZER_LIST(dom_storage_dispatcher_host_(
new DOMStorageDispatcherHost(this, profile->GetWebKitContext(),
resource_dispatcher_host->webkit_thread()))),
@@ -193,7 +194,7 @@ ResourceMessageFilter::~ResourceMessageFilter() {
void ResourceMessageFilter::Init() {
render_widget_helper_->Init(id(), resource_dispatcher_host_);
- appcache_dispatcher_host_->Initialize(this);
+ appcache_dispatcher_host_->Initialize(this, id());
}
// Called on the IPC thread:
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index e4bbe6f..47a521b 100644
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -423,6 +423,7 @@
'common/appcache/appcache_dispatcher_host.h',
'common/appcache/appcache_frontend_proxy.cc',
'common/appcache/appcache_frontend_proxy.h',
+ 'common/appcache/chrome_appcache_service.h',
'common/automation_constants.cc',
'common/automation_constants.h',
'common/bindings_policy.h',
diff --git a/chrome/common/appcache/appcache_backend_proxy.cc b/chrome/common/appcache/appcache_backend_proxy.cc
index 14b81f1..25c77f7 100644
--- a/chrome/common/appcache/appcache_backend_proxy.cc
+++ b/chrome/common/appcache/appcache_backend_proxy.cc
@@ -34,20 +34,19 @@ void AppCacheBackendProxy::MarkAsForeignEntry(
}
appcache::Status AppCacheBackendProxy::GetStatus(int host_id) {
- appcache::Status status;
+ appcache::Status status = appcache::UNCACHED;
sender_->Send(new AppCacheMsg_GetStatus(host_id, &status));
return status;
}
bool AppCacheBackendProxy::StartUpdate(int host_id) {
- bool result;
+ bool result = false;
sender_->Send(new AppCacheMsg_StartUpdate(host_id, &result));
return result;
}
bool AppCacheBackendProxy::SwapCache(int host_id) {
- bool result;
+ bool result = false;
sender_->Send(new AppCacheMsg_SwapCache(host_id, &result));
return result;
}
-
diff --git a/chrome/common/appcache/appcache_dispatcher_host.cc b/chrome/common/appcache/appcache_dispatcher_host.cc
index b71f2d9..ee0265f 100644
--- a/chrome/common/appcache/appcache_dispatcher_host.cc
+++ b/chrome/common/appcache/appcache_dispatcher_host.cc
@@ -4,12 +4,28 @@
#include "chrome/common/appcache/appcache_dispatcher_host.h"
+#include "chrome/common/appcache/chrome_appcache_service.h"
#include "chrome/common/render_messages.h"
-void AppCacheDispatcherHost::Initialize(IPC::Message::Sender* sender) {
+AppCacheDispatcherHost::AppCacheDispatcherHost(
+ ChromeAppCacheService* appcache_service)
+ : appcache_service_(appcache_service) {
+}
+
+void AppCacheDispatcherHost::Initialize(IPC::Message::Sender* sender,
+ int process_id) {
DCHECK(sender);
frontend_proxy_.set_sender(sender);
- backend_impl_.Initialize(NULL, &frontend_proxy_);
+ if (appcache_service_.get()) {
+ backend_impl_.Initialize(
+ appcache_service_.get(), &frontend_proxy_, process_id);
+ get_status_callback_.reset(
+ NewCallback(this, &AppCacheDispatcherHost::GetStatusCallback));
+ start_update_callback_.reset(
+ NewCallback(this, &AppCacheDispatcherHost::StartUpdateCallback));
+ swap_cache_callback_.reset(
+ NewCallback(this, &AppCacheDispatcherHost::SwapCacheCallback));
+ }
}
bool AppCacheDispatcherHost::OnMessageReceived(const IPC::Message& msg,
@@ -31,49 +47,78 @@ bool AppCacheDispatcherHost::OnMessageReceived(const IPC::Message& msg,
}
void AppCacheDispatcherHost::OnRegisterHost(int host_id) {
- backend_impl_.RegisterHost(host_id);
+ if (appcache_service_.get())
+ backend_impl_.RegisterHost(host_id);
}
void AppCacheDispatcherHost::OnUnregisterHost(int host_id) {
- backend_impl_.UnregisterHost(host_id);
+ if (appcache_service_.get())
+ backend_impl_.UnregisterHost(host_id);
}
void AppCacheDispatcherHost::OnSelectCache(
int host_id, const GURL& document_url,
int64 cache_document_was_loaded_from,
const GURL& opt_manifest_url) {
- backend_impl_.SelectCache(host_id, document_url,
- cache_document_was_loaded_from,
- opt_manifest_url);
+ if (appcache_service_.get())
+ backend_impl_.SelectCache(host_id, document_url,
+ cache_document_was_loaded_from,
+ opt_manifest_url);
+ else
+ frontend_proxy_.OnCacheSelected(
+ host_id, appcache::kNoCacheId, appcache::UNCACHED);
}
void AppCacheDispatcherHost::OnMarkAsForeignEntry(
int host_id, const GURL& document_url,
int64 cache_document_was_loaded_from) {
- backend_impl_.MarkAsForeignEntry(host_id, document_url,
- cache_document_was_loaded_from);
+ if (appcache_service_.get())
+ backend_impl_.MarkAsForeignEntry(host_id, document_url,
+ cache_document_was_loaded_from);
}
void AppCacheDispatcherHost::OnGetStatus(int host_id,
IPC::Message* reply_msg) {
- // TODO(michaeln): Handle the case where cache selection is not yet complete.
- appcache::Status status = backend_impl_.GetStatus(host_id);
- AppCacheMsg_GetStatus::WriteReplyParams(reply_msg, status);
- frontend_proxy_.sender()->Send(reply_msg);
+ if (appcache_service_.get())
+ backend_impl_.GetStatusWithCallback(
+ host_id, get_status_callback_.get(), reply_msg);
+ else
+ GetStatusCallback(appcache::UNCACHED, reply_msg);
}
void AppCacheDispatcherHost::OnStartUpdate(int host_id,
IPC::Message* reply_msg) {
- // TODO(michaeln): Handle the case where cache selection is not yet complete.
- bool success = backend_impl_.StartUpdate(host_id);
- AppCacheMsg_StartUpdate::WriteReplyParams(reply_msg, success);
- frontend_proxy_.sender()->Send(reply_msg);
+ if (appcache_service_.get())
+ backend_impl_.StartUpdateWithCallback(
+ host_id, start_update_callback_.get(), reply_msg);
+ else
+ StartUpdateCallback(false, reply_msg);
}
void AppCacheDispatcherHost::OnSwapCache(int host_id,
IPC::Message* reply_msg) {
- // TODO(michaeln): Handle the case where cache selection is not yet complete.
- bool success = backend_impl_.SwapCache(host_id);
- AppCacheMsg_SwapCache::WriteReplyParams(reply_msg, success);
+ if (appcache_service_.get())
+ backend_impl_.SwapCacheWithCallback(
+ host_id, swap_cache_callback_.get(), reply_msg);
+ else
+ SwapCacheCallback(false, reply_msg);
+}
+
+void AppCacheDispatcherHost::GetStatusCallback(
+ appcache::Status status, void* param) {
+ IPC::Message* reply_msg = reinterpret_cast<IPC::Message*>(param);
+ AppCacheMsg_GetStatus::WriteReplyParams(reply_msg, status);
+ frontend_proxy_.sender()->Send(reply_msg);
+}
+
+void AppCacheDispatcherHost::StartUpdateCallback(bool result, void* param) {
+ IPC::Message* reply_msg = reinterpret_cast<IPC::Message*>(param);
+ AppCacheMsg_StartUpdate::WriteReplyParams(reply_msg, result);
+ frontend_proxy_.sender()->Send(reply_msg);
+}
+
+void AppCacheDispatcherHost::SwapCacheCallback(bool result, void* param) {
+ IPC::Message* reply_msg = reinterpret_cast<IPC::Message*>(param);
+ AppCacheMsg_SwapCache::WriteReplyParams(reply_msg, result);
frontend_proxy_.sender()->Send(reply_msg);
}
diff --git a/chrome/common/appcache/appcache_dispatcher_host.h b/chrome/common/appcache/appcache_dispatcher_host.h
index f141fdb..47f245a 100644
--- a/chrome/common/appcache/appcache_dispatcher_host.h
+++ b/chrome/common/appcache/appcache_dispatcher_host.h
@@ -6,19 +6,27 @@
#define CHROME_COMMON_APPCACHE_APPCACHE_DISPATCHER_HOST_H_
#include <vector>
+#include "base/ref_counted.h"
+#include "base/scoped_ptr.h"
#include "chrome/common/appcache/appcache_frontend_proxy.h"
#include "ipc/ipc_message.h"
#include "webkit/appcache/appcache_backend_impl.h"
+class ChromeAppCacheService;
+
// Handles appcache related messages sent to the main browser process from
// its child processes. There is a distinct host for each child process.
// Messages are handled on the IO thread. The ResourceMessageFilter creates
// an instance and delegates calls to it.
class AppCacheDispatcherHost {
public:
- void Initialize(IPC::Message::Sender* sender);
+ explicit AppCacheDispatcherHost(ChromeAppCacheService* appcache_service);
+
+ void Initialize(IPC::Message::Sender* sender, int process_id);
bool OnMessageReceived(const IPC::Message& msg, bool* msg_is_ok);
+ int process_id() const { return backend_impl_.process_id(); }
+
// Note: needed to satisfy ipc message dispatching macros.
bool Send(IPC::Message* msg) {
return frontend_proxy_.sender()->Send(msg);
@@ -37,8 +45,18 @@ class AppCacheDispatcherHost {
void OnStartUpdate(int host_id, IPC::Message* reply_msg);
void OnSwapCache(int host_id, IPC::Message* reply_msg);
+ void GetStatusCallback(appcache::Status status, void* param);
+ void StartUpdateCallback(bool result, void* param);
+ void SwapCacheCallback(bool result, void* param);
+
AppCacheFrontendProxy frontend_proxy_;
appcache::AppCacheBackendImpl backend_impl_;
+ scoped_refptr<ChromeAppCacheService> appcache_service_;
+ scoped_ptr<appcache::GetStatusCallback> get_status_callback_;
+ scoped_ptr<appcache::StartUpdateCallback> start_update_callback_;
+ scoped_ptr<appcache::SwapCacheCallback> swap_cache_callback_;
+
+ DISALLOW_COPY_AND_ASSIGN(AppCacheDispatcherHost);
};
#endif // CHROME_COMMON_APPCACHE_APPCACHE_DISPATCHER_HOST_H_
diff --git a/chrome/common/appcache/appcache_frontend_proxy.cc b/chrome/common/appcache/appcache_frontend_proxy.cc
index bf20baa8..08c8510 100644
--- a/chrome/common/appcache/appcache_frontend_proxy.cc
+++ b/chrome/common/appcache/appcache_frontend_proxy.cc
@@ -20,4 +20,3 @@ void AppCacheFrontendProxy::OnEventRaised(const std::vector<int>& host_ids,
appcache::EventID event_id) {
sender_->Send(new AppCacheMsg_EventRaised(host_ids, event_id));
}
-
diff --git a/chrome/common/appcache/chrome_appcache_service.h b/chrome/common/appcache/chrome_appcache_service.h
new file mode 100644
index 0000000..63736da
--- /dev/null
+++ b/chrome/common/appcache/chrome_appcache_service.h
@@ -0,0 +1,67 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_COMMON_APPCACHE_CHROME_APPCACHE_SERVICE_H_
+#define CHROME_COMMON_APPCACHE_CHROME_APPCACHE_SERVICE_H_
+
+#include "base/file_path.h"
+#include "base/message_loop.h"
+#include "base/ref_counted.h"
+#include "base/task.h"
+#include "chrome/browser/chrome_thread.h"
+#include "chrome/common/chrome_constants.h"
+#include "webkit/appcache/appcache_service.h"
+
+// An AppCacheService subclass used by the chrome. There is an instance
+// associated with each Profile. This derivation adds refcounting semantics
+// since a profile has multiple URLRequestContexts which refer to the same
+// object, and those URLRequestContexts are refcounted independently of the
+// owning profile.
+//
+// All methods, including the dtor, are expected to be called on the IO thread
+// except for the ctor and the init method which are expected to be called on
+// the UI thread.
+class ChromeAppCacheService
+ : public base::RefCountedThreadSafe<ChromeAppCacheService>,
+ public appcache::AppCacheService {
+ public:
+
+ explicit ChromeAppCacheService()
+ : was_initialized_with_io_thread_(false) {
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
+ }
+
+ void InitializeOnUIThread(const FilePath& data_directory,
+ bool is_incognito) {
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
+
+ // Some test cases run without an IO thread.
+ MessageLoop* io_thread = ChromeThread::GetMessageLoop(ChromeThread::IO);
+ if (io_thread) {
+ was_initialized_with_io_thread_ = true;
+ io_thread->PostTask(FROM_HERE,
+ NewRunnableMethod(this, &ChromeAppCacheService::InitializeOnIOThread,
+ data_directory, is_incognito));
+ }
+ }
+
+ private:
+ friend class base::RefCountedThreadSafe<ChromeAppCacheService>;
+
+ virtual ~ChromeAppCacheService() {
+ DCHECK(!was_initialized_with_io_thread_ ||
+ ChromeThread::CurrentlyOn(ChromeThread::IO));
+ }
+
+ void InitializeOnIOThread(const FilePath& data_directory,
+ bool is_incognito) {
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
+ Initialize(is_incognito ? FilePath()
+ : data_directory.Append(chrome::kAppCacheDirname));
+ }
+
+ bool was_initialized_with_io_thread_;
+};
+
+#endif // CHROME_COMMON_APPCACHE_CHROME_APPCACHE_SERVICE_H_
diff --git a/chrome/common/chrome_constants.cc b/chrome/common/chrome_constants.cc
index 6e578c5..d892a8f 100644
--- a/chrome/common/chrome_constants.cc
+++ b/chrome/common/chrome_constants.cc
@@ -64,6 +64,7 @@ const FilePath::CharType kCacheDirname[] = FPL("Cache");
const FilePath::CharType kMediaCacheDirname[] = FPL("Media Cache");
const FilePath::CharType kOffTheRecordMediaCacheDirname[] =
FPL("Incognito Media Cache");
+const FilePath::CharType kAppCacheDirname[] = FPL("Application Cache");
const wchar_t kChromePluginDataDirname[] = L"Plugin Data";
const wchar_t kThemeImagesDirname[] = L"Cached Theme Images";
const FilePath::CharType kCookieFilename[] = FPL("Cookies");
diff --git a/chrome/common/chrome_constants.h b/chrome/common/chrome_constants.h
index 9e76426..0f5ec52 100644
--- a/chrome/common/chrome_constants.h
+++ b/chrome/common/chrome_constants.h
@@ -30,6 +30,7 @@ extern const FilePath::CharType kArchivedHistoryFilename[];
extern const FilePath::CharType kCacheDirname[];
extern const FilePath::CharType kMediaCacheDirname[];
extern const FilePath::CharType kOffTheRecordMediaCacheDirname[];
+extern const FilePath::CharType kAppCacheDirname[];
extern const wchar_t kChromePluginDataDirname[];
extern const wchar_t kThemeImagesDirname[];
extern const FilePath::CharType kCookieFilename[];
diff --git a/chrome/test/testing_profile.h b/chrome/test/testing_profile.h
index ff89b61..d786017 100644
--- a/chrome/test/testing_profile.h
+++ b/chrome/test/testing_profile.h
@@ -75,6 +75,9 @@ class TestingProfile : public Profile {
virtual Profile* GetOriginalProfile() {
return this;
}
+ virtual ChromeAppCacheService* GetAppCacheService() {
+ return NULL;
+ }
virtual VisitedLinkMaster* GetVisitedLinkMaster() {
return NULL;
}
@@ -130,11 +133,9 @@ class TestingProfile : public Profile {
virtual TemplateURLFetcher* GetTemplateURLFetcher() {
return NULL;
}
-
virtual ThumbnailStore* GetThumbnailStore() {
return NULL;
}
-
virtual DownloadManager* GetDownloadManager() {
return NULL;
}