summaryrefslogtreecommitdiffstats
path: root/chrome/common/appcache/appcache_dispatcher_host.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/common/appcache/appcache_dispatcher_host.cc')
-rw-r--r--chrome/common/appcache/appcache_dispatcher_host.cc85
1 files changed, 65 insertions, 20 deletions
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);
}