| Index: content/browser/dom_storage/dom_storage_message_filter.cc
|
| ===================================================================
|
| --- content/browser/dom_storage/dom_storage_message_filter.cc (revision 139572)
|
| +++ content/browser/dom_storage/dom_storage_message_filter.cc (working copy)
|
| @@ -82,15 +82,10 @@
|
| IPC_MESSAGE_HANDLER(DOMStorageHostMsg_OpenStorageArea, OnOpenStorageArea)
|
| IPC_MESSAGE_HANDLER(DOMStorageHostMsg_CloseStorageArea, OnCloseStorageArea)
|
| IPC_MESSAGE_HANDLER(DOMStorageHostMsg_LoadStorageArea, OnLoadStorageArea)
|
| - IPC_MESSAGE_HANDLER(DOMStorageHostMsg_Length, OnLength)
|
| - IPC_MESSAGE_HANDLER(DOMStorageHostMsg_Key, OnKey)
|
| - IPC_MESSAGE_HANDLER(DOMStorageHostMsg_GetItem, OnGetItem)
|
| IPC_MESSAGE_HANDLER(DOMStorageHostMsg_SetItem, OnSetItem)
|
| - IPC_MESSAGE_HANDLER(DOMStorageHostMsg_SetItemAsync, OnSetItemAsync)
|
| IPC_MESSAGE_HANDLER(DOMStorageHostMsg_RemoveItem, OnRemoveItem)
|
| - IPC_MESSAGE_HANDLER(DOMStorageHostMsg_RemoveItemAsync, OnRemoveItemAsync)
|
| IPC_MESSAGE_HANDLER(DOMStorageHostMsg_Clear, OnClear)
|
| - IPC_MESSAGE_HANDLER(DOMStorageHostMsg_ClearAsync, OnClearAsync)
|
| + IPC_MESSAGE_HANDLER(DOMStorageHostMsg_FlushMessages, OnFlushMessages)
|
| IPC_MESSAGE_UNHANDLED(handled = false)
|
| IPC_END_MESSAGE_MAP()
|
| return handled;
|
| @@ -118,44 +113,11 @@
|
| content::RecordAction(UserMetricsAction("BadMessageTerminate_DSMF_2"));
|
| BadMessageReceived();
|
| }
|
| + Send(new DOMStorageMsg_AsyncOperationComplete(true));
|
| }
|
|
|
| -void DOMStorageMessageFilter::OnLength(int connection_id,
|
| - unsigned* length) {
|
| - DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::IO));
|
| - *length = host_->GetAreaLength(connection_id);
|
| -}
|
| -
|
| -void DOMStorageMessageFilter::OnKey(int connection_id, unsigned index,
|
| - NullableString16* key) {
|
| - DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::IO));
|
| - *key = host_->GetAreaKey(connection_id, index);
|
| -}
|
| -
|
| -void DOMStorageMessageFilter::OnGetItem(int connection_id,
|
| - const string16& key,
|
| - NullableString16* value) {
|
| - DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::IO));
|
| - *value = host_->GetAreaItem(connection_id, key);
|
| -}
|
| -
|
| void DOMStorageMessageFilter::OnSetItem(
|
| int connection_id, const string16& key,
|
| - const string16& value, const GURL& page_url,
|
| - WebKit::WebStorageArea::Result* result, NullableString16* old_value) {
|
| - DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::IO));
|
| - DCHECK_EQ(0, connection_dispatching_message_for_);
|
| - AutoReset<int> auto_reset(&connection_dispatching_message_for_,
|
| - connection_id);
|
| - *old_value = NullableString16(true);
|
| - if (host_->SetAreaItem(connection_id, key, value, page_url, old_value))
|
| - *result = WebKit::WebStorageArea::ResultOK;
|
| - else
|
| - *result = WebKit::WebStorageArea::ResultBlockedByQuota;
|
| -}
|
| -
|
| -void DOMStorageMessageFilter::OnSetItemAsync(
|
| - int connection_id, int operation_id, const string16& key,
|
| const string16& value, const GURL& page_url) {
|
| DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::IO));
|
| DCHECK_EQ(0, connection_dispatching_message_for_);
|
| @@ -164,25 +126,11 @@
|
| NullableString16 not_used;
|
| bool success = host_->SetAreaItem(connection_id, key, value,
|
| page_url, ¬_used);
|
| - Send(new DOMStorageMsg_AsyncOperationComplete(operation_id, success));
|
| + Send(new DOMStorageMsg_AsyncOperationComplete(success));
|
| }
|
|
|
| void DOMStorageMessageFilter::OnRemoveItem(
|
| - int connection_id, const string16& key, const GURL& page_url,
|
| - NullableString16* old_value) {
|
| - DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::IO));
|
| - DCHECK_EQ(0, connection_dispatching_message_for_);
|
| - AutoReset<int> auto_reset(&connection_dispatching_message_for_,
|
| - connection_id);
|
| - string16 old_string_value;
|
| - if (host_->RemoveAreaItem(connection_id, key, page_url, &old_string_value))
|
| - *old_value = NullableString16(old_string_value, false);
|
| - else
|
| - *old_value = NullableString16(true);
|
| -}
|
| -
|
| -void DOMStorageMessageFilter::OnRemoveItemAsync(
|
| - int connection_id, int operation_id, const string16& key,
|
| + int connection_id, const string16& key,
|
| const GURL& page_url) {
|
| DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::IO));
|
| DCHECK_EQ(0, connection_dispatching_message_for_);
|
| @@ -190,26 +138,21 @@
|
| connection_id);
|
| string16 not_used;
|
| host_->RemoveAreaItem(connection_id, key, page_url, ¬_used);
|
| - Send(new DOMStorageMsg_AsyncOperationComplete(operation_id, true));
|
| + Send(new DOMStorageMsg_AsyncOperationComplete(true));
|
| }
|
|
|
| -void DOMStorageMessageFilter::OnClear(int connection_id, const GURL& page_url,
|
| - bool* something_cleared) {
|
| +void DOMStorageMessageFilter::OnClear(
|
| + int connection_id, const GURL& page_url) {
|
| DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::IO));
|
| DCHECK_EQ(0, connection_dispatching_message_for_);
|
| AutoReset<int> auto_reset(&connection_dispatching_message_for_,
|
| connection_id);
|
| - *something_cleared = host_->ClearArea(connection_id, page_url);
|
| + host_->ClearArea(connection_id, page_url);
|
| + Send(new DOMStorageMsg_AsyncOperationComplete(true));
|
| }
|
|
|
| -void DOMStorageMessageFilter::OnClearAsync(
|
| - int connection_id, int operation_id, const GURL& page_url) {
|
| - DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::IO));
|
| - DCHECK_EQ(0, connection_dispatching_message_for_);
|
| - AutoReset<int> auto_reset(&connection_dispatching_message_for_,
|
| - connection_id);
|
| - host_->ClearArea(connection_id, page_url);
|
| - Send(new DOMStorageMsg_AsyncOperationComplete(operation_id, true));
|
| +void DOMStorageMessageFilter::OnFlushMessages() {
|
| + // Intentionally empty method body.
|
| }
|
|
|
| void DOMStorageMessageFilter::OnDomStorageItemSet(
|
| @@ -251,17 +194,18 @@
|
| const NullableString16& new_value,
|
| const NullableString16& old_value) {
|
| DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::IO));
|
| - if (area->namespace_id() != dom_storage::kLocalStorageNamespaceId &&
|
| - !connection_dispatching_message_for_) {
|
| - return; // No need to broadcast session storage events across processes.
|
| + // Only send mutation events to processes which have the area open.
|
| + bool originated_in_process = connection_dispatching_message_for_ != 0;
|
| + if (originated_in_process ||
|
| + host_->HasAreaOpen(area->namespace_id(), area->origin())) {
|
| + DOMStorageMsg_Event_Params params;
|
| + params.origin = area->origin();
|
| + params.page_url = page_url;
|
| + params.connection_id = connection_dispatching_message_for_;
|
| + params.key = key;
|
| + params.new_value = new_value;
|
| + params.old_value = old_value;
|
| + params.namespace_id = area->namespace_id();
|
| + Send(new DOMStorageMsg_Event(params));
|
| }
|
| - DOMStorageMsg_Event_Params params;
|
| - params.origin = area->origin();
|
| - params.page_url = page_url;
|
| - params.connection_id = connection_dispatching_message_for_;
|
| - params.key = key;
|
| - params.new_value = new_value;
|
| - params.old_value = old_value;
|
| - params.namespace_id = area->namespace_id();
|
| - Send(new DOMStorageMsg_Event(params));
|
| }
|
|
|