| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this |
| 2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
| 3 // LICENSE file. | 3 // LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h" | 5 #include "chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h" |
| 6 | 6 |
| 7 #include "base/nullable_string16.h" | 7 #include "base/nullable_string16.h" |
| 8 #include "chrome/browser/chrome_thread.h" | 8 #include "chrome/browser/chrome_thread.h" |
| 9 #include "chrome/browser/in_process_webkit/dom_storage_context.h" | 9 #include "chrome/browser/in_process_webkit/dom_storage_context.h" |
| 10 #include "chrome/browser/in_process_webkit/storage_area.h" | 10 #include "chrome/browser/in_process_webkit/storage_area.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 IPC_BEGIN_MESSAGE_MAP_EX(DOMStorageDispatcherHost, message, *msg_is_ok) | 72 IPC_BEGIN_MESSAGE_MAP_EX(DOMStorageDispatcherHost, message, *msg_is_ok) |
| 73 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_DOMStorageNamespaceId, | 73 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_DOMStorageNamespaceId, |
| 74 OnNamespaceId) | 74 OnNamespaceId) |
| 75 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_DOMStorageCloneNamespaceId, | 75 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_DOMStorageCloneNamespaceId, |
| 76 OnCloneNamespaceId) | 76 OnCloneNamespaceId) |
| 77 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_DOMStorageStorageAreaId, | 77 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_DOMStorageStorageAreaId, |
| 78 OnStorageAreaId) | 78 OnStorageAreaId) |
| 79 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_DOMStorageLength, OnLength) | 79 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_DOMStorageLength, OnLength) |
| 80 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_DOMStorageKey, OnKey) | 80 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_DOMStorageKey, OnKey) |
| 81 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_DOMStorageGetItem, OnGetItem) | 81 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_DOMStorageGetItem, OnGetItem) |
| 82 IPC_MESSAGE_HANDLER(ViewHostMsg_DOMStorageSetItem, OnSetItem) | 82 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_DOMStorageSetItem, OnSetItem) |
| 83 IPC_MESSAGE_HANDLER(ViewHostMsg_DOMStorageRemoveItem, OnRemoveItem) | 83 IPC_MESSAGE_HANDLER(ViewHostMsg_DOMStorageRemoveItem, OnRemoveItem) |
| 84 IPC_MESSAGE_HANDLER(ViewHostMsg_DOMStorageClear, OnClear) | 84 IPC_MESSAGE_HANDLER(ViewHostMsg_DOMStorageClear, OnClear) |
| 85 IPC_MESSAGE_UNHANDLED(handled = false) | 85 IPC_MESSAGE_UNHANDLED(handled = false) |
| 86 IPC_END_MESSAGE_MAP() | 86 IPC_END_MESSAGE_MAP() |
| 87 if (handled) | 87 if (handled) |
| 88 ever_used_ = true; | 88 ever_used_ = true; |
| 89 return handled; | 89 return handled; |
| 90 } | 90 } |
| 91 | 91 |
| 92 void DOMStorageDispatcherHost::Send(IPC::Message* message) { | 92 void DOMStorageDispatcherHost::Send(IPC::Message* message) { |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 ViewHostMsg_DOMStorageGetItem::ID, process_handle_); | 247 ViewHostMsg_DOMStorageGetItem::ID, process_handle_); |
| 248 delete reply_msg; | 248 delete reply_msg; |
| 249 return; | 249 return; |
| 250 } | 250 } |
| 251 const NullableString16& value = storage_area->GetItem(key); | 251 const NullableString16& value = storage_area->GetItem(key); |
| 252 ViewHostMsg_DOMStorageGetItem::WriteReplyParams(reply_msg, value); | 252 ViewHostMsg_DOMStorageGetItem::WriteReplyParams(reply_msg, value); |
| 253 Send(reply_msg); | 253 Send(reply_msg); |
| 254 } | 254 } |
| 255 | 255 |
| 256 void DOMStorageDispatcherHost::OnSetItem(int64 storage_area_id, | 256 void DOMStorageDispatcherHost::OnSetItem(int64 storage_area_id, |
| 257 const string16& key, | 257 const string16& key, const string16& value, IPC::Message* reply_msg) { |
| 258 const string16& value) { | |
| 259 DCHECK(!shutdown_); | 258 DCHECK(!shutdown_); |
| 260 if (ChromeThread::CurrentlyOn(ChromeThread::IO)) { | 259 if (ChromeThread::CurrentlyOn(ChromeThread::IO)) { |
| 261 MessageLoop* webkit_loop = webkit_thread_->GetMessageLoop(); | 260 MessageLoop* webkit_loop = webkit_thread_->GetMessageLoop(); |
| 262 webkit_loop->PostTask(FROM_HERE, NewRunnableMethod(this, | 261 webkit_loop->PostTask(FROM_HERE, NewRunnableMethod(this, |
| 263 &DOMStorageDispatcherHost::OnSetItem, storage_area_id, key, value)); | 262 &DOMStorageDispatcherHost::OnSetItem, storage_area_id, key, value, |
| 263 reply_msg)); |
| 264 return; | 264 return; |
| 265 } | 265 } |
| 266 | 266 |
| 267 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT)); | 267 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT)); |
| 268 bool quota_exception = false; | 268 bool quota_exception = false; |
| 269 StorageArea* storage_area = Context()->GetStorageArea(storage_area_id); | 269 StorageArea* storage_area = Context()->GetStorageArea(storage_area_id); |
| 270 if (!storage_area) { | 270 if (!storage_area) { |
| 271 BrowserRenderProcessHost::BadMessageTerminateProcess( | 271 BrowserRenderProcessHost::BadMessageTerminateProcess( |
| 272 ViewHostMsg_DOMStorageSetItem::ID, process_handle_); | 272 ViewHostMsg_DOMStorageSetItem::ID, process_handle_); |
| 273 return; | 273 return; |
| 274 } | 274 } |
| 275 storage_area->SetItem(key, value, "a_exception); | 275 storage_area->SetItem(key, value, "a_exception); |
| 276 DCHECK(!quota_exception); // This is tracked by the renderer. | 276 ViewHostMsg_DOMStorageSetItem::WriteReplyParams(reply_msg, quota_exception); |
| 277 Send(reply_msg); |
| 277 } | 278 } |
| 278 | 279 |
| 279 void DOMStorageDispatcherHost::OnRemoveItem(int64 storage_area_id, | 280 void DOMStorageDispatcherHost::OnRemoveItem(int64 storage_area_id, |
| 280 const string16& key) { | 281 const string16& key) { |
| 281 DCHECK(!shutdown_); | 282 DCHECK(!shutdown_); |
| 282 if (ChromeThread::CurrentlyOn(ChromeThread::IO)) { | 283 if (ChromeThread::CurrentlyOn(ChromeThread::IO)) { |
| 283 MessageLoop* webkit_loop = webkit_thread_->GetMessageLoop(); | 284 MessageLoop* webkit_loop = webkit_thread_->GetMessageLoop(); |
| 284 webkit_loop->PostTask(FROM_HERE, NewRunnableMethod(this, | 285 webkit_loop->PostTask(FROM_HERE, NewRunnableMethod(this, |
| 285 &DOMStorageDispatcherHost::OnRemoveItem, storage_area_id, key)); | 286 &DOMStorageDispatcherHost::OnRemoveItem, storage_area_id, key)); |
| 286 return; | 287 return; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 307 | 308 |
| 308 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT)); | 309 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT)); |
| 309 StorageArea* storage_area = Context()->GetStorageArea(storage_area_id); | 310 StorageArea* storage_area = Context()->GetStorageArea(storage_area_id); |
| 310 if (!storage_area) { | 311 if (!storage_area) { |
| 311 BrowserRenderProcessHost::BadMessageTerminateProcess( | 312 BrowserRenderProcessHost::BadMessageTerminateProcess( |
| 312 ViewHostMsg_DOMStorageClear::ID, process_handle_); | 313 ViewHostMsg_DOMStorageClear::ID, process_handle_); |
| 313 return; | 314 return; |
| 314 } | 315 } |
| 315 storage_area->Clear(); | 316 storage_area->Clear(); |
| 316 } | 317 } |
| OLD | NEW |