summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-14 00:27:10 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-14 00:27:10 +0000
commite93e04e68701ef882ea86d16039e17525e41ebad (patch)
tree2b53b5ba7b4f179f9ba8369af5c70c986afd31b0 /content
parent4ce47a5c70379c34dd1ba114642712308d5fb38b (diff)
downloadchromium_src-e93e04e68701ef882ea86d16039e17525e41ebad.zip
chromium_src-e93e04e68701ef882ea86d16039e17525e41ebad.tar.gz
chromium_src-e93e04e68701ef882ea86d16039e17525e41ebad.tar.bz2
Move AppCache common code to content and split off AppCache messages into their own file. Also move WebMessagePortChannel and WebDatabaseObserverImpl to content.
TBR=michaeln Review URL: http://codereview.chromium.org/6691002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@77990 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/browser/appcache/appcache_dispatcher_host.cc29
-rw-r--r--content/browser/appcache/appcache_frontend_proxy.cc2
-rw-r--r--content/common/appcache/appcache_backend_proxy.cc70
-rw-r--r--content/common/appcache/appcache_backend_proxy.h47
-rw-r--r--content/common/appcache/appcache_dispatcher.cc61
-rw-r--r--content/common/appcache/appcache_dispatcher.h48
-rw-r--r--content/common/appcache_messages.h137
-rw-r--r--content/common/content_message_generator.h1
-rw-r--r--content/common/web_database_observer_impl.cc53
-rw-r--r--content/common/web_database_observer_impl.h29
-rw-r--r--content/common/webmessageportchannel_impl.cc244
-rw-r--r--content/common/webmessageportchannel_impl.h78
-rw-r--r--content/content_common.gypi9
13 files changed, 790 insertions, 18 deletions
diff --git a/content/browser/appcache/appcache_dispatcher_host.cc b/content/browser/appcache/appcache_dispatcher_host.cc
index 6d0246b..e3f4430 100644
--- a/content/browser/appcache/appcache_dispatcher_host.cc
+++ b/content/browser/appcache/appcache_dispatcher_host.cc
@@ -8,8 +8,8 @@
#include "chrome/browser/metrics/user_metrics.h"
#include "chrome/browser/net/chrome_url_request_context.h"
#include "chrome/browser/renderer_host/browser_render_process_host.h"
-#include "chrome/common/render_messages.h"
#include "content/browser/appcache/chrome_appcache_service.h"
+#include "content/common/appcache_messages.h"
AppCacheDispatcherHost::AppCacheDispatcherHost(
net::URLRequestContext* request_context,
@@ -61,18 +61,19 @@ bool AppCacheDispatcherHost::OnMessageReceived(const IPC::Message& message,
bool* message_was_ok) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP_EX(AppCacheDispatcherHost, message, *message_was_ok)
- IPC_MESSAGE_HANDLER(AppCacheMsg_RegisterHost, OnRegisterHost)
- IPC_MESSAGE_HANDLER(AppCacheMsg_UnregisterHost, OnUnregisterHost)
- IPC_MESSAGE_HANDLER(AppCacheMsg_GetResourceList, OnGetResourceList)
- IPC_MESSAGE_HANDLER(AppCacheMsg_SelectCache, OnSelectCache)
- IPC_MESSAGE_HANDLER(AppCacheMsg_SelectCacheForWorker,
+ IPC_MESSAGE_HANDLER(AppCacheHostMsg_RegisterHost, OnRegisterHost)
+ IPC_MESSAGE_HANDLER(AppCacheHostMsg_UnregisterHost, OnUnregisterHost)
+ IPC_MESSAGE_HANDLER(AppCacheHostMsg_GetResourceList, OnGetResourceList)
+ IPC_MESSAGE_HANDLER(AppCacheHostMsg_SelectCache, OnSelectCache)
+ IPC_MESSAGE_HANDLER(AppCacheHostMsg_SelectCacheForWorker,
OnSelectCacheForWorker)
- IPC_MESSAGE_HANDLER(AppCacheMsg_SelectCacheForSharedWorker,
+ IPC_MESSAGE_HANDLER(AppCacheHostMsg_SelectCacheForSharedWorker,
OnSelectCacheForSharedWorker)
- IPC_MESSAGE_HANDLER(AppCacheMsg_MarkAsForeignEntry, OnMarkAsForeignEntry)
- IPC_MESSAGE_HANDLER_DELAY_REPLY(AppCacheMsg_GetStatus, OnGetStatus)
- IPC_MESSAGE_HANDLER_DELAY_REPLY(AppCacheMsg_StartUpdate, OnStartUpdate)
- IPC_MESSAGE_HANDLER_DELAY_REPLY(AppCacheMsg_SwapCache, OnSwapCache)
+ IPC_MESSAGE_HANDLER(AppCacheHostMsg_MarkAsForeignEntry,
+ OnMarkAsForeignEntry)
+ IPC_MESSAGE_HANDLER_DELAY_REPLY(AppCacheHostMsg_GetStatus, OnGetStatus)
+ IPC_MESSAGE_HANDLER_DELAY_REPLY(AppCacheHostMsg_StartUpdate, OnStartUpdate)
+ IPC_MESSAGE_HANDLER_DELAY_REPLY(AppCacheHostMsg_SwapCache, OnSwapCache)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP_EX()
@@ -218,20 +219,20 @@ void AppCacheDispatcherHost::GetStatusCallback(
appcache::Status status, void* param) {
IPC::Message* reply_msg = reinterpret_cast<IPC::Message*>(param);
DCHECK_EQ(pending_reply_msg_.get(), reply_msg);
- AppCacheMsg_GetStatus::WriteReplyParams(reply_msg, status);
+ AppCacheHostMsg_GetStatus::WriteReplyParams(reply_msg, status);
Send(pending_reply_msg_.release());
}
void AppCacheDispatcherHost::StartUpdateCallback(bool result, void* param) {
IPC::Message* reply_msg = reinterpret_cast<IPC::Message*>(param);
DCHECK_EQ(pending_reply_msg_.get(), reply_msg);
- AppCacheMsg_StartUpdate::WriteReplyParams(reply_msg, result);
+ AppCacheHostMsg_StartUpdate::WriteReplyParams(reply_msg, result);
Send(pending_reply_msg_.release());
}
void AppCacheDispatcherHost::SwapCacheCallback(bool result, void* param) {
IPC::Message* reply_msg = reinterpret_cast<IPC::Message*>(param);
DCHECK_EQ(pending_reply_msg_.get(), reply_msg);
- AppCacheMsg_SwapCache::WriteReplyParams(reply_msg, result);
+ AppCacheHostMsg_SwapCache::WriteReplyParams(reply_msg, result);
Send(pending_reply_msg_.release());
}
diff --git a/content/browser/appcache/appcache_frontend_proxy.cc b/content/browser/appcache/appcache_frontend_proxy.cc
index 3691007a..f6fa108 100644
--- a/content/browser/appcache/appcache_frontend_proxy.cc
+++ b/content/browser/appcache/appcache_frontend_proxy.cc
@@ -4,7 +4,7 @@
#include "content/browser/appcache/appcache_frontend_proxy.h"
-#include "chrome/common/render_messages.h"
+#include "content/common/appcache_messages.h"
AppCacheFrontendProxy::AppCacheFrontendProxy(IPC::Message::Sender* sender)
: sender_(sender) {
diff --git a/content/common/appcache/appcache_backend_proxy.cc b/content/common/appcache/appcache_backend_proxy.cc
new file mode 100644
index 0000000..be54b76
--- /dev/null
+++ b/content/common/appcache/appcache_backend_proxy.cc
@@ -0,0 +1,70 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/common/appcache/appcache_backend_proxy.h"
+
+#include "content/common/appcache_messages.h"
+
+void AppCacheBackendProxy::RegisterHost(int host_id) {
+ sender_->Send(new AppCacheHostMsg_RegisterHost(host_id));
+}
+
+void AppCacheBackendProxy::UnregisterHost(int host_id) {
+ sender_->Send(new AppCacheHostMsg_UnregisterHost(host_id));
+}
+
+void AppCacheBackendProxy::SelectCache(
+ int host_id,
+ const GURL& document_url,
+ const int64 cache_document_was_loaded_from,
+ const GURL& manifest_url) {
+ sender_->Send(new AppCacheHostMsg_SelectCache(
+ host_id, document_url,
+ cache_document_was_loaded_from,
+ manifest_url));
+}
+
+void AppCacheBackendProxy::SelectCacheForWorker(
+ int host_id, int parent_process_id, int parent_host_id) {
+ sender_->Send(new AppCacheHostMsg_SelectCacheForWorker(
+ host_id, parent_process_id,
+ parent_host_id));
+}
+
+void AppCacheBackendProxy::SelectCacheForSharedWorker(
+ int host_id, int64 appcache_id) {
+ sender_->Send(new AppCacheHostMsg_SelectCacheForSharedWorker(
+ host_id, appcache_id));
+}
+
+void AppCacheBackendProxy::MarkAsForeignEntry(
+ int host_id, const GURL& document_url,
+ int64 cache_document_was_loaded_from) {
+ sender_->Send(new AppCacheHostMsg_MarkAsForeignEntry(
+ host_id, document_url,
+ cache_document_was_loaded_from));
+}
+
+appcache::Status AppCacheBackendProxy::GetStatus(int host_id) {
+ appcache::Status status = appcache::UNCACHED;
+ sender_->Send(new AppCacheHostMsg_GetStatus(host_id, &status));
+ return status;
+}
+
+bool AppCacheBackendProxy::StartUpdate(int host_id) {
+ bool result = false;
+ sender_->Send(new AppCacheHostMsg_StartUpdate(host_id, &result));
+ return result;
+}
+
+bool AppCacheBackendProxy::SwapCache(int host_id) {
+ bool result = false;
+ sender_->Send(new AppCacheHostMsg_SwapCache(host_id, &result));
+ return result;
+}
+
+void AppCacheBackendProxy::GetResourceList(
+ int host_id, std::vector<appcache::AppCacheResourceInfo>* resource_infos) {
+ sender_->Send(new AppCacheHostMsg_GetResourceList(host_id, resource_infos));
+}
diff --git a/content/common/appcache/appcache_backend_proxy.h b/content/common/appcache/appcache_backend_proxy.h
new file mode 100644
index 0000000..b05115e
--- /dev/null
+++ b/content/common/appcache/appcache_backend_proxy.h
@@ -0,0 +1,47 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_COMMON_APPCACHE_APPCACHE_BACKEND_PROXY_H_
+#define CONTENT_COMMON_APPCACHE_APPCACHE_BACKEND_PROXY_H_
+#pragma once
+
+#include "ipc/ipc_message.h"
+#include "webkit/appcache/appcache_interfaces.h"
+
+// Sends appcache related messages to the main process.
+class AppCacheBackendProxy : public appcache::AppCacheBackend {
+ public:
+ explicit AppCacheBackendProxy(IPC::Message::Sender* sender)
+ : sender_(sender) {}
+
+ IPC::Message::Sender* sender() const { return sender_; }
+
+ // AppCacheBackend methods
+ virtual void RegisterHost(int host_id);
+ virtual void UnregisterHost(int host_id);
+ virtual void SelectCache(int host_id,
+ const GURL& document_url,
+ const int64 cache_document_was_loaded_from,
+ const GURL& manifest_url);
+ virtual void SelectCacheForWorker(
+ int host_id,
+ int parent_process_id,
+ int parent_host_id);
+ virtual void SelectCacheForSharedWorker(
+ int host_id,
+ int64 appcache_id);
+ virtual void MarkAsForeignEntry(int host_id, const GURL& document_url,
+ int64 cache_document_was_loaded_from);
+ virtual appcache::Status GetStatus(int host_id);
+ virtual bool StartUpdate(int host_id);
+ virtual bool SwapCache(int host_id);
+ virtual void GetResourceList(
+ int host_id,
+ std::vector<appcache::AppCacheResourceInfo>* resource_infos);
+
+ private:
+ IPC::Message::Sender* sender_;
+};
+
+#endif // CONTENT_COMMON_APPCACHE_APPCACHE_BACKEND_PROXY_H_
diff --git a/content/common/appcache/appcache_dispatcher.cc b/content/common/appcache/appcache_dispatcher.cc
new file mode 100644
index 0000000..6504770
--- /dev/null
+++ b/content/common/appcache/appcache_dispatcher.cc
@@ -0,0 +1,61 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/common/appcache/appcache_dispatcher.h"
+
+#include "content/common/appcache_messages.h"
+#include "webkit/appcache/web_application_cache_host_impl.h"
+
+bool AppCacheDispatcher::OnMessageReceived(const IPC::Message& msg) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(AppCacheDispatcher, msg)
+ IPC_MESSAGE_HANDLER(AppCacheMsg_CacheSelected, OnCacheSelected)
+ IPC_MESSAGE_HANDLER(AppCacheMsg_StatusChanged, OnStatusChanged)
+ IPC_MESSAGE_HANDLER(AppCacheMsg_EventRaised, OnEventRaised)
+ IPC_MESSAGE_HANDLER(AppCacheMsg_ProgressEventRaised, OnProgressEventRaised)
+ IPC_MESSAGE_HANDLER(AppCacheMsg_ErrorEventRaised, OnErrorEventRaised)
+ IPC_MESSAGE_HANDLER(AppCacheMsg_LogMessage, OnLogMessage)
+ IPC_MESSAGE_HANDLER(AppCacheMsg_ContentBlocked, OnContentBlocked)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ return handled;
+}
+
+void AppCacheDispatcher::OnCacheSelected(
+ int host_id, const appcache::AppCacheInfo& info) {
+ frontend_impl_.OnCacheSelected(host_id, info);
+}
+
+void AppCacheDispatcher::OnStatusChanged(const std::vector<int>& host_ids,
+ appcache::Status status) {
+ frontend_impl_.OnStatusChanged(host_ids, status);
+}
+
+void AppCacheDispatcher::OnEventRaised(const std::vector<int>& host_ids,
+ appcache::EventID event_id) {
+ frontend_impl_.OnEventRaised(host_ids, event_id);
+}
+
+void AppCacheDispatcher::OnProgressEventRaised(
+ const std::vector<int>& host_ids,
+ const GURL& url, int num_total, int num_complete) {
+ frontend_impl_.OnProgressEventRaised(host_ids, url, num_total, num_complete);
+}
+
+void AppCacheDispatcher::OnErrorEventRaised(
+ const std::vector<int>& host_ids,
+ const std::string& message) {
+ frontend_impl_.OnErrorEventRaised(host_ids, message);
+}
+
+void AppCacheDispatcher::OnLogMessage(
+ int host_id, int log_level, const std::string& message) {
+ frontend_impl_.OnLogMessage(
+ host_id, static_cast<appcache::LogLevel>(log_level), message);
+}
+
+void AppCacheDispatcher::OnContentBlocked(int host_id,
+ const GURL& manifest_url) {
+ frontend_impl_.OnContentBlocked(host_id, manifest_url);
+}
diff --git a/content/common/appcache/appcache_dispatcher.h b/content/common/appcache/appcache_dispatcher.h
new file mode 100644
index 0000000..aafaa395
--- /dev/null
+++ b/content/common/appcache/appcache_dispatcher.h
@@ -0,0 +1,48 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_COMMON_APPCACHE_APPCACHE_DISPATCHER_H_
+#define CONTENT_COMMON_APPCACHE_APPCACHE_DISPATCHER_H_
+#pragma once
+
+#include <string>
+#include <vector>
+#include "content/common/appcache/appcache_backend_proxy.h"
+#include "ipc/ipc_channel.h"
+#include "webkit/appcache/appcache_frontend_impl.h"
+
+// Dispatches appcache related messages sent to a child process from the
+// main browser process. There is one instance per child process. Messages
+// are dispatched on the main child thread. The ChildThread base class
+// creates an instance and delegates calls to it.
+class AppCacheDispatcher : public IPC::Channel::Listener {
+ public:
+ explicit AppCacheDispatcher(IPC::Message::Sender* sender)
+ : backend_proxy_(sender) {}
+
+ AppCacheBackendProxy* backend_proxy() { return &backend_proxy_; }
+
+ // IPC::Channel::Listener implementation
+ virtual bool OnMessageReceived(const IPC::Message& msg);
+
+ private:
+ // Ipc message handlers
+ void OnCacheSelected(int host_id, const appcache::AppCacheInfo& info);
+ void OnStatusChanged(const std::vector<int>& host_ids,
+ appcache::Status status);
+ void OnEventRaised(const std::vector<int>& host_ids,
+ appcache::EventID event_id);
+ void OnProgressEventRaised(const std::vector<int>& host_ids,
+ const GURL& url, int num_total, int num_complete);
+ void OnErrorEventRaised(const std::vector<int>& host_ids,
+ const std::string& message);
+ void OnLogMessage(int host_id, int log_level, const std::string& message);
+ void OnContentBlocked(int host_id,
+ const GURL& manifest_url);
+
+ AppCacheBackendProxy backend_proxy_;
+ appcache::AppCacheFrontendImpl frontend_impl_;
+};
+
+#endif // CONTENT_COMMON_APPCACHE_APPCACHE_DISPATCHER_H_
diff --git a/content/common/appcache_messages.h b/content/common/appcache_messages.h
new file mode 100644
index 0000000..d14ffa8
--- /dev/null
+++ b/content/common/appcache_messages.h
@@ -0,0 +1,137 @@
+// Copyright (c) 2011 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.
+
+// Multiply-included message file, hence no include guard.
+
+#include "ipc/ipc_message_macros.h"
+#include "webkit/appcache/appcache_interfaces.h"
+
+#define IPC_MESSAGE_START AppCacheMsgStart
+
+IPC_ENUM_TRAITS(appcache::EventID)
+IPC_ENUM_TRAITS(appcache::Status)
+
+IPC_STRUCT_TRAITS_BEGIN(appcache::AppCacheInfo)
+ IPC_STRUCT_TRAITS_MEMBER(manifest_url)
+ IPC_STRUCT_TRAITS_MEMBER(creation_time)
+ IPC_STRUCT_TRAITS_MEMBER(last_update_time)
+ IPC_STRUCT_TRAITS_MEMBER(last_access_time)
+ IPC_STRUCT_TRAITS_MEMBER(cache_id)
+ IPC_STRUCT_TRAITS_MEMBER(status)
+ IPC_STRUCT_TRAITS_MEMBER(size)
+ IPC_STRUCT_TRAITS_MEMBER(is_complete)
+IPC_STRUCT_TRAITS_END()
+
+IPC_STRUCT_TRAITS_BEGIN(appcache::AppCacheResourceInfo)
+ IPC_STRUCT_TRAITS_MEMBER(url)
+ IPC_STRUCT_TRAITS_MEMBER(size)
+ IPC_STRUCT_TRAITS_MEMBER(is_master)
+ IPC_STRUCT_TRAITS_MEMBER(is_manifest)
+ IPC_STRUCT_TRAITS_MEMBER(is_fallback)
+ IPC_STRUCT_TRAITS_MEMBER(is_foreign)
+ IPC_STRUCT_TRAITS_MEMBER(is_explicit)
+IPC_STRUCT_TRAITS_END()
+
+// AppCache messages sent from the child process to the browser.
+
+// Informs the browser of a new appcache host.
+IPC_MESSAGE_CONTROL1(AppCacheHostMsg_RegisterHost,
+ int /* host_id */)
+
+// Informs the browser of an appcache host being destroyed.
+IPC_MESSAGE_CONTROL1(AppCacheHostMsg_UnregisterHost,
+ int /* host_id */)
+
+// Initiates the cache selection algorithm for the given host.
+// This is sent prior to any subresource loads. An AppCacheMsg_CacheSelected
+// message will be sent in response.
+// 'host_id' indentifies a specific document or worker
+// 'document_url' the url of the main resource
+// 'appcache_document_was_loaded_from' the id of the appcache the main
+// resource was loaded from or kNoCacheId
+// 'opt_manifest_url' the manifest url specified in the <html> tag if any
+IPC_MESSAGE_CONTROL4(AppCacheHostMsg_SelectCache,
+ int /* host_id */,
+ GURL /* document_url */,
+ int64 /* appcache_document_was_loaded_from */,
+ GURL /* opt_manifest_url */)
+
+// Initiates worker specific cache selection algorithm for the given host.
+IPC_MESSAGE_CONTROL3(AppCacheHostMsg_SelectCacheForWorker,
+ int /* host_id */,
+ int /* parent_process_id */,
+ int /* parent_host_id */)
+IPC_MESSAGE_CONTROL2(AppCacheHostMsg_SelectCacheForSharedWorker,
+ int /* host_id */,
+ int64 /* appcache_id */)
+
+// Informs the browser of a 'foreign' entry in an appcache.
+IPC_MESSAGE_CONTROL3(AppCacheHostMsg_MarkAsForeignEntry,
+ int /* host_id */,
+ GURL /* document_url */,
+ int64 /* appcache_document_was_loaded_from */)
+
+// Returns the status of the appcache associated with host_id.
+IPC_SYNC_MESSAGE_CONTROL1_1(AppCacheHostMsg_GetStatus,
+ int /* host_id */,
+ appcache::Status)
+
+// Initiates an update of the appcache associated with host_id.
+IPC_SYNC_MESSAGE_CONTROL1_1(AppCacheHostMsg_StartUpdate,
+ int /* host_id */,
+ bool /* success */)
+
+// Swaps a new pending appcache, if there is one, into use for host_id.
+IPC_SYNC_MESSAGE_CONTROL1_1(AppCacheHostMsg_SwapCache,
+ int /* host_id */,
+ bool /* success */)
+
+// Gets resource list from appcache synchronously.
+IPC_SYNC_MESSAGE_CONTROL1_1(AppCacheHostMsg_GetResourceList,
+ int /* host_id in*/,
+ std::vector<appcache::AppCacheResourceInfo>
+ /* resources out */)
+
+
+// AppCache messages sent from the browser to the child process.
+
+// Notifies the renderer of the appcache that has been selected for a
+// a particular host. This is sent in reply to AppCacheHostMsg_SelectCache.
+IPC_MESSAGE_CONTROL2(AppCacheMsg_CacheSelected,
+ int /* host_id */,
+ appcache::AppCacheInfo)
+
+// Notifies the renderer of an AppCache status change.
+IPC_MESSAGE_CONTROL2(AppCacheMsg_StatusChanged,
+ std::vector<int> /* host_ids */,
+ appcache::Status)
+
+// Notifies the renderer of an AppCache event other than the
+// progress event which has a seperate message.
+IPC_MESSAGE_CONTROL2(AppCacheMsg_EventRaised,
+ std::vector<int> /* host_ids */,
+ appcache::EventID)
+
+// Notifies the renderer of an AppCache progress event.
+IPC_MESSAGE_CONTROL4(AppCacheMsg_ProgressEventRaised,
+ std::vector<int> /* host_ids */,
+ GURL /* url being processed */,
+ int /* total */,
+ int /* complete */)
+
+// Notifies the renderer of an AppCache error event.
+IPC_MESSAGE_CONTROL2(AppCacheMsg_ErrorEventRaised,
+ std::vector<int> /* host_ids */,
+ std::string /* error_message */)
+
+// Notifies the renderer of an AppCache logging message.
+IPC_MESSAGE_CONTROL3(AppCacheMsg_LogMessage,
+ int /* host_id */,
+ int /* log_level */,
+ std::string /* message */)
+
+// Notifies the renderer of the fact that AppCache access was blocked.
+IPC_MESSAGE_CONTROL2(AppCacheMsg_ContentBlocked,
+ int /* host_id */,
+ GURL /* manifest_url */)
diff --git a/content/common/content_message_generator.h b/content/common/content_message_generator.h
index 68c16e8..117865f 100644
--- a/content/common/content_message_generator.h
+++ b/content/common/content_message_generator.h
@@ -4,6 +4,7 @@
// Multiply-included file, hence no include guard.
+#include "content/common/appcache_messages.h"
#include "content/common/child_process_messages.h"
#include "content/common/database_messages.h"
#include "content/common/file_system_messages.h"
diff --git a/content/common/web_database_observer_impl.cc b/content/common/web_database_observer_impl.cc
new file mode 100644
index 0000000..37c3e2c
--- /dev/null
+++ b/content/common/web_database_observer_impl.cc
@@ -0,0 +1,53 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/common/web_database_observer_impl.h"
+
+#include "base/auto_reset.h"
+#include "base/message_loop.h"
+#include "base/string16.h"
+#include "content/common/database_messages.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebDatabase.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
+
+WebDatabaseObserverImpl::WebDatabaseObserverImpl(
+ IPC::Message::Sender* sender)
+ : sender_(sender),
+ waiting_for_dbs_to_close_(false) {
+}
+
+void WebDatabaseObserverImpl::databaseOpened(
+ const WebKit::WebDatabase& database) {
+ string16 origin_identifier = database.securityOrigin().databaseIdentifier();
+ string16 database_name = database.name();
+ sender_->Send(new DatabaseHostMsg_Opened(
+ origin_identifier, database_name,
+ database.displayName(), database.estimatedSize()));
+ database_connections_.AddConnection(origin_identifier, database_name);
+}
+
+void WebDatabaseObserverImpl::databaseModified(
+ const WebKit::WebDatabase& database) {
+ sender_->Send(new DatabaseHostMsg_Modified(
+ database.securityOrigin().databaseIdentifier(), database.name()));
+}
+
+void WebDatabaseObserverImpl::databaseClosed(
+ const WebKit::WebDatabase& database) {
+ string16 origin_identifier = database.securityOrigin().databaseIdentifier();
+ string16 database_name = database.name();
+ sender_->Send(new DatabaseHostMsg_Closed(
+ origin_identifier, database_name));
+ database_connections_.RemoveConnection(origin_identifier, database_name);
+ if (waiting_for_dbs_to_close_ && database_connections_.IsEmpty())
+ MessageLoop::current()->Quit();
+}
+
+void WebDatabaseObserverImpl::WaitForAllDatabasesToClose() {
+ if (!database_connections_.IsEmpty()) {
+ AutoReset<bool> waiting_for_dbs_auto_reset(&waiting_for_dbs_to_close_, true);
+ MessageLoop::ScopedNestableTaskAllower nestable(MessageLoop::current());
+ MessageLoop::current()->Run();
+ }
+}
diff --git a/content/common/web_database_observer_impl.h b/content/common/web_database_observer_impl.h
new file mode 100644
index 0000000..442a7af
--- /dev/null
+++ b/content/common/web_database_observer_impl.h
@@ -0,0 +1,29 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_COMMON_WEB_DATABASE_OBSERVER_IMPL_H_
+#define CONTENT_COMMON_WEB_DATABASE_OBSERVER_IMPL_H_
+#pragma once
+
+#include "ipc/ipc_message.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebDatabaseObserver.h"
+#include "webkit/database/database_connections.h"
+
+class WebDatabaseObserverImpl : public WebKit::WebDatabaseObserver {
+ public:
+ explicit WebDatabaseObserverImpl(IPC::Message::Sender* sender);
+ virtual ~WebDatabaseObserverImpl() {}
+ virtual void databaseOpened(const WebKit::WebDatabase& database);
+ virtual void databaseModified(const WebKit::WebDatabase& database);
+ virtual void databaseClosed(const WebKit::WebDatabase& database);
+
+ void WaitForAllDatabasesToClose();
+
+ private:
+ IPC::Message::Sender* sender_;
+ bool waiting_for_dbs_to_close_;
+ webkit_database::DatabaseConnections database_connections_;
+};
+
+#endif // CONTENT_COMMON_WEB_DATABASE_OBSERVER_IMPL_H_
diff --git a/content/common/webmessageportchannel_impl.cc b/content/common/webmessageportchannel_impl.cc
new file mode 100644
index 0000000..6a9ac36
--- /dev/null
+++ b/content/common/webmessageportchannel_impl.cc
@@ -0,0 +1,244 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/common/webmessageportchannel_impl.h"
+
+#include "content/common/child_process.h"
+#include "content/common/child_thread.h"
+#include "content/common/worker_messages.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebMessagePortChannelClient.h"
+
+using WebKit::WebMessagePortChannel;
+using WebKit::WebMessagePortChannelArray;
+using WebKit::WebMessagePortChannelClient;
+using WebKit::WebString;
+
+WebMessagePortChannelImpl::WebMessagePortChannelImpl()
+ : client_(NULL),
+ route_id_(MSG_ROUTING_NONE),
+ message_port_id_(MSG_ROUTING_NONE) {
+ AddRef();
+ Init();
+}
+
+WebMessagePortChannelImpl::WebMessagePortChannelImpl(
+ int route_id,
+ int message_port_id)
+ : client_(NULL),
+ route_id_(route_id),
+ message_port_id_(message_port_id) {
+ AddRef();
+ Init();
+}
+
+WebMessagePortChannelImpl::~WebMessagePortChannelImpl() {
+ // If we have any queued messages with attached ports, manually destroy them.
+ while (!message_queue_.empty()) {
+ const std::vector<WebMessagePortChannelImpl*>& channel_array =
+ message_queue_.front().ports;
+ for (size_t i = 0; i < channel_array.size(); i++) {
+ channel_array[i]->destroy();
+ }
+ message_queue_.pop();
+ }
+
+ if (message_port_id_ != MSG_ROUTING_NONE)
+ Send(new WorkerProcessHostMsg_DestroyMessagePort(message_port_id_));
+
+ if (route_id_ != MSG_ROUTING_NONE)
+ ChildThread::current()->RemoveRoute(route_id_);
+}
+
+void WebMessagePortChannelImpl::setClient(WebMessagePortChannelClient* client) {
+ // Must lock here since client_ is called on the main thread.
+ base::AutoLock auto_lock(lock_);
+ client_ = client;
+}
+
+void WebMessagePortChannelImpl::destroy() {
+ setClient(NULL);
+
+ // Release the object on the main thread, since the destructor might want to
+ // send an IPC, and that has to happen on the main thread.
+ ChildThread::current()->message_loop()->ReleaseSoon(FROM_HERE, this);
+}
+
+void WebMessagePortChannelImpl::entangle(WebMessagePortChannel* channel) {
+ // The message port ids might not be set up yet, if this channel wasn't
+ // created on the main thread. So need to wait until we're on the main thread
+ // before getting the other message port id.
+ scoped_refptr<WebMessagePortChannelImpl> webchannel(
+ static_cast<WebMessagePortChannelImpl*>(channel));
+ Entangle(webchannel);
+}
+
+void WebMessagePortChannelImpl::postMessage(
+ const WebString& message,
+ WebMessagePortChannelArray* channels) {
+ if (MessageLoop::current() != ChildThread::current()->message_loop()) {
+ ChildThread::current()->message_loop()->PostTask(FROM_HERE,
+ NewRunnableMethod(this, &WebMessagePortChannelImpl::postMessage,
+ message, channels));
+ return;
+ }
+
+ std::vector<int> message_port_ids(channels ? channels->size() : 0);
+ if (channels) {
+ // Extract the port IDs from the source array, then free it.
+ for (size_t i = 0; i < channels->size(); ++i) {
+ WebMessagePortChannelImpl* webchannel =
+ static_cast<WebMessagePortChannelImpl*>((*channels)[i]);
+ message_port_ids[i] = webchannel->message_port_id();
+ webchannel->QueueMessages();
+ DCHECK(message_port_ids[i] != MSG_ROUTING_NONE);
+ }
+ delete channels;
+ }
+
+ IPC::Message* msg = new WorkerProcessHostMsg_PostMessage(
+ message_port_id_, message, message_port_ids);
+ Send(msg);
+}
+
+bool WebMessagePortChannelImpl::tryGetMessage(
+ WebString* message,
+ WebMessagePortChannelArray& channels) {
+ base::AutoLock auto_lock(lock_);
+ if (message_queue_.empty())
+ return false;
+
+ *message = message_queue_.front().message;
+ const std::vector<WebMessagePortChannelImpl*>& channel_array =
+ message_queue_.front().ports;
+ WebMessagePortChannelArray result_ports(channel_array.size());
+ for (size_t i = 0; i < channel_array.size(); i++) {
+ result_ports[i] = channel_array[i];
+ }
+
+ channels.swap(result_ports);
+ message_queue_.pop();
+ return true;
+}
+
+void WebMessagePortChannelImpl::Init() {
+ if (MessageLoop::current() != ChildThread::current()->message_loop()) {
+ ChildThread::current()->message_loop()->PostTask(FROM_HERE,
+ NewRunnableMethod(this, &WebMessagePortChannelImpl::Init));
+ return;
+ }
+
+ if (route_id_ == MSG_ROUTING_NONE) {
+ DCHECK(message_port_id_ == MSG_ROUTING_NONE);
+ Send(new WorkerProcessHostMsg_CreateMessagePort(
+ &route_id_, &message_port_id_));
+ }
+
+ ChildThread::current()->AddRoute(route_id_, this);
+}
+
+void WebMessagePortChannelImpl::Entangle(
+ scoped_refptr<WebMessagePortChannelImpl> channel) {
+ if (MessageLoop::current() != ChildThread::current()->message_loop()) {
+ ChildThread::current()->message_loop()->PostTask(FROM_HERE,
+ NewRunnableMethod(this, &WebMessagePortChannelImpl::Entangle, channel));
+ return;
+ }
+
+ Send(new WorkerProcessHostMsg_Entangle(
+ message_port_id_, channel->message_port_id()));
+}
+
+void WebMessagePortChannelImpl::QueueMessages() {
+ if (MessageLoop::current() != ChildThread::current()->message_loop()) {
+ ChildThread::current()->message_loop()->PostTask(FROM_HERE,
+ NewRunnableMethod(this, &WebMessagePortChannelImpl::QueueMessages));
+ return;
+ }
+ // This message port is being sent elsewhere (perhaps to another process).
+ // The new endpoint needs to receive the queued messages, including ones that
+ // could still be in-flight. So we tell the browser to queue messages, and it
+ // sends us an ack, whose receipt we know means that no more messages are
+ // in-flight. We then send the queued messages to the browser, which prepends
+ // them to the ones it queued and it sends them to the new endpoint.
+ Send(new WorkerProcessHostMsg_QueueMessages(message_port_id_));
+
+ // The process could potentially go away while we're still waiting for
+ // in-flight messages. Ensure it stays alive.
+ ChildProcess::current()->AddRefProcess();
+}
+
+void WebMessagePortChannelImpl::Send(IPC::Message* message) {
+ if (MessageLoop::current() != ChildThread::current()->message_loop()) {
+ DCHECK(!message->is_sync());
+ ChildThread::current()->message_loop()->PostTask(FROM_HERE,
+ NewRunnableMethod(this, &WebMessagePortChannelImpl::Send, message));
+ return;
+ }
+
+ ChildThread::current()->Send(message);
+}
+
+bool WebMessagePortChannelImpl::OnMessageReceived(const IPC::Message& message) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(WebMessagePortChannelImpl, message)
+ IPC_MESSAGE_HANDLER(WorkerProcessMsg_Message, OnMessage)
+ IPC_MESSAGE_HANDLER(WorkerProcessMsg_MessagesQueued, OnMessagedQueued)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ return handled;
+}
+
+void WebMessagePortChannelImpl::OnMessage(
+ const string16& message,
+ const std::vector<int>& sent_message_port_ids,
+ const std::vector<int>& new_routing_ids) {
+ base::AutoLock auto_lock(lock_);
+ Message msg;
+ msg.message = message;
+ if (!sent_message_port_ids.empty()) {
+ msg.ports.resize(sent_message_port_ids.size());
+ for (size_t i = 0; i < sent_message_port_ids.size(); ++i) {
+ msg.ports[i] = new WebMessagePortChannelImpl(
+ new_routing_ids[i], sent_message_port_ids[i]);
+ }
+ }
+
+ bool was_empty = message_queue_.empty();
+ message_queue_.push(msg);
+ if (client_ && was_empty)
+ client_->messageAvailable();
+}
+
+void WebMessagePortChannelImpl::OnMessagedQueued() {
+ std::vector<QueuedMessage> queued_messages;
+
+ {
+ base::AutoLock auto_lock(lock_);
+ queued_messages.reserve(message_queue_.size());
+ while (!message_queue_.empty()) {
+ string16 message = message_queue_.front().message;
+ const std::vector<WebMessagePortChannelImpl*>& channel_array =
+ message_queue_.front().ports;
+ std::vector<int> port_ids(channel_array.size());
+ for (size_t i = 0; i < channel_array.size(); ++i) {
+ port_ids[i] = channel_array[i]->message_port_id();
+ }
+ queued_messages.push_back(std::make_pair(message, port_ids));
+ message_queue_.pop();
+ }
+ }
+
+ Send(new WorkerProcessHostMsg_SendQueuedMessages(
+ message_port_id_, queued_messages));
+
+ message_port_id_ = MSG_ROUTING_NONE;
+
+ Release();
+ ChildProcess::current()->ReleaseProcess();
+}
+
+WebMessagePortChannelImpl::Message::Message() {}
+
+WebMessagePortChannelImpl::Message::~Message() {}
diff --git a/content/common/webmessageportchannel_impl.h b/content/common/webmessageportchannel_impl.h
new file mode 100644
index 0000000..e947050
--- /dev/null
+++ b/content/common/webmessageportchannel_impl.h
@@ -0,0 +1,78 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_COMMON_WEBMESSAGEPORTCHANNEL_IMPL_H_
+#define CONTENT_COMMON_WEBMESSAGEPORTCHANNEL_IMPL_H_
+#pragma once
+
+#include <queue>
+#include <vector>
+
+#include "base/basictypes.h"
+#include "base/string16.h"
+#include "base/ref_counted.h"
+#include "base/synchronization/lock.h"
+#include "ipc/ipc_channel.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebMessagePortChannel.h"
+
+// This is thread safe.
+class WebMessagePortChannelImpl
+ : public WebKit::WebMessagePortChannel,
+ public IPC::Channel::Listener,
+ public base::RefCountedThreadSafe<WebMessagePortChannelImpl> {
+ public:
+ WebMessagePortChannelImpl();
+ WebMessagePortChannelImpl(int route_id, int message_port_id);
+
+ // Queues received and incoming messages until there are no more in-flight
+ // messages, then sends all of them to the browser process.
+ void QueueMessages();
+ int message_port_id() const { return message_port_id_; }
+
+ private:
+ friend class base::RefCountedThreadSafe<WebMessagePortChannelImpl>;
+ virtual ~WebMessagePortChannelImpl();
+
+ // WebMessagePortChannel implementation.
+ virtual void setClient(WebKit::WebMessagePortChannelClient* client);
+ virtual void destroy();
+ virtual void entangle(WebKit::WebMessagePortChannel* channel);
+ virtual void postMessage(const WebKit::WebString& message,
+ WebKit::WebMessagePortChannelArray* channels);
+ virtual bool tryGetMessage(WebKit::WebString* message,
+ WebKit::WebMessagePortChannelArray& channels);
+
+ void Init();
+ void Entangle(scoped_refptr<WebMessagePortChannelImpl> channel);
+ void Send(IPC::Message* message);
+
+ // IPC::Channel::Listener implementation.
+ virtual bool OnMessageReceived(const IPC::Message& message);
+
+ void OnMessage(const string16& message,
+ const std::vector<int>& sent_message_port_ids,
+ const std::vector<int>& new_routing_ids);
+ void OnMessagedQueued();
+
+ struct Message {
+ Message();
+ ~Message();
+
+ string16 message;
+ std::vector<WebMessagePortChannelImpl*> ports;
+ };
+
+ typedef std::queue<Message> MessageQueue;
+ MessageQueue message_queue_;
+
+ WebKit::WebMessagePortChannelClient* client_;
+ base::Lock lock_; // Locks access to above.
+
+ int route_id_; // The routing id for this object.
+ int message_port_id_; // A globally unique identifier for this message port.
+
+ DISALLOW_COPY_AND_ASSIGN(WebMessagePortChannelImpl);
+};
+
+#endif // CONTENT_COMMON_WEBMESSAGEPORTCHANNEL_IMPL_H_
diff --git a/content/content_common.gypi b/content/content_common.gypi
index 326bfcc..56e25c7 100644
--- a/content/content_common.gypi
+++ b/content/content_common.gypi
@@ -11,6 +11,7 @@
'../ipc/ipc.gyp:ipc',
'../third_party/icu/icu.gyp:icuuc',
'../third_party/WebKit/Source/WebKit/chromium/WebKit.gyp:webkit',
+ '../webkit/support/webkit_support.gyp:appcache',
'../webkit/support/webkit_support.gyp:blob',
'../webkit/support/webkit_support.gyp:fileapi',
],
@@ -18,6 +19,11 @@
'..',
],
'sources': [
+ 'common/appcache/appcache_backend_proxy.cc',
+ 'common/appcache/appcache_backend_proxy.h',
+ 'common/appcache/appcache_dispatcher.cc',
+ 'common/appcache/appcache_dispatcher.h',
+ 'common/appcache_messages.h',
'common/child_process.cc',
'common/child_process.h',
'common/child_process_host.cc',
@@ -103,9 +109,6 @@
'common/socket_stream_dispatcher.cc',
'common/socket_stream_dispatcher.h',
'common/socket_stream_messages.h',
- 'common/webblobregistry_impl.cc',
- 'common/webblobregistry_impl.h',
- 'common/webblob_messages.h',
'common/worker_messages.h',
],
'conditions': [