Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/in_process_webkit/indexed_db_dispatcher_host.h" | 5 #include "chrome/browser/in_process_webkit/indexed_db_dispatcher_host.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/browser_thread.h" | 9 #include "chrome/browser/browser_thread.h" |
| 10 #include "chrome/browser/content_settings/host_content_settings_map.h" | 10 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 11 #include "chrome/browser/in_process_webkit/indexed_db_callbacks.h" | 11 #include "chrome/browser/in_process_webkit/indexed_db_callbacks.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/renderer_host/browser_render_process_host.h" | 13 #include "chrome/browser/renderer_host/browser_render_process_host.h" |
| 14 #include "chrome/browser/renderer_host/render_view_host_notification_task.h" | 14 #include "chrome/browser/renderer_host/render_view_host_notification_task.h" |
| 15 #include "chrome/browser/renderer_host/resource_message_filter.h" | 15 #include "chrome/browser/renderer_host/resource_message_filter.h" |
| 16 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
| 17 #include "chrome/common/indexed_db_key.h" | 17 #include "chrome/common/indexed_db_messages.h" |
| 18 #include "chrome/common/render_messages.h" | |
| 19 #include "chrome/common/render_messages_params.h" | |
| 20 #include "chrome/common/serialized_script_value.h" | |
| 21 #include "googleurl/src/gurl.h" | 18 #include "googleurl/src/gurl.h" |
| 22 #include "third_party/WebKit/WebKit/chromium/public/WebDOMStringList.h" | 19 #include "third_party/WebKit/WebKit/chromium/public/WebDOMStringList.h" |
| 23 #include "third_party/WebKit/WebKit/chromium/public/WebIDBCursor.h" | 20 #include "third_party/WebKit/WebKit/chromium/public/WebIDBCursor.h" |
| 24 #include "third_party/WebKit/WebKit/chromium/public/WebIDBDatabase.h" | 21 #include "third_party/WebKit/WebKit/chromium/public/WebIDBDatabase.h" |
| 25 #include "third_party/WebKit/WebKit/chromium/public/WebIDBDatabaseError.h" | 22 #include "third_party/WebKit/WebKit/chromium/public/WebIDBDatabaseError.h" |
| 26 #include "third_party/WebKit/WebKit/chromium/public/WebIDBKeyRange.h" | 23 #include "third_party/WebKit/WebKit/chromium/public/WebIDBKeyRange.h" |
| 27 #include "third_party/WebKit/WebKit/chromium/public/WebIDBIndex.h" | 24 #include "third_party/WebKit/WebKit/chromium/public/WebIDBIndex.h" |
| 28 #include "third_party/WebKit/WebKit/chromium/public/WebIDBFactory.h" | 25 #include "third_party/WebKit/WebKit/chromium/public/WebIDBFactory.h" |
| 29 #include "third_party/WebKit/WebKit/chromium/public/WebIDBObjectStore.h" | 26 #include "third_party/WebKit/WebKit/chromium/public/WebIDBObjectStore.h" |
| 30 #include "third_party/WebKit/WebKit/chromium/public/WebIDBTransaction.h" | 27 #include "third_party/WebKit/WebKit/chromium/public/WebIDBTransaction.h" |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 54 static const uint64 kDefaultQuota = 5 * 1024 * 1024; | 51 static const uint64 kDefaultQuota = 5 * 1024 * 1024; |
| 55 | 52 |
| 56 template <class T> | 53 template <class T> |
| 57 void DeleteOnWebKitThread(T* obj) { | 54 void DeleteOnWebKitThread(T* obj) { |
| 58 if (!BrowserThread::DeleteSoon(BrowserThread::WEBKIT, FROM_HERE, obj)) | 55 if (!BrowserThread::DeleteSoon(BrowserThread::WEBKIT, FROM_HERE, obj)) |
| 59 delete obj; | 56 delete obj; |
| 60 } | 57 } |
| 61 | 58 |
| 62 } | 59 } |
| 63 | 60 |
| 64 IndexedDBDispatcherHost::IndexedDBDispatcherHost( | 61 IndexedDBDispatcherHost::IndexedDBDispatcherHost(int process_id, |
| 65 IPC::Message::Sender* sender, Profile* profile) | 62 Profile* profile) |
| 66 : sender_(sender), | 63 : webkit_context_(profile->GetWebKitContext()), |
| 67 webkit_context_(profile->GetWebKitContext()), | |
| 68 host_content_settings_map_(profile->GetHostContentSettingsMap()), | 64 host_content_settings_map_(profile->GetHostContentSettingsMap()), |
| 69 ALLOW_THIS_IN_INITIALIZER_LIST(database_dispatcher_host_( | 65 ALLOW_THIS_IN_INITIALIZER_LIST(database_dispatcher_host_( |
| 70 new DatabaseDispatcherHost(this))), | 66 new DatabaseDispatcherHost(this))), |
| 71 ALLOW_THIS_IN_INITIALIZER_LIST(index_dispatcher_host_( | 67 ALLOW_THIS_IN_INITIALIZER_LIST(index_dispatcher_host_( |
| 72 new IndexDispatcherHost(this))), | 68 new IndexDispatcherHost(this))), |
| 73 ALLOW_THIS_IN_INITIALIZER_LIST(object_store_dispatcher_host_( | 69 ALLOW_THIS_IN_INITIALIZER_LIST(object_store_dispatcher_host_( |
| 74 new ObjectStoreDispatcherHost(this))), | 70 new ObjectStoreDispatcherHost(this))), |
| 75 ALLOW_THIS_IN_INITIALIZER_LIST(cursor_dispatcher_host_( | 71 ALLOW_THIS_IN_INITIALIZER_LIST(cursor_dispatcher_host_( |
| 76 new CursorDispatcherHost(this))), | 72 new CursorDispatcherHost(this))), |
| 77 ALLOW_THIS_IN_INITIALIZER_LIST(transaction_dispatcher_host_( | 73 ALLOW_THIS_IN_INITIALIZER_LIST(transaction_dispatcher_host_( |
| 78 new TransactionDispatcherHost(this))), | 74 new TransactionDispatcherHost(this))), |
| 79 process_handle_(0) { | 75 process_id_(process_id) { |
| 80 DCHECK(sender_); | |
| 81 DCHECK(webkit_context_.get()); | 76 DCHECK(webkit_context_.get()); |
| 82 } | 77 } |
| 83 | 78 |
| 84 IndexedDBDispatcherHost::~IndexedDBDispatcherHost() { | 79 IndexedDBDispatcherHost::~IndexedDBDispatcherHost() { |
| 85 } | 80 } |
| 86 | 81 |
| 87 void IndexedDBDispatcherHost::Init(int process_id, | 82 void IndexedDBDispatcherHost::OnChannelClosing() { |
| 88 base::ProcessHandle process_handle) { | 83 BrowserThread::DeleteSoon( |
| 89 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 84 BrowserThread::WEBKIT, FROM_HERE, database_dispatcher_host_.release()); |
| 90 DCHECK(sender_); // Ensure Shutdown() has not been called. | 85 BrowserThread::DeleteSoon( |
| 91 DCHECK(!process_handle_); // Make sure Init() has not yet been called. | 86 BrowserThread::WEBKIT, FROM_HERE, index_dispatcher_host_.release()); |
| 92 DCHECK(process_handle); | 87 BrowserThread::DeleteSoon( |
| 93 process_id_ = process_id; | 88 BrowserThread::WEBKIT, FROM_HERE, |
| 94 process_handle_ = process_handle; | 89 object_store_dispatcher_host_.release()); |
| 90 BrowserThread::DeleteSoon( | |
| 91 BrowserThread::WEBKIT, FROM_HERE, cursor_dispatcher_host_.release()); | |
| 92 BrowserThread::DeleteSoon( | |
| 93 BrowserThread::WEBKIT, FROM_HERE, | |
| 94 transaction_dispatcher_host_.release()); | |
| 95 } | 95 } |
| 96 | 96 |
| 97 void IndexedDBDispatcherHost::Shutdown() { | 97 void IndexedDBDispatcherHost::OverrideThreadForMessage( |
| 98 if (BrowserThread::CurrentlyOn(BrowserThread::IO)) { | 98 const IPC::Message& message, |
| 99 sender_ = NULL; | 99 BrowserThread::ID* thread) { |
| 100 | 100 if (IPC_MESSAGE_CLASS(message) == IndexedDBMsgStart) |
| 101 bool success = BrowserThread::PostTask( | 101 *thread = BrowserThread::WEBKIT; |
| 102 BrowserThread::WEBKIT, FROM_HERE, | |
| 103 NewRunnableMethod(this, &IndexedDBDispatcherHost::Shutdown)); | |
| 104 if (success) | |
| 105 return; | |
| 106 } | |
| 107 | |
| 108 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT) || | |
| 109 CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)); | |
| 110 DCHECK(!sender_); | |
| 111 | |
| 112 database_dispatcher_host_.reset(); | |
| 113 index_dispatcher_host_.reset(); | |
| 114 object_store_dispatcher_host_.reset(); | |
| 115 cursor_dispatcher_host_.reset(); | |
| 116 transaction_dispatcher_host_.reset(); | |
| 117 } | 102 } |
| 118 | 103 |
| 119 bool IndexedDBDispatcherHost::OnMessageReceived(const IPC::Message& message) { | 104 bool IndexedDBDispatcherHost::OnMessageReceived(const IPC::Message& message, |
| 120 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 105 bool* message_was_ok) { |
| 121 DCHECK(process_handle_); | 106 if (IPC_MESSAGE_CLASS(message) != IndexedDBMsgStart) |
| 107 return false; | |
| 122 | 108 |
| 123 switch (message.type()) { | |
| 124 case ViewHostMsg_IDBCursorDirection::ID: | |
| 125 case ViewHostMsg_IDBCursorKey::ID: | |
| 126 case ViewHostMsg_IDBCursorValue::ID: | |
| 127 case ViewHostMsg_IDBCursorUpdate::ID: | |
| 128 case ViewHostMsg_IDBCursorContinue::ID: | |
| 129 case ViewHostMsg_IDBCursorDelete::ID: | |
| 130 case ViewHostMsg_IDBCursorDestroyed::ID: | |
| 131 case ViewHostMsg_IDBFactoryOpen::ID: | |
| 132 case ViewHostMsg_IDBDatabaseName::ID: | |
| 133 case ViewHostMsg_IDBDatabaseVersion::ID: | |
| 134 case ViewHostMsg_IDBDatabaseObjectStoreNames::ID: | |
| 135 case ViewHostMsg_IDBDatabaseCreateObjectStore::ID: | |
| 136 case ViewHostMsg_IDBDatabaseDeleteObjectStore::ID: | |
| 137 case ViewHostMsg_IDBDatabaseSetVersion::ID: | |
| 138 case ViewHostMsg_IDBDatabaseTransaction::ID: | |
| 139 case ViewHostMsg_IDBDatabaseDestroyed::ID: | |
| 140 case ViewHostMsg_IDBIndexName::ID: | |
| 141 case ViewHostMsg_IDBIndexStoreName::ID: | |
| 142 case ViewHostMsg_IDBIndexKeyPath::ID: | |
| 143 case ViewHostMsg_IDBIndexUnique::ID: | |
| 144 case ViewHostMsg_IDBIndexDestroyed::ID: | |
| 145 case ViewHostMsg_IDBIndexOpenObjectCursor::ID: | |
| 146 case ViewHostMsg_IDBIndexOpenKeyCursor::ID: | |
| 147 case ViewHostMsg_IDBIndexGetObject::ID: | |
| 148 case ViewHostMsg_IDBIndexGetKey::ID: | |
| 149 case ViewHostMsg_IDBObjectStoreName::ID: | |
| 150 case ViewHostMsg_IDBObjectStoreKeyPath::ID: | |
| 151 case ViewHostMsg_IDBObjectStoreIndexNames::ID: | |
| 152 case ViewHostMsg_IDBObjectStoreGet::ID: | |
| 153 case ViewHostMsg_IDBObjectStorePut::ID: | |
| 154 case ViewHostMsg_IDBObjectStoreDelete::ID: | |
| 155 case ViewHostMsg_IDBObjectStoreCreateIndex::ID: | |
| 156 case ViewHostMsg_IDBObjectStoreIndex::ID: | |
| 157 case ViewHostMsg_IDBObjectStoreDeleteIndex::ID: | |
| 158 case ViewHostMsg_IDBObjectStoreOpenCursor::ID: | |
| 159 case ViewHostMsg_IDBObjectStoreDestroyed::ID: | |
| 160 case ViewHostMsg_IDBTransactionAbort::ID: | |
| 161 case ViewHostMsg_IDBTransactionMode::ID: | |
| 162 case ViewHostMsg_IDBTransactionDestroyed::ID: | |
| 163 case ViewHostMsg_IDBTransactionDidCompleteTaskEvents::ID: | |
| 164 case ViewHostMsg_IDBTransactionObjectStore::ID: | |
| 165 break; | |
| 166 default: | |
| 167 return false; | |
| 168 } | |
| 169 | |
| 170 bool success = BrowserThread::PostTask( | |
| 171 BrowserThread::WEBKIT, FROM_HERE, NewRunnableMethod( | |
| 172 this, &IndexedDBDispatcherHost::OnMessageReceivedWebKit, message)); | |
| 173 DCHECK(success); | |
| 174 return true; | |
| 175 } | |
| 176 | |
| 177 void IndexedDBDispatcherHost::Send(IPC::Message* message) { | |
| 178 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { | |
| 179 // TODO(jorlow): Even if we successfully post, I believe it's possible for | |
| 180 // the task to never run (if the IO thread is already shutting | |
| 181 // down). We may want to handle this case, though | |
| 182 // realistically it probably doesn't matter. | |
| 183 if (!BrowserThread::PostTask( | |
| 184 BrowserThread::IO, FROM_HERE, NewRunnableMethod( | |
| 185 this, &IndexedDBDispatcherHost::Send, message))) { | |
| 186 // The IO thread is dead. | |
| 187 delete message; | |
| 188 } | |
| 189 return; | |
| 190 } | |
| 191 | |
| 192 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
| 193 if (!sender_) | |
| 194 delete message; | |
| 195 else | |
| 196 sender_->Send(message); | |
| 197 } | |
| 198 | |
| 199 void IndexedDBDispatcherHost::OnMessageReceivedWebKit( | |
| 200 const IPC::Message& message) { | |
| 201 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 109 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
| 202 DCHECK(process_handle_); | |
| 203 | 110 |
| 204 bool msg_is_ok = true; | 111 bool msg_is_ok = true; |
|
jorlow
2010/12/13 18:24:04
What if it's not OK?
jam
2010/12/13 20:41:05
oops, this was unused, removed
| |
| 205 bool handled = | 112 bool handled = |
| 206 database_dispatcher_host_->OnMessageReceived(message, &msg_is_ok) || | 113 database_dispatcher_host_->OnMessageReceived(message, message_was_ok) || |
| 207 index_dispatcher_host_->OnMessageReceived(message, &msg_is_ok) || | 114 index_dispatcher_host_->OnMessageReceived(message, message_was_ok) || |
| 208 object_store_dispatcher_host_->OnMessageReceived(message, &msg_is_ok) || | 115 object_store_dispatcher_host_->OnMessageReceived(message, message_was_ok) || |
|
jorlow
2010/12/13 18:24:04
>80
jam
2010/12/13 20:41:05
Done.
| |
| 209 cursor_dispatcher_host_->OnMessageReceived(message, &msg_is_ok) || | 116 cursor_dispatcher_host_->OnMessageReceived(message, message_was_ok) || |
| 210 transaction_dispatcher_host_->OnMessageReceived(message, &msg_is_ok); | 117 transaction_dispatcher_host_->OnMessageReceived(message, message_was_ok); |
| 211 | 118 |
| 212 if (!handled) { | 119 if (!handled) { |
| 213 handled = true; | 120 handled = true; |
| 214 DCHECK(msg_is_ok); | 121 DCHECK(msg_is_ok); |
| 215 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost, message, msg_is_ok) | 122 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost, message, msg_is_ok) |
| 216 IPC_MESSAGE_HANDLER(ViewHostMsg_IDBFactoryOpen, | 123 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_FactoryOpen, OnIDBFactoryOpen) |
| 217 OnIDBFactoryOpen) | |
| 218 IPC_MESSAGE_UNHANDLED(handled = false) | 124 IPC_MESSAGE_UNHANDLED(handled = false) |
| 219 IPC_END_MESSAGE_MAP() | 125 IPC_END_MESSAGE_MAP() |
| 220 } | 126 } |
| 221 | 127 |
| 222 DCHECK(handled); | 128 return handled; |
| 223 if (!msg_is_ok) { | |
| 224 BrowserRenderProcessHost::BadMessageTerminateProcess(message.type(), | |
| 225 process_handle_); | |
| 226 } | |
| 227 } | 129 } |
| 228 | 130 |
| 229 int32 IndexedDBDispatcherHost::Add(WebIDBCursor* idb_cursor) { | 131 int32 IndexedDBDispatcherHost::Add(WebIDBCursor* idb_cursor) { |
| 230 return cursor_dispatcher_host_->map_.Add(idb_cursor); | 132 return cursor_dispatcher_host_->map_.Add(idb_cursor); |
| 231 } | 133 } |
| 232 | 134 |
| 233 int32 IndexedDBDispatcherHost::Add(WebIDBDatabase* idb_database) { | 135 int32 IndexedDBDispatcherHost::Add(WebIDBDatabase* idb_database) { |
| 234 return database_dispatcher_host_->map_.Add(idb_database); | 136 return database_dispatcher_host_->map_.Add(idb_database); |
| 235 } | 137 } |
| 236 | 138 |
| 237 int32 IndexedDBDispatcherHost::Add(WebIDBIndex* idb_index) { | 139 int32 IndexedDBDispatcherHost::Add(WebIDBIndex* idb_index) { |
| 238 if (!idb_index) | 140 if (!idb_index) |
| 239 return 0; | 141 return 0; |
| 240 return index_dispatcher_host_->map_.Add(idb_index); | 142 return index_dispatcher_host_->map_.Add(idb_index); |
| 241 } | 143 } |
| 242 | 144 |
| 243 int32 IndexedDBDispatcherHost::Add(WebIDBObjectStore* idb_object_store) { | 145 int32 IndexedDBDispatcherHost::Add(WebIDBObjectStore* idb_object_store) { |
| 244 if (!idb_object_store) | 146 if (!idb_object_store) |
| 245 return 0; | 147 return 0; |
| 246 return object_store_dispatcher_host_->map_.Add(idb_object_store); | 148 return object_store_dispatcher_host_->map_.Add(idb_object_store); |
| 247 } | 149 } |
| 248 | 150 |
| 249 int32 IndexedDBDispatcherHost::Add(WebIDBTransaction* idb_transaction) { | 151 int32 IndexedDBDispatcherHost::Add(WebIDBTransaction* idb_transaction) { |
| 250 int32 id = transaction_dispatcher_host_->map_.Add(idb_transaction); | 152 int32 id = transaction_dispatcher_host_->map_.Add(idb_transaction); |
| 251 idb_transaction->setCallbacks(new IndexedDBTransactionCallbacks(this, id)); | 153 idb_transaction->setCallbacks(new IndexedDBTransactionCallbacks(this, id)); |
| 252 return id; | 154 return id; |
| 253 } | 155 } |
| 254 | 156 |
| 255 void IndexedDBDispatcherHost::OnIDBFactoryOpen( | 157 void IndexedDBDispatcherHost::OnIDBFactoryOpen( |
| 256 const ViewHostMsg_IDBFactoryOpen_Params& params) { | 158 const IndexedDBHostMsg_FactoryOpen_Params& params) { |
| 257 FilePath base_path = webkit_context_->data_path(); | 159 FilePath base_path = webkit_context_->data_path(); |
| 258 FilePath indexed_db_path; | 160 FilePath indexed_db_path; |
| 259 if (!base_path.empty()) { | 161 if (!base_path.empty()) { |
| 260 indexed_db_path = base_path.Append( | 162 indexed_db_path = base_path.Append( |
| 261 IndexedDBContext::kIndexedDBDirectory); | 163 IndexedDBContext::kIndexedDBDirectory); |
| 262 } | 164 } |
| 263 | 165 |
| 264 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 166 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
| 265 GURL host(string16(WebSecurityOrigin::createFromDatabaseIdentifier( | 167 GURL host(string16(WebSecurityOrigin::createFromDatabaseIdentifier( |
| 266 params.origin_).toString())); | 168 params.origin).toString())); |
| 267 | 169 |
| 268 ContentSetting content_setting = | 170 ContentSetting content_setting = |
| 269 host_content_settings_map_->GetContentSetting( | 171 host_content_settings_map_->GetContentSetting( |
| 270 host, CONTENT_SETTINGS_TYPE_COOKIES, ""); | 172 host, CONTENT_SETTINGS_TYPE_COOKIES, ""); |
| 271 | 173 |
| 272 CallRenderViewHostContentSettingsDelegate( | 174 CallRenderViewHostContentSettingsDelegate( |
| 273 process_id_, params.routing_id_, | 175 process_id_, params.routing_id, |
| 274 &RenderViewHostDelegate::ContentSettings::OnIndexedDBAccessed, | 176 &RenderViewHostDelegate::ContentSettings::OnIndexedDBAccessed, |
| 275 host, params.name_, content_setting == CONTENT_SETTING_BLOCK); | 177 host, params.name, content_setting == CONTENT_SETTING_BLOCK); |
| 276 | 178 |
| 277 if (content_setting == CONTENT_SETTING_BLOCK) { | 179 if (content_setting == CONTENT_SETTING_BLOCK) { |
| 278 // TODO(jorlow): Change this to the proper error code once we figure out | 180 // TODO(jorlow): Change this to the proper error code once we figure out |
| 279 // one. | 181 // one. |
| 280 int error_code = 0; // Defined by the IndexedDB spec. | 182 int error_code = 0; // Defined by the IndexedDB spec. |
| 281 static string16 error_message = ASCIIToUTF16( | 183 static string16 error_message = ASCIIToUTF16( |
| 282 "The user denied permission to open the database."); | 184 "The user denied permission to open the database."); |
| 283 Send(new ViewMsg_IDBCallbacksError(params.response_id_, error_code, | 185 Send(new IndexedDBMsg_CallbacksError(params.response_id, error_code, |
| 284 error_message)); | 186 error_message)); |
| 285 return; | 187 return; |
| 286 } | 188 } |
| 287 | 189 |
| 288 DCHECK(kDefaultQuota == params.maximum_size_); | 190 DCHECK(kDefaultQuota == params.maximum_size); |
| 289 | 191 |
| 290 uint64 quota = kDefaultQuota; | 192 uint64 quota = kDefaultQuota; |
| 291 if (CommandLine::ForCurrentProcess()->HasSwitch( | 193 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 292 switches::kUnlimitedQuotaForIndexedDB)) { | 194 switches::kUnlimitedQuotaForIndexedDB)) { |
| 293 quota = 1024 * 1024 * 1024; // 1GB. More or less "unlimited". | 195 quota = 1024 * 1024 * 1024; // 1GB. More or less "unlimited". |
| 294 } | 196 } |
| 295 | 197 |
| 296 Context()->GetIDBFactory()->open( | 198 Context()->GetIDBFactory()->open( |
| 297 params.name_, | 199 params.name, |
| 298 new IndexedDBCallbacks<WebIDBDatabase>(this, params.response_id_), | 200 new IndexedDBCallbacks<WebIDBDatabase>(this, params.response_id), |
| 299 WebSecurityOrigin::createFromDatabaseIdentifier(params.origin_), NULL, | 201 WebSecurityOrigin::createFromDatabaseIdentifier(params.origin), NULL, |
| 300 webkit_glue::FilePathToWebString(indexed_db_path), quota); | 202 webkit_glue::FilePathToWebString(indexed_db_path), quota); |
| 301 } | 203 } |
| 302 | 204 |
| 303 ////////////////////////////////////////////////////////////////////// | 205 ////////////////////////////////////////////////////////////////////// |
| 304 // Helper templates. | 206 // Helper templates. |
| 305 // | 207 // |
| 306 | 208 |
| 307 template <typename ObjectType> | 209 template <typename ObjectType> |
| 308 ObjectType* IndexedDBDispatcherHost::GetOrTerminateProcess( | 210 ObjectType* IndexedDBDispatcherHost::GetOrTerminateProcess( |
| 309 IDMap<ObjectType, IDMapOwnPointer>* map, int32 return_object_id, | 211 IDMap<ObjectType, IDMapOwnPointer>* map, int32 return_object_id, |
| 310 IPC::Message* reply_msg, uint32 message_type) { | 212 IPC::Message* reply_msg, uint32 message_type) { |
| 311 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 213 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
| 312 ObjectType* return_object = map->Lookup(return_object_id); | 214 ObjectType* return_object = map->Lookup(return_object_id); |
| 313 if (!return_object) { | 215 if (!return_object) { |
| 314 BrowserRenderProcessHost::BadMessageTerminateProcess(message_type, | 216 BadMessageReceived(message_type); |
| 315 process_handle_); | |
| 316 delete reply_msg; | 217 delete reply_msg; |
| 317 } | 218 } |
| 318 return return_object; | 219 return return_object; |
| 319 } | 220 } |
| 320 | 221 |
| 321 template <typename ReplyType, typename MessageType, | 222 template <typename ReplyType, typename MessageType, |
| 322 typename MapObjectType, typename Method> | 223 typename MapObjectType, typename Method> |
| 323 void IndexedDBDispatcherHost::SyncGetter( | 224 void IndexedDBDispatcherHost::SyncGetter( |
| 324 IDMap<MapObjectType, IDMapOwnPointer>* map, int32 object_id, | 225 IDMap<MapObjectType, IDMapOwnPointer>* map, int32 object_id, |
| 325 IPC::Message* reply_msg, Method method) { | 226 IPC::Message* reply_msg, Method method) { |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 353 } | 254 } |
| 354 | 255 |
| 355 IndexedDBDispatcherHost::DatabaseDispatcherHost::~DatabaseDispatcherHost() { | 256 IndexedDBDispatcherHost::DatabaseDispatcherHost::~DatabaseDispatcherHost() { |
| 356 } | 257 } |
| 357 | 258 |
| 358 bool IndexedDBDispatcherHost::DatabaseDispatcherHost::OnMessageReceived( | 259 bool IndexedDBDispatcherHost::DatabaseDispatcherHost::OnMessageReceived( |
| 359 const IPC::Message& message, bool* msg_is_ok) { | 260 const IPC::Message& message, bool* msg_is_ok) { |
| 360 bool handled = true; | 261 bool handled = true; |
| 361 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost::DatabaseDispatcherHost, | 262 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost::DatabaseDispatcherHost, |
| 362 message, *msg_is_ok) | 263 message, *msg_is_ok) |
| 363 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBDatabaseName, OnName) | 264 IPC_MESSAGE_HANDLER_DELAY_REPLY(IndexedDBHostMsg_DatabaseName, OnName) |
| 364 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBDatabaseVersion, OnVersion) | 265 IPC_MESSAGE_HANDLER_DELAY_REPLY(IndexedDBHostMsg_DatabaseVersion, OnVersion) |
| 365 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBDatabaseObjectStoreNames, | 266 IPC_MESSAGE_HANDLER_DELAY_REPLY(IndexedDBHostMsg_DatabaseObjectStoreNames, |
| 366 OnObjectStoreNames) | 267 OnObjectStoreNames) |
| 367 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBDatabaseCreateObjectStore, | 268 IPC_MESSAGE_HANDLER_DELAY_REPLY(IndexedDBHostMsg_DatabaseCreateObjectStore, |
| 368 OnCreateObjectStore) | 269 OnCreateObjectStore) |
| 369 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBDatabaseDeleteObjectStore, | 270 IPC_MESSAGE_HANDLER_DELAY_REPLY(IndexedDBHostMsg_DatabaseDeleteObjectStore, |
| 370 OnDeleteObjectStore) | 271 OnDeleteObjectStore) |
| 371 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBDatabaseSetVersion, | 272 IPC_MESSAGE_HANDLER_DELAY_REPLY(IndexedDBHostMsg_DatabaseSetVersion, |
| 372 OnSetVersion) | 273 OnSetVersion) |
| 373 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBDatabaseTransaction, | 274 IPC_MESSAGE_HANDLER_DELAY_REPLY(IndexedDBHostMsg_DatabaseTransaction, |
| 374 OnTransaction) | 275 OnTransaction) |
| 375 IPC_MESSAGE_HANDLER(ViewHostMsg_IDBDatabaseDestroyed, OnDestroyed) | 276 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDestroyed, OnDestroyed) |
| 376 IPC_MESSAGE_UNHANDLED(handled = false) | 277 IPC_MESSAGE_UNHANDLED(handled = false) |
| 377 IPC_END_MESSAGE_MAP() | 278 IPC_END_MESSAGE_MAP() |
| 378 return handled; | 279 return handled; |
| 379 } | 280 } |
| 380 | 281 |
| 381 void IndexedDBDispatcherHost::DatabaseDispatcherHost::Send( | 282 void IndexedDBDispatcherHost::DatabaseDispatcherHost::Send( |
| 382 IPC::Message* message) { | 283 IPC::Message* message) { |
| 383 // The macro magic in OnMessageReceived requires this to link, but it should | 284 // The macro magic in OnMessageReceived requires this to link, but it should |
| 384 // never actually be called. | 285 // never actually be called. |
| 385 NOTREACHED(); | 286 NOTREACHED(); |
| 386 parent_->Send(message); | 287 parent_->Send(message); |
| 387 } | 288 } |
| 388 | 289 |
| 389 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnName( | 290 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnName( |
| 390 int32 object_id, IPC::Message* reply_msg) { | 291 int32 object_id, IPC::Message* reply_msg) { |
| 391 parent_->SyncGetter<string16, ViewHostMsg_IDBDatabaseName>( | 292 parent_->SyncGetter<string16, IndexedDBHostMsg_DatabaseName>( |
| 392 &map_, object_id, reply_msg, &WebIDBDatabase::name); | 293 &map_, object_id, reply_msg, &WebIDBDatabase::name); |
| 393 } | 294 } |
| 394 | 295 |
| 395 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnVersion( | 296 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnVersion( |
| 396 int32 object_id, IPC::Message* reply_msg) { | 297 int32 object_id, IPC::Message* reply_msg) { |
| 397 parent_->SyncGetter<string16, ViewHostMsg_IDBDatabaseVersion>( | 298 parent_->SyncGetter<string16, IndexedDBHostMsg_DatabaseVersion>( |
| 398 &map_, object_id, reply_msg, &WebIDBDatabase::version); | 299 &map_, object_id, reply_msg, &WebIDBDatabase::version); |
| 399 } | 300 } |
| 400 | 301 |
| 401 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnObjectStoreNames( | 302 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnObjectStoreNames( |
| 402 int32 idb_database_id, IPC::Message* reply_msg) { | 303 int32 idb_database_id, IPC::Message* reply_msg) { |
| 403 WebIDBDatabase* idb_database = parent_->GetOrTerminateProcess( | 304 WebIDBDatabase* idb_database = parent_->GetOrTerminateProcess( |
| 404 &map_, idb_database_id, reply_msg, | 305 &map_, idb_database_id, reply_msg, |
| 405 ViewHostMsg_IDBDatabaseObjectStoreNames::ID); | 306 IndexedDBHostMsg_DatabaseObjectStoreNames::ID); |
| 406 if (!idb_database) | 307 if (!idb_database) |
| 407 return; | 308 return; |
| 408 | 309 |
| 409 WebDOMStringList web_object_stores = idb_database->objectStoreNames(); | 310 WebDOMStringList web_object_stores = idb_database->objectStoreNames(); |
| 410 std::vector<string16> object_stores; | 311 std::vector<string16> object_stores; |
| 411 object_stores.reserve(web_object_stores.length()); | 312 object_stores.reserve(web_object_stores.length()); |
| 412 for (unsigned i = 0; i < web_object_stores.length(); ++i) | 313 for (unsigned i = 0; i < web_object_stores.length(); ++i) |
| 413 object_stores.push_back(web_object_stores.item(i)); | 314 object_stores.push_back(web_object_stores.item(i)); |
| 414 ViewHostMsg_IDBDatabaseObjectStoreNames::WriteReplyParams(reply_msg, | 315 IndexedDBHostMsg_DatabaseObjectStoreNames::WriteReplyParams(reply_msg, |
| 415 object_stores); | 316 object_stores); |
| 416 parent_->Send(reply_msg); | 317 parent_->Send(reply_msg); |
| 417 } | 318 } |
| 418 | 319 |
| 419 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCreateObjectStore( | 320 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCreateObjectStore( |
| 420 const ViewHostMsg_IDBDatabaseCreateObjectStore_Params& params, | 321 const IndexedDBHostMsg_DatabaseCreateObjectStore_Params& params, |
| 421 IPC::Message* reply_msg) { | 322 IPC::Message* reply_msg) { |
| 422 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 323 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
| 423 WebIDBDatabase* idb_database = parent_->GetOrTerminateProcess( | 324 WebIDBDatabase* idb_database = parent_->GetOrTerminateProcess( |
| 424 &map_, params.idb_database_id_, NULL, | 325 &map_, params.idb_database_id, NULL, |
| 425 ViewHostMsg_IDBDatabaseCreateObjectStore::ID); | 326 IndexedDBHostMsg_DatabaseCreateObjectStore::ID); |
| 426 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 327 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
| 427 &parent_->transaction_dispatcher_host_->map_, params.transaction_id_, | 328 &parent_->transaction_dispatcher_host_->map_, params.transaction_id, |
| 428 NULL, ViewHostMsg_IDBDatabaseCreateObjectStore::ID); | 329 NULL, IndexedDBHostMsg_DatabaseCreateObjectStore::ID); |
| 429 if (!idb_database || !idb_transaction) | 330 if (!idb_database || !idb_transaction) |
| 430 return; | 331 return; |
| 431 | 332 |
| 432 WebExceptionCode ec = 0; | 333 WebExceptionCode ec = 0; |
| 433 WebIDBObjectStore* object_store = idb_database->createObjectStore( | 334 WebIDBObjectStore* object_store = idb_database->createObjectStore( |
| 434 params.name_, params.key_path_, params.auto_increment_, | 335 params.name, params.key_path, params.auto_increment, |
| 435 *idb_transaction, ec); | 336 *idb_transaction, ec); |
| 436 ViewHostMsg_IDBDatabaseCreateObjectStore::WriteReplyParams( | 337 IndexedDBHostMsg_DatabaseCreateObjectStore::WriteReplyParams( |
| 437 reply_msg, ec ? 0 : parent_->Add(object_store), ec); | 338 reply_msg, ec ? 0 : parent_->Add(object_store), ec); |
| 438 parent_->Send(reply_msg); | 339 parent_->Send(reply_msg); |
| 439 } | 340 } |
| 440 | 341 |
| 441 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDeleteObjectStore( | 342 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDeleteObjectStore( |
| 442 int32 idb_database_id, | 343 int32 idb_database_id, |
| 443 const string16& name, | 344 const string16& name, |
| 444 int32 transaction_id, | 345 int32 transaction_id, |
| 445 IPC::Message* reply_msg) { | 346 IPC::Message* reply_msg) { |
| 446 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 347 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
| 447 WebIDBDatabase* idb_database = parent_->GetOrTerminateProcess( | 348 WebIDBDatabase* idb_database = parent_->GetOrTerminateProcess( |
| 448 &map_, idb_database_id, NULL, | 349 &map_, idb_database_id, NULL, |
| 449 ViewHostMsg_IDBDatabaseDeleteObjectStore::ID); | 350 IndexedDBHostMsg_DatabaseDeleteObjectStore::ID); |
| 450 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 351 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
| 451 &parent_->transaction_dispatcher_host_->map_, transaction_id, NULL, | 352 &parent_->transaction_dispatcher_host_->map_, transaction_id, NULL, |
| 452 ViewHostMsg_IDBDatabaseDeleteObjectStore::ID); | 353 IndexedDBHostMsg_DatabaseDeleteObjectStore::ID); |
| 453 if (!idb_database || !idb_transaction) | 354 if (!idb_database || !idb_transaction) |
| 454 return; | 355 return; |
| 455 | 356 |
| 456 WebExceptionCode ec = 0; | 357 WebExceptionCode ec = 0; |
| 457 idb_database->deleteObjectStore(name, *idb_transaction, ec); | 358 idb_database->deleteObjectStore(name, *idb_transaction, ec); |
| 458 ViewHostMsg_IDBDatabaseDeleteObjectStore::WriteReplyParams(reply_msg, ec); | 359 IndexedDBHostMsg_DatabaseDeleteObjectStore::WriteReplyParams(reply_msg, ec); |
| 459 parent_->Send(reply_msg); | 360 parent_->Send(reply_msg); |
| 460 } | 361 } |
| 461 | 362 |
| 462 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnSetVersion( | 363 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnSetVersion( |
| 463 int32 idb_database_id, | 364 int32 idb_database_id, |
| 464 int32 response_id, | 365 int32 response_id, |
| 465 const string16& version, | 366 const string16& version, |
| 466 IPC::Message* reply_msg) { | 367 IPC::Message* reply_msg) { |
| 467 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 368 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
| 468 WebIDBDatabase* idb_database = parent_->GetOrTerminateProcess( | 369 WebIDBDatabase* idb_database = parent_->GetOrTerminateProcess( |
| 469 &map_, idb_database_id, NULL, | 370 &map_, idb_database_id, NULL, |
| 470 ViewHostMsg_IDBDatabaseSetVersion::ID); | 371 IndexedDBHostMsg_DatabaseSetVersion::ID); |
| 471 if (!idb_database) | 372 if (!idb_database) |
| 472 return; | 373 return; |
| 473 | 374 |
| 474 WebExceptionCode ec = 0; | 375 WebExceptionCode ec = 0; |
| 475 idb_database->setVersion( | 376 idb_database->setVersion( |
| 476 version, | 377 version, |
| 477 new IndexedDBCallbacks<WebIDBTransaction>(parent_, response_id), | 378 new IndexedDBCallbacks<WebIDBTransaction>(parent_, response_id), |
| 478 ec); | 379 ec); |
| 479 ViewHostMsg_IDBDatabaseSetVersion::WriteReplyParams(reply_msg, ec); | 380 IndexedDBHostMsg_DatabaseSetVersion::WriteReplyParams(reply_msg, ec); |
| 480 parent_->Send(reply_msg); | 381 parent_->Send(reply_msg); |
| 481 } | 382 } |
| 482 | 383 |
| 483 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnTransaction( | 384 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnTransaction( |
| 484 int32 idb_database_id, | 385 int32 idb_database_id, |
| 485 const std::vector<string16>& names, | 386 const std::vector<string16>& names, |
| 486 int32 mode, | 387 int32 mode, |
| 487 int32 timeout, | 388 int32 timeout, |
| 488 IPC::Message* reply_msg) { | 389 IPC::Message* reply_msg) { |
| 489 WebIDBDatabase* database = parent_->GetOrTerminateProcess( | 390 WebIDBDatabase* database = parent_->GetOrTerminateProcess( |
| 490 &map_, idb_database_id, reply_msg, | 391 &map_, idb_database_id, reply_msg, |
| 491 ViewHostMsg_IDBDatabaseTransaction::ID); | 392 IndexedDBHostMsg_DatabaseTransaction::ID); |
| 492 if (!database) | 393 if (!database) |
| 493 return; | 394 return; |
| 494 | 395 |
| 495 WebDOMStringList object_stores; | 396 WebDOMStringList object_stores; |
| 496 for (std::vector<string16>::const_iterator it = names.begin(); | 397 for (std::vector<string16>::const_iterator it = names.begin(); |
| 497 it != names.end(); ++it) { | 398 it != names.end(); ++it) { |
| 498 object_stores.append(*it); | 399 object_stores.append(*it); |
| 499 } | 400 } |
| 500 | 401 |
| 501 WebExceptionCode ec = 0; | 402 WebExceptionCode ec = 0; |
| 502 WebIDBTransaction* transaction = database->transaction( | 403 WebIDBTransaction* transaction = database->transaction( |
| 503 object_stores, mode, timeout, ec); | 404 object_stores, mode, timeout, ec); |
| 504 DCHECK(!transaction != !ec); | 405 DCHECK(!transaction != !ec); |
| 505 int32 id = ec ? 0 : parent_->Add(transaction); | 406 int32 id = ec ? 0 : parent_->Add(transaction); |
| 506 ViewHostMsg_IDBDatabaseTransaction::WriteReplyParams(reply_msg, id, ec); | 407 IndexedDBHostMsg_DatabaseTransaction::WriteReplyParams(reply_msg, id, ec); |
| 507 parent_->Send(reply_msg); | 408 parent_->Send(reply_msg); |
| 508 } | 409 } |
| 509 | 410 |
| 510 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDestroyed( | 411 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDestroyed( |
| 511 int32 object_id) { | 412 int32 object_id) { |
| 512 parent_->DestroyObject(&map_, object_id, | 413 parent_->DestroyObject(&map_, object_id, |
| 513 ViewHostMsg_IDBDatabaseDestroyed::ID); | 414 IndexedDBHostMsg_DatabaseDestroyed::ID); |
| 514 } | 415 } |
| 515 | 416 |
| 516 | 417 |
| 517 ////////////////////////////////////////////////////////////////////// | 418 ////////////////////////////////////////////////////////////////////// |
| 518 // IndexedDBDispatcherHost::IndexDispatcherHost | 419 // IndexedDBDispatcherHost::IndexDispatcherHost |
| 519 // | 420 // |
| 520 | 421 |
| 521 IndexedDBDispatcherHost::IndexDispatcherHost::IndexDispatcherHost( | 422 IndexedDBDispatcherHost::IndexDispatcherHost::IndexDispatcherHost( |
| 522 IndexedDBDispatcherHost* parent) | 423 IndexedDBDispatcherHost* parent) |
| 523 : parent_(parent) { | 424 : parent_(parent) { |
| 524 map_.set_check_on_null_data(true); | 425 map_.set_check_on_null_data(true); |
| 525 } | 426 } |
| 526 | 427 |
| 527 IndexedDBDispatcherHost::IndexDispatcherHost::~IndexDispatcherHost() { | 428 IndexedDBDispatcherHost::IndexDispatcherHost::~IndexDispatcherHost() { |
| 528 } | 429 } |
| 529 | 430 |
| 530 bool IndexedDBDispatcherHost::IndexDispatcherHost::OnMessageReceived( | 431 bool IndexedDBDispatcherHost::IndexDispatcherHost::OnMessageReceived( |
| 531 const IPC::Message& message, bool* msg_is_ok) { | 432 const IPC::Message& message, bool* msg_is_ok) { |
| 532 bool handled = true; | 433 bool handled = true; |
| 533 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost::IndexDispatcherHost, | 434 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost::IndexDispatcherHost, |
| 534 message, *msg_is_ok) | 435 message, *msg_is_ok) |
| 535 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBIndexName, OnName) | 436 IPC_MESSAGE_HANDLER_DELAY_REPLY(IndexedDBHostMsg_IndexName, OnName) |
| 536 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBIndexStoreName, OnStoreName) | 437 IPC_MESSAGE_HANDLER_DELAY_REPLY(IndexedDBHostMsg_IndexStoreName, OnStoreName ) |
| 537 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBIndexKeyPath, OnKeyPath) | 438 IPC_MESSAGE_HANDLER_DELAY_REPLY(IndexedDBHostMsg_IndexKeyPath, OnKeyPath) |
| 538 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBIndexUnique, OnUnique) | 439 IPC_MESSAGE_HANDLER_DELAY_REPLY(IndexedDBHostMsg_IndexUnique, OnUnique) |
| 539 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBIndexOpenObjectCursor, | 440 IPC_MESSAGE_HANDLER_DELAY_REPLY(IndexedDBHostMsg_IndexOpenObjectCursor, |
| 540 OnOpenObjectCursor) | 441 OnOpenObjectCursor) |
| 541 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBIndexOpenKeyCursor, | 442 IPC_MESSAGE_HANDLER_DELAY_REPLY(IndexedDBHostMsg_IndexOpenKeyCursor, |
| 542 OnOpenKeyCursor) | 443 OnOpenKeyCursor) |
| 543 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBIndexGetObject, OnGetObject) | 444 IPC_MESSAGE_HANDLER_DELAY_REPLY(IndexedDBHostMsg_IndexGetObject, |
| 544 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBIndexGetKey, OnGetKey) | 445 OnGetObject) |
| 545 IPC_MESSAGE_HANDLER(ViewHostMsg_IDBIndexDestroyed, OnDestroyed) | 446 IPC_MESSAGE_HANDLER_DELAY_REPLY(IndexedDBHostMsg_IndexGetKey, OnGetKey) |
| 447 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexDestroyed, OnDestroyed) | |
| 546 IPC_MESSAGE_UNHANDLED(handled = false) | 448 IPC_MESSAGE_UNHANDLED(handled = false) |
| 547 IPC_END_MESSAGE_MAP() | 449 IPC_END_MESSAGE_MAP() |
| 548 return handled; | 450 return handled; |
| 549 } | 451 } |
| 550 | 452 |
| 551 void IndexedDBDispatcherHost::IndexDispatcherHost::Send( | 453 void IndexedDBDispatcherHost::IndexDispatcherHost::Send( |
| 552 IPC::Message* message) { | 454 IPC::Message* message) { |
| 553 // The macro magic in OnMessageReceived requires this to link, but it should | 455 // The macro magic in OnMessageReceived requires this to link, but it should |
| 554 // never actually be called. | 456 // never actually be called. |
| 555 NOTREACHED(); | 457 NOTREACHED(); |
| 556 parent_->Send(message); | 458 parent_->Send(message); |
| 557 } | 459 } |
| 558 | 460 |
| 559 void IndexedDBDispatcherHost::IndexDispatcherHost::OnName( | 461 void IndexedDBDispatcherHost::IndexDispatcherHost::OnName( |
| 560 int32 object_id, IPC::Message* reply_msg) { | 462 int32 object_id, IPC::Message* reply_msg) { |
| 561 parent_->SyncGetter<string16, ViewHostMsg_IDBIndexName>( | 463 parent_->SyncGetter<string16, IndexedDBHostMsg_IndexName>( |
| 562 &map_, object_id, reply_msg, &WebIDBIndex::name); | 464 &map_, object_id, reply_msg, &WebIDBIndex::name); |
| 563 } | 465 } |
| 564 | 466 |
| 565 void IndexedDBDispatcherHost::IndexDispatcherHost::OnStoreName( | 467 void IndexedDBDispatcherHost::IndexDispatcherHost::OnStoreName( |
| 566 int32 object_id, IPC::Message* reply_msg) { | 468 int32 object_id, IPC::Message* reply_msg) { |
| 567 parent_->SyncGetter<string16, ViewHostMsg_IDBIndexStoreName>( | 469 parent_->SyncGetter<string16, IndexedDBHostMsg_IndexStoreName>( |
| 568 &map_, object_id, reply_msg, &WebIDBIndex::storeName); | 470 &map_, object_id, reply_msg, &WebIDBIndex::storeName); |
| 569 } | 471 } |
| 570 | 472 |
| 571 void IndexedDBDispatcherHost::IndexDispatcherHost::OnKeyPath( | 473 void IndexedDBDispatcherHost::IndexDispatcherHost::OnKeyPath( |
| 572 int32 object_id, IPC::Message* reply_msg) { | 474 int32 object_id, IPC::Message* reply_msg) { |
| 573 parent_->SyncGetter<NullableString16, ViewHostMsg_IDBIndexKeyPath>( | 475 parent_->SyncGetter<NullableString16, IndexedDBHostMsg_IndexKeyPath>( |
| 574 &map_, object_id, reply_msg, &WebIDBIndex::keyPath); | 476 &map_, object_id, reply_msg, &WebIDBIndex::keyPath); |
| 575 } | 477 } |
| 576 | 478 |
| 577 void IndexedDBDispatcherHost::IndexDispatcherHost::OnUnique( | 479 void IndexedDBDispatcherHost::IndexDispatcherHost::OnUnique( |
| 578 int32 object_id, IPC::Message* reply_msg) { | 480 int32 object_id, IPC::Message* reply_msg) { |
| 579 parent_->SyncGetter<bool, ViewHostMsg_IDBIndexUnique>( | 481 parent_->SyncGetter<bool, IndexedDBHostMsg_IndexUnique>( |
| 580 &map_, object_id, reply_msg, &WebIDBIndex::unique); | 482 &map_, object_id, reply_msg, &WebIDBIndex::unique); |
| 581 } | 483 } |
| 582 | 484 |
| 583 void IndexedDBDispatcherHost::IndexDispatcherHost::OnOpenObjectCursor( | 485 void IndexedDBDispatcherHost::IndexDispatcherHost::OnOpenObjectCursor( |
| 584 const ViewHostMsg_IDBIndexOpenCursor_Params& params, | 486 const IndexedDBHostMsg_IndexOpenCursor_Params& params, |
| 585 IPC::Message* reply_msg) { | 487 IPC::Message* reply_msg) { |
| 586 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 488 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
| 587 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( | 489 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( |
| 588 &map_, params.idb_index_id_, NULL, | 490 &map_, params.idb_index_id, NULL, |
| 589 ViewHostMsg_IDBIndexOpenObjectCursor::ID); | 491 IndexedDBHostMsg_IndexOpenObjectCursor::ID); |
| 590 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 492 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
| 591 &parent_->transaction_dispatcher_host_->map_, | 493 &parent_->transaction_dispatcher_host_->map_, |
| 592 params.transaction_id_, NULL, ViewHostMsg_IDBIndexOpenObjectCursor::ID); | 494 params.transaction_id, NULL, IndexedDBHostMsg_IndexOpenObjectCursor::ID); |
| 593 if (!idb_transaction || !idb_index) | 495 if (!idb_transaction || !idb_index) |
| 594 return; | 496 return; |
| 595 | 497 |
| 596 scoped_ptr<WebIDBCallbacks> callbacks( | 498 scoped_ptr<WebIDBCallbacks> callbacks( |
| 597 new IndexedDBCallbacks<WebIDBCursor>(parent_, params.response_id_)); | 499 new IndexedDBCallbacks<WebIDBCursor>(parent_, params.response_id)); |
| 598 WebExceptionCode ec = 0; | 500 WebExceptionCode ec = 0; |
| 599 idb_index->openObjectCursor( | 501 idb_index->openObjectCursor( |
| 600 WebIDBKeyRange(params.lower_key_, params.upper_key_, params.lower_open_, | 502 WebIDBKeyRange(params.lower_key, params.upper_key, params.lower_open, |
| 601 params.upper_open_), | 503 params.upper_open), |
| 602 params.direction_, callbacks.release(), *idb_transaction, ec); | 504 params.direction, callbacks.release(), *idb_transaction, ec); |
| 603 ViewHostMsg_IDBIndexOpenObjectCursor::WriteReplyParams(reply_msg, ec); | 505 IndexedDBHostMsg_IndexOpenObjectCursor::WriteReplyParams(reply_msg, ec); |
| 604 parent_->Send(reply_msg); | 506 parent_->Send(reply_msg); |
| 605 } | 507 } |
| 606 | 508 |
| 607 void IndexedDBDispatcherHost::IndexDispatcherHost::OnOpenKeyCursor( | 509 void IndexedDBDispatcherHost::IndexDispatcherHost::OnOpenKeyCursor( |
| 608 const ViewHostMsg_IDBIndexOpenCursor_Params& params, | 510 const IndexedDBHostMsg_IndexOpenCursor_Params& params, |
| 609 IPC::Message* reply_msg) { | 511 IPC::Message* reply_msg) { |
| 610 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 512 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
| 611 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( | 513 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( |
| 612 &map_, params.idb_index_id_, NULL, ViewHostMsg_IDBIndexOpenKeyCursor::ID); | 514 &map_, params.idb_index_id, NULL, |
| 515 IndexedDBHostMsg_IndexOpenKeyCursor::ID); | |
| 613 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 516 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
| 614 &parent_->transaction_dispatcher_host_->map_, params.transaction_id_, | 517 &parent_->transaction_dispatcher_host_->map_, params.transaction_id, |
| 615 NULL, ViewHostMsg_IDBIndexOpenKeyCursor::ID); | 518 NULL, IndexedDBHostMsg_IndexOpenKeyCursor::ID); |
| 616 if (!idb_transaction || !idb_index) | 519 if (!idb_transaction || !idb_index) |
| 617 return; | 520 return; |
| 618 | 521 |
| 619 scoped_ptr<WebIDBCallbacks> callbacks( | 522 scoped_ptr<WebIDBCallbacks> callbacks( |
| 620 new IndexedDBCallbacks<WebIDBCursor>(parent_, params.response_id_)); | 523 new IndexedDBCallbacks<WebIDBCursor>(parent_, params.response_id)); |
| 621 WebExceptionCode ec = 0; | 524 WebExceptionCode ec = 0; |
| 622 idb_index->openKeyCursor( | 525 idb_index->openKeyCursor( |
| 623 WebIDBKeyRange(params.lower_key_, params.upper_key_, params.lower_open_, | 526 WebIDBKeyRange(params.lower_key, params.upper_key, params.lower_open, |
| 624 params.upper_open_), | 527 params.upper_open), |
| 625 params.direction_, callbacks.release(), *idb_transaction, ec); | 528 params.direction, callbacks.release(), *idb_transaction, ec); |
| 626 ViewHostMsg_IDBIndexOpenKeyCursor::WriteReplyParams(reply_msg, ec); | 529 IndexedDBHostMsg_IndexOpenKeyCursor::WriteReplyParams(reply_msg, ec); |
| 627 parent_->Send(reply_msg); | 530 parent_->Send(reply_msg); |
| 628 } | 531 } |
| 629 | 532 |
| 630 void IndexedDBDispatcherHost::IndexDispatcherHost::OnGetObject( | 533 void IndexedDBDispatcherHost::IndexDispatcherHost::OnGetObject( |
| 631 int idb_index_id, | 534 int idb_index_id, |
| 632 int32 response_id, | 535 int32 response_id, |
| 633 const IndexedDBKey& key, | 536 const IndexedDBKey& key, |
| 634 int32 transaction_id, | 537 int32 transaction_id, |
| 635 IPC::Message* reply_msg) { | 538 IPC::Message* reply_msg) { |
| 636 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 539 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
| 637 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( | 540 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( |
| 638 &map_, idb_index_id, NULL, ViewHostMsg_IDBIndexGetObject::ID); | 541 &map_, idb_index_id, NULL, IndexedDBHostMsg_IndexGetObject::ID); |
| 639 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 542 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
| 640 &parent_->transaction_dispatcher_host_->map_, transaction_id, NULL, | 543 &parent_->transaction_dispatcher_host_->map_, transaction_id, NULL, |
| 641 ViewHostMsg_IDBIndexGetObject::ID); | 544 IndexedDBHostMsg_IndexGetObject::ID); |
| 642 if (!idb_transaction || !idb_index) | 545 if (!idb_transaction || !idb_index) |
| 643 return; | 546 return; |
| 644 | 547 |
| 645 scoped_ptr<WebIDBCallbacks> callbacks( | 548 scoped_ptr<WebIDBCallbacks> callbacks( |
| 646 new IndexedDBCallbacks<WebSerializedScriptValue>(parent_, response_id)); | 549 new IndexedDBCallbacks<WebSerializedScriptValue>(parent_, response_id)); |
| 647 WebExceptionCode ec = 0; | 550 WebExceptionCode ec = 0; |
| 648 idb_index->getObject(key, callbacks.release(), *idb_transaction, ec); | 551 idb_index->getObject(key, callbacks.release(), *idb_transaction, ec); |
| 649 ViewHostMsg_IDBIndexGetObject::WriteReplyParams(reply_msg, ec); | 552 IndexedDBHostMsg_IndexGetObject::WriteReplyParams(reply_msg, ec); |
| 650 parent_->Send(reply_msg); | 553 parent_->Send(reply_msg); |
| 651 } | 554 } |
| 652 | 555 |
| 653 void IndexedDBDispatcherHost::IndexDispatcherHost::OnGetKey( | 556 void IndexedDBDispatcherHost::IndexDispatcherHost::OnGetKey( |
| 654 int idb_index_id, | 557 int idb_index_id, |
| 655 int32 response_id, | 558 int32 response_id, |
| 656 const IndexedDBKey& key, | 559 const IndexedDBKey& key, |
| 657 int32 transaction_id, | 560 int32 transaction_id, |
| 658 IPC::Message* reply_msg) { | 561 IPC::Message* reply_msg) { |
| 659 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 562 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
| 660 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( | 563 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( |
| 661 &map_, idb_index_id, NULL, ViewHostMsg_IDBIndexGetKey::ID); | 564 &map_, idb_index_id, NULL, IndexedDBHostMsg_IndexGetKey::ID); |
| 662 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 565 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
| 663 &parent_->transaction_dispatcher_host_->map_, transaction_id, NULL, | 566 &parent_->transaction_dispatcher_host_->map_, transaction_id, NULL, |
| 664 ViewHostMsg_IDBIndexGetKey::ID); | 567 IndexedDBHostMsg_IndexGetKey::ID); |
| 665 if (!idb_transaction || !idb_index) | 568 if (!idb_transaction || !idb_index) |
| 666 return; | 569 return; |
| 667 | 570 |
| 668 scoped_ptr<WebIDBCallbacks> callbacks( | 571 scoped_ptr<WebIDBCallbacks> callbacks( |
| 669 new IndexedDBCallbacks<WebIDBKey>(parent_, response_id)); | 572 new IndexedDBCallbacks<WebIDBKey>(parent_, response_id)); |
| 670 WebExceptionCode ec = 0; | 573 WebExceptionCode ec = 0; |
| 671 idb_index->getKey(key, callbacks.release(), *idb_transaction, ec); | 574 idb_index->getKey(key, callbacks.release(), *idb_transaction, ec); |
| 672 ViewHostMsg_IDBIndexGetKey::WriteReplyParams(reply_msg, ec); | 575 IndexedDBHostMsg_IndexGetKey::WriteReplyParams(reply_msg, ec); |
| 673 parent_->Send(reply_msg); | 576 parent_->Send(reply_msg); |
| 674 } | 577 } |
| 675 | 578 |
| 676 void IndexedDBDispatcherHost::IndexDispatcherHost::OnDestroyed( | 579 void IndexedDBDispatcherHost::IndexDispatcherHost::OnDestroyed( |
| 677 int32 object_id) { | 580 int32 object_id) { |
| 678 parent_->DestroyObject(&map_, object_id, ViewHostMsg_IDBIndexDestroyed::ID); | 581 parent_->DestroyObject(&map_, object_id, IndexedDBHostMsg_IndexDestroyed::ID); |
| 679 } | 582 } |
| 680 | 583 |
| 681 ////////////////////////////////////////////////////////////////////// | 584 ////////////////////////////////////////////////////////////////////// |
| 682 // IndexedDBDispatcherHost::ObjectStoreDispatcherHost | 585 // IndexedDBDispatcherHost::ObjectStoreDispatcherHost |
| 683 // | 586 // |
| 684 | 587 |
| 685 IndexedDBDispatcherHost::ObjectStoreDispatcherHost::ObjectStoreDispatcherHost( | 588 IndexedDBDispatcherHost::ObjectStoreDispatcherHost::ObjectStoreDispatcherHost( |
| 686 IndexedDBDispatcherHost* parent) | 589 IndexedDBDispatcherHost* parent) |
| 687 : parent_(parent) { | 590 : parent_(parent) { |
| 688 map_.set_check_on_null_data(true); | 591 map_.set_check_on_null_data(true); |
| 689 } | 592 } |
| 690 | 593 |
| 691 IndexedDBDispatcherHost:: | 594 IndexedDBDispatcherHost:: |
| 692 ObjectStoreDispatcherHost::~ObjectStoreDispatcherHost() { | 595 ObjectStoreDispatcherHost::~ObjectStoreDispatcherHost() { |
| 693 } | 596 } |
| 694 | 597 |
| 695 bool IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnMessageReceived( | 598 bool IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnMessageReceived( |
| 696 const IPC::Message& message, bool* msg_is_ok) { | 599 const IPC::Message& message, bool* msg_is_ok) { |
| 697 bool handled = true; | 600 bool handled = true; |
| 698 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost::ObjectStoreDispatcherHost, | 601 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost::ObjectStoreDispatcherHost, |
| 699 message, *msg_is_ok) | 602 message, *msg_is_ok) |
| 700 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBObjectStoreName, OnName) | 603 IPC_MESSAGE_HANDLER_DELAY_REPLY(IndexedDBHostMsg_ObjectStoreName, OnName) |
| 701 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBObjectStoreKeyPath, | 604 IPC_MESSAGE_HANDLER_DELAY_REPLY(IndexedDBHostMsg_ObjectStoreKeyPath, |
| 702 OnKeyPath) | 605 OnKeyPath) |
| 703 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBObjectStoreIndexNames, | 606 IPC_MESSAGE_HANDLER_DELAY_REPLY(IndexedDBHostMsg_ObjectStoreIndexNames, |
| 704 OnIndexNames) | 607 OnIndexNames) |
| 705 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBObjectStoreGet, OnGet); | 608 IPC_MESSAGE_HANDLER_DELAY_REPLY(IndexedDBHostMsg_ObjectStoreGet, OnGet); |
| 706 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBObjectStorePut, OnPut); | 609 IPC_MESSAGE_HANDLER_DELAY_REPLY(IndexedDBHostMsg_ObjectStorePut, OnPut); |
| 707 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBObjectStoreDelete, OnDelete); | 610 IPC_MESSAGE_HANDLER_DELAY_REPLY(IndexedDBHostMsg_ObjectStoreDelete, |
| 708 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBObjectStoreCreateIndex, | 611 OnDelete); |
| 612 IPC_MESSAGE_HANDLER_DELAY_REPLY(IndexedDBHostMsg_ObjectStoreCreateIndex, | |
| 709 OnCreateIndex); | 613 OnCreateIndex); |
| 710 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBObjectStoreIndex, OnIndex); | 614 IPC_MESSAGE_HANDLER_DELAY_REPLY(IndexedDBHostMsg_ObjectStoreIndex, OnIndex) |
| 711 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBObjectStoreDeleteIndex, | 615 IPC_MESSAGE_HANDLER_DELAY_REPLY(IndexedDBHostMsg_ObjectStoreDeleteIndex, |
| 712 OnDeleteIndex); | 616 OnDeleteIndex); |
| 713 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBObjectStoreOpenCursor, | 617 IPC_MESSAGE_HANDLER_DELAY_REPLY(IndexedDBHostMsg_ObjectStoreOpenCursor, |
| 714 OnOpenCursor) | 618 OnOpenCursor) |
| 715 IPC_MESSAGE_HANDLER(ViewHostMsg_IDBObjectStoreDestroyed, OnDestroyed) | 619 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreDestroyed, OnDestroyed) |
| 716 IPC_MESSAGE_UNHANDLED(handled = false) | 620 IPC_MESSAGE_UNHANDLED(handled = false) |
| 717 IPC_END_MESSAGE_MAP() | 621 IPC_END_MESSAGE_MAP() |
| 718 return handled; | 622 return handled; |
| 719 } | 623 } |
| 720 | 624 |
| 721 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::Send( | 625 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::Send( |
| 722 IPC::Message* message) { | 626 IPC::Message* message) { |
| 723 // The macro magic in OnMessageReceived requires this to link, but it should | 627 // The macro magic in OnMessageReceived requires this to link, but it should |
| 724 // never actually be called. | 628 // never actually be called. |
| 725 NOTREACHED(); | 629 NOTREACHED(); |
| 726 parent_->Send(message); | 630 parent_->Send(message); |
| 727 } | 631 } |
| 728 | 632 |
| 729 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnName( | 633 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnName( |
| 730 int32 object_id, IPC::Message* reply_msg) { | 634 int32 object_id, IPC::Message* reply_msg) { |
| 731 parent_->SyncGetter<string16, ViewHostMsg_IDBObjectStoreName>( | 635 parent_->SyncGetter<string16, IndexedDBHostMsg_ObjectStoreName>( |
| 732 &map_, object_id, reply_msg, &WebIDBObjectStore::name); | 636 &map_, object_id, reply_msg, &WebIDBObjectStore::name); |
| 733 } | 637 } |
| 734 | 638 |
| 735 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnKeyPath( | 639 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnKeyPath( |
| 736 int32 object_id, IPC::Message* reply_msg) { | 640 int32 object_id, IPC::Message* reply_msg) { |
| 737 parent_->SyncGetter<NullableString16, ViewHostMsg_IDBObjectStoreKeyPath>( | 641 parent_->SyncGetter<NullableString16, IndexedDBHostMsg_ObjectStoreKeyPath>( |
| 738 &map_, object_id, reply_msg, &WebIDBObjectStore::keyPath); | 642 &map_, object_id, reply_msg, &WebIDBObjectStore::keyPath); |
| 739 } | 643 } |
| 740 | 644 |
| 741 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnIndexNames( | 645 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnIndexNames( |
| 742 int32 idb_object_store_id, IPC::Message* reply_msg) { | 646 int32 idb_object_store_id, IPC::Message* reply_msg) { |
| 743 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( | 647 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( |
| 744 &map_, idb_object_store_id, reply_msg, | 648 &map_, idb_object_store_id, reply_msg, |
| 745 ViewHostMsg_IDBObjectStoreIndexNames::ID); | 649 IndexedDBHostMsg_ObjectStoreIndexNames::ID); |
| 746 if (!idb_object_store) | 650 if (!idb_object_store) |
| 747 return; | 651 return; |
| 748 | 652 |
| 749 WebDOMStringList web_index_names = idb_object_store->indexNames(); | 653 WebDOMStringList web_index_names = idb_object_store->indexNames(); |
| 750 std::vector<string16> index_names; | 654 std::vector<string16> index_names; |
| 751 index_names.reserve(web_index_names.length()); | 655 index_names.reserve(web_index_names.length()); |
| 752 for (unsigned i = 0; i < web_index_names.length(); ++i) | 656 for (unsigned i = 0; i < web_index_names.length(); ++i) |
| 753 index_names.push_back(web_index_names.item(i)); | 657 index_names.push_back(web_index_names.item(i)); |
| 754 ViewHostMsg_IDBObjectStoreIndexNames::WriteReplyParams(reply_msg, | 658 IndexedDBHostMsg_ObjectStoreIndexNames::WriteReplyParams(reply_msg, |
| 755 index_names); | 659 index_names); |
| 756 parent_->Send(reply_msg); | 660 parent_->Send(reply_msg); |
| 757 } | 661 } |
| 758 | 662 |
| 759 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnGet( | 663 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnGet( |
| 760 int idb_object_store_id, | 664 int idb_object_store_id, |
| 761 int32 response_id, | 665 int32 response_id, |
| 762 const IndexedDBKey& key, | 666 const IndexedDBKey& key, |
| 763 int32 transaction_id, | 667 int32 transaction_id, |
| 764 IPC::Message* reply_msg) { | 668 IPC::Message* reply_msg) { |
| 765 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 669 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
| 766 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( | 670 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( |
| 767 &map_, idb_object_store_id, NULL, ViewHostMsg_IDBObjectStoreGet::ID); | 671 &map_, idb_object_store_id, NULL, IndexedDBHostMsg_ObjectStoreGet::ID); |
| 768 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 672 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
| 769 &parent_->transaction_dispatcher_host_->map_, transaction_id, NULL, | 673 &parent_->transaction_dispatcher_host_->map_, transaction_id, NULL, |
| 770 ViewHostMsg_IDBObjectStoreGet::ID); | 674 IndexedDBHostMsg_ObjectStoreGet::ID); |
| 771 if (!idb_transaction || !idb_object_store) | 675 if (!idb_transaction || !idb_object_store) |
| 772 return; | 676 return; |
| 773 | 677 |
| 774 scoped_ptr<WebIDBCallbacks> callbacks( | 678 scoped_ptr<WebIDBCallbacks> callbacks( |
| 775 new IndexedDBCallbacks<WebSerializedScriptValue>(parent_, response_id)); | 679 new IndexedDBCallbacks<WebSerializedScriptValue>(parent_, response_id)); |
| 776 WebExceptionCode ec = 0; | 680 WebExceptionCode ec = 0; |
| 777 idb_object_store->get(key, callbacks.release(), *idb_transaction, ec); | 681 idb_object_store->get(key, callbacks.release(), *idb_transaction, ec); |
| 778 ViewHostMsg_IDBObjectStoreGet::WriteReplyParams(reply_msg, ec); | 682 IndexedDBHostMsg_ObjectStoreGet::WriteReplyParams(reply_msg, ec); |
| 779 parent_->Send(reply_msg); | 683 parent_->Send(reply_msg); |
| 780 } | 684 } |
| 781 | 685 |
| 782 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnPut( | 686 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnPut( |
| 783 const ViewHostMsg_IDBObjectStorePut_Params& params, | 687 const IndexedDBHostMsg_ObjectStorePut_Params& params, |
| 784 IPC::Message* reply_msg) { | 688 IPC::Message* reply_msg) { |
| 785 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 689 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
| 786 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( | 690 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( |
| 787 &map_, params.idb_object_store_id_, NULL, | 691 &map_, params.idb_object_store_id, NULL, |
| 788 ViewHostMsg_IDBObjectStorePut::ID); | 692 IndexedDBHostMsg_ObjectStorePut::ID); |
| 789 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 693 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
| 790 &parent_->transaction_dispatcher_host_->map_, params.transaction_id_, | 694 &parent_->transaction_dispatcher_host_->map_, params.transaction_id, |
| 791 NULL, ViewHostMsg_IDBObjectStorePut::ID); | 695 NULL, IndexedDBHostMsg_ObjectStorePut::ID); |
| 792 if (!idb_transaction || !idb_object_store) | 696 if (!idb_transaction || !idb_object_store) |
| 793 return; | 697 return; |
| 794 | 698 |
| 795 scoped_ptr<WebIDBCallbacks> callbacks( | 699 scoped_ptr<WebIDBCallbacks> callbacks( |
| 796 new IndexedDBCallbacks<WebIDBKey>(parent_, params.response_id_)); | 700 new IndexedDBCallbacks<WebIDBKey>(parent_, params.response_id)); |
| 797 WebExceptionCode ec = 0; | 701 WebExceptionCode ec = 0; |
| 798 idb_object_store->put(params.serialized_value_, params.key_, params.add_only_, | 702 idb_object_store->put(params.serialized_value, params.key, params.add_only, |
| 799 callbacks.release(), *idb_transaction, ec); | 703 callbacks.release(), *idb_transaction, ec); |
| 800 ViewHostMsg_IDBObjectStorePut::WriteReplyParams(reply_msg, ec); | 704 IndexedDBHostMsg_ObjectStorePut::WriteReplyParams(reply_msg, ec); |
| 801 parent_->Send(reply_msg); | 705 parent_->Send(reply_msg); |
| 802 } | 706 } |
| 803 | 707 |
| 804 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnDelete( | 708 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnDelete( |
| 805 int idb_object_store_id, | 709 int idb_object_store_id, |
| 806 int32 response_id, | 710 int32 response_id, |
| 807 const IndexedDBKey& key, | 711 const IndexedDBKey& key, |
| 808 int32 transaction_id, | 712 int32 transaction_id, |
| 809 IPC::Message* reply_msg) { | 713 IPC::Message* reply_msg) { |
| 810 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 714 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
| 811 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( | 715 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( |
| 812 &map_, idb_object_store_id, NULL, ViewHostMsg_IDBObjectStoreDelete::ID); | 716 &map_, idb_object_store_id, NULL, IndexedDBHostMsg_ObjectStoreDelete::ID); |
| 813 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 717 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
| 814 &parent_->transaction_dispatcher_host_->map_, transaction_id, NULL, | 718 &parent_->transaction_dispatcher_host_->map_, transaction_id, NULL, |
| 815 ViewHostMsg_IDBObjectStoreDelete::ID); | 719 IndexedDBHostMsg_ObjectStoreDelete::ID); |
| 816 if (!idb_transaction || !idb_object_store) | 720 if (!idb_transaction || !idb_object_store) |
| 817 return; | 721 return; |
| 818 | 722 |
| 819 scoped_ptr<WebIDBCallbacks> callbacks( | 723 scoped_ptr<WebIDBCallbacks> callbacks( |
| 820 new IndexedDBCallbacks<void>(parent_, response_id)); | 724 new IndexedDBCallbacks<void>(parent_, response_id)); |
| 821 WebExceptionCode ec = 0; | 725 WebExceptionCode ec = 0; |
| 822 idb_object_store->deleteFunction(key, callbacks.release(), *idb_transaction, e c); | 726 idb_object_store->deleteFunction( |
| 823 ViewHostMsg_IDBObjectStoreDelete::WriteReplyParams(reply_msg, ec); | 727 key, callbacks.release(), *idb_transaction, ec); |
| 728 IndexedDBHostMsg_ObjectStoreDelete::WriteReplyParams(reply_msg, ec); | |
| 824 parent_->Send(reply_msg); | 729 parent_->Send(reply_msg); |
| 825 } | 730 } |
| 826 | 731 |
| 827 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnCreateIndex( | 732 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnCreateIndex( |
| 828 const ViewHostMsg_IDBObjectStoreCreateIndex_Params& params, | 733 const IndexedDBHostMsg_ObjectStoreCreateIndex_Params& params, |
| 829 IPC::Message* reply_msg) { | 734 IPC::Message* reply_msg) { |
| 830 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 735 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
| 831 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( | 736 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( |
| 832 &map_, params.idb_object_store_id_, NULL, | 737 &map_, params.idb_object_store_id, NULL, |
| 833 ViewHostMsg_IDBObjectStoreCreateIndex::ID); | 738 IndexedDBHostMsg_ObjectStoreCreateIndex::ID); |
| 834 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 739 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
| 835 &parent_->transaction_dispatcher_host_->map_, params.transaction_id_, | 740 &parent_->transaction_dispatcher_host_->map_, params.transaction_id, |
| 836 NULL, ViewHostMsg_IDBObjectStoreCreateIndex::ID); | 741 NULL, IndexedDBHostMsg_ObjectStoreCreateIndex::ID); |
| 837 if (!idb_object_store || !idb_transaction) | 742 if (!idb_object_store || !idb_transaction) |
| 838 return; | 743 return; |
| 839 | 744 |
| 840 WebExceptionCode ec = 0; | 745 WebExceptionCode ec = 0; |
| 841 WebIDBIndex* index = idb_object_store->createIndex( | 746 WebIDBIndex* index = idb_object_store->createIndex( |
| 842 params.name_, params.key_path_, params.unique_, *idb_transaction, ec); | 747 params.name, params.key_path, params.unique, *idb_transaction, ec); |
| 843 ViewHostMsg_IDBObjectStoreCreateIndex::WriteReplyParams( | 748 IndexedDBHostMsg_ObjectStoreCreateIndex::WriteReplyParams( |
| 844 reply_msg, ec ? 0 : parent_->Add(index), ec); | 749 reply_msg, ec ? 0 : parent_->Add(index), ec); |
| 845 parent_->Send(reply_msg); | 750 parent_->Send(reply_msg); |
| 846 } | 751 } |
| 847 | 752 |
| 848 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnIndex( | 753 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnIndex( |
| 849 int32 idb_object_store_id, | 754 int32 idb_object_store_id, |
| 850 const string16& name, | 755 const string16& name, |
| 851 IPC::Message* reply_msg) { | 756 IPC::Message* reply_msg) { |
| 852 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( | 757 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( |
| 853 &map_, idb_object_store_id, reply_msg, | 758 &map_, idb_object_store_id, reply_msg, |
| 854 ViewHostMsg_IDBObjectStoreIndex::ID); | 759 IndexedDBHostMsg_ObjectStoreIndex::ID); |
| 855 if (!idb_object_store) | 760 if (!idb_object_store) |
| 856 return; | 761 return; |
| 857 | 762 |
| 858 WebExceptionCode ec = 0; | 763 WebExceptionCode ec = 0; |
| 859 WebIDBIndex* index = idb_object_store->index(name, ec); | 764 WebIDBIndex* index = idb_object_store->index(name, ec); |
| 860 int32 object_id = parent_->Add(index); | 765 int32 object_id = parent_->Add(index); |
| 861 ViewHostMsg_IDBObjectStoreIndex::WriteReplyParams(reply_msg, object_id, ec); | 766 IndexedDBHostMsg_ObjectStoreIndex::WriteReplyParams(reply_msg, object_id, ec); |
| 862 parent_->Send(reply_msg); | 767 parent_->Send(reply_msg); |
| 863 } | 768 } |
| 864 | 769 |
| 865 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnDeleteIndex( | 770 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnDeleteIndex( |
| 866 int32 idb_object_store_id, | 771 int32 idb_object_store_id, |
| 867 const string16& name, | 772 const string16& name, |
| 868 int32 transaction_id, | 773 int32 transaction_id, |
| 869 IPC::Message* reply_msg) { | 774 IPC::Message* reply_msg) { |
| 870 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 775 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
| 871 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( | 776 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( |
| 872 &map_, idb_object_store_id, NULL, | 777 &map_, idb_object_store_id, NULL, |
| 873 ViewHostMsg_IDBObjectStoreDeleteIndex::ID); | 778 IndexedDBHostMsg_ObjectStoreDeleteIndex::ID); |
| 874 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 779 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
| 875 &parent_->transaction_dispatcher_host_->map_, transaction_id, NULL, | 780 &parent_->transaction_dispatcher_host_->map_, transaction_id, NULL, |
| 876 ViewHostMsg_IDBObjectStoreDeleteIndex::ID); | 781 IndexedDBHostMsg_ObjectStoreDeleteIndex::ID); |
| 877 if (!idb_object_store || !idb_transaction) | 782 if (!idb_object_store || !idb_transaction) |
| 878 return; | 783 return; |
| 879 | 784 |
| 880 WebExceptionCode ec = 0; | 785 WebExceptionCode ec = 0; |
| 881 idb_object_store->deleteIndex(name, *idb_transaction, ec); | 786 idb_object_store->deleteIndex(name, *idb_transaction, ec); |
| 882 ViewHostMsg_IDBObjectStoreDeleteIndex::WriteReplyParams(reply_msg, ec); | 787 IndexedDBHostMsg_ObjectStoreDeleteIndex::WriteReplyParams(reply_msg, ec); |
| 883 parent_->Send(reply_msg); | 788 parent_->Send(reply_msg); |
| 884 } | 789 } |
| 885 | 790 |
| 886 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnOpenCursor( | 791 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnOpenCursor( |
| 887 const ViewHostMsg_IDBObjectStoreOpenCursor_Params& params, | 792 const IndexedDBHostMsg_ObjectStoreOpenCursor_Params& params, |
| 888 IPC::Message* reply_msg) { | 793 IPC::Message* reply_msg) { |
| 889 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 794 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
| 890 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( | 795 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( |
| 891 &parent_->object_store_dispatcher_host_->map_, | 796 &parent_->object_store_dispatcher_host_->map_, |
| 892 params.idb_object_store_id_, NULL, | 797 params.idb_object_store_id, NULL, |
| 893 ViewHostMsg_IDBObjectStoreOpenCursor::ID); | 798 IndexedDBHostMsg_ObjectStoreOpenCursor::ID); |
| 894 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 799 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
| 895 &parent_->transaction_dispatcher_host_->map_, params.transaction_id_, | 800 &parent_->transaction_dispatcher_host_->map_, params.transaction_id, |
| 896 NULL, ViewHostMsg_IDBObjectStoreOpenCursor::ID); | 801 NULL, IndexedDBHostMsg_ObjectStoreOpenCursor::ID); |
| 897 if (!idb_transaction || !idb_object_store) | 802 if (!idb_transaction || !idb_object_store) |
| 898 return; | 803 return; |
| 899 | 804 |
| 900 scoped_ptr<WebIDBCallbacks> callbacks( | 805 scoped_ptr<WebIDBCallbacks> callbacks( |
| 901 new IndexedDBCallbacks<WebIDBCursor>(parent_, params.response_id_)); | 806 new IndexedDBCallbacks<WebIDBCursor>(parent_, params.response_id)); |
| 902 WebExceptionCode ec = 0; | 807 WebExceptionCode ec = 0; |
| 903 idb_object_store->openCursor( | 808 idb_object_store->openCursor( |
| 904 WebIDBKeyRange(params.lower_key_, params.upper_key_, params.lower_open_, | 809 WebIDBKeyRange(params.lower_key, params.upper_key, params.lower_open, |
| 905 params.upper_open_), | 810 params.upper_open), |
| 906 params.direction_, callbacks.release(), *idb_transaction, ec); | 811 params.direction, callbacks.release(), *idb_transaction, ec); |
| 907 ViewHostMsg_IDBObjectStoreOpenCursor::WriteReplyParams(reply_msg, ec); | 812 IndexedDBHostMsg_ObjectStoreOpenCursor::WriteReplyParams(reply_msg, ec); |
| 908 parent_->Send(reply_msg); | 813 parent_->Send(reply_msg); |
| 909 } | 814 } |
| 910 | 815 |
| 911 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnDestroyed( | 816 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnDestroyed( |
| 912 int32 object_id) { | 817 int32 object_id) { |
| 913 parent_->DestroyObject( | 818 parent_->DestroyObject( |
| 914 &map_, object_id, ViewHostMsg_IDBObjectStoreDestroyed::ID); | 819 &map_, object_id, IndexedDBHostMsg_ObjectStoreDestroyed::ID); |
| 915 } | 820 } |
| 916 | 821 |
| 917 ////////////////////////////////////////////////////////////////////// | 822 ////////////////////////////////////////////////////////////////////// |
| 918 // IndexedDBDispatcherHost::CursorDispatcherHost | 823 // IndexedDBDispatcherHost::CursorDispatcherHost |
| 919 // | 824 // |
| 920 | 825 |
| 921 IndexedDBDispatcherHost::CursorDispatcherHost::CursorDispatcherHost( | 826 IndexedDBDispatcherHost::CursorDispatcherHost::CursorDispatcherHost( |
| 922 IndexedDBDispatcherHost* parent) | 827 IndexedDBDispatcherHost* parent) |
| 923 : parent_(parent) { | 828 : parent_(parent) { |
| 924 map_.set_check_on_null_data(true); | 829 map_.set_check_on_null_data(true); |
| 925 } | 830 } |
| 926 | 831 |
| 927 IndexedDBDispatcherHost::CursorDispatcherHost::~CursorDispatcherHost() { | 832 IndexedDBDispatcherHost::CursorDispatcherHost::~CursorDispatcherHost() { |
| 928 } | 833 } |
| 929 | 834 |
| 930 bool IndexedDBDispatcherHost::CursorDispatcherHost::OnMessageReceived( | 835 bool IndexedDBDispatcherHost::CursorDispatcherHost::OnMessageReceived( |
| 931 const IPC::Message& message, bool* msg_is_ok) { | 836 const IPC::Message& message, bool* msg_is_ok) { |
| 932 bool handled = true; | 837 bool handled = true; |
| 933 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost::CursorDispatcherHost, | 838 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost::CursorDispatcherHost, |
| 934 message, *msg_is_ok) | 839 message, *msg_is_ok) |
| 935 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBCursorDirection, | 840 IPC_MESSAGE_HANDLER_DELAY_REPLY(IndexedDBHostMsg_CursorDirection, |
| 936 OnDirection) | 841 OnDirection) |
| 937 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBCursorKey, OnKey) | 842 IPC_MESSAGE_HANDLER_DELAY_REPLY(IndexedDBHostMsg_CursorKey, OnKey) |
| 938 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBCursorValue, OnValue) | 843 IPC_MESSAGE_HANDLER_DELAY_REPLY(IndexedDBHostMsg_CursorValue, OnValue) |
| 939 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBCursorUpdate, OnUpdate) | 844 IPC_MESSAGE_HANDLER_DELAY_REPLY(IndexedDBHostMsg_CursorUpdate, OnUpdate) |
| 940 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBCursorContinue, OnContinue) | 845 IPC_MESSAGE_HANDLER_DELAY_REPLY(IndexedDBHostMsg_CursorContinue, OnContinue) |
| 941 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBCursorDelete, OnDelete) | 846 IPC_MESSAGE_HANDLER_DELAY_REPLY(IndexedDBHostMsg_CursorDelete, OnDelete) |
| 942 IPC_MESSAGE_HANDLER(ViewHostMsg_IDBCursorDestroyed, OnDestroyed) | 847 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_CursorDestroyed, OnDestroyed) |
| 943 IPC_MESSAGE_UNHANDLED(handled = false) | 848 IPC_MESSAGE_UNHANDLED(handled = false) |
| 944 IPC_END_MESSAGE_MAP() | 849 IPC_END_MESSAGE_MAP() |
| 945 return handled; | 850 return handled; |
| 946 } | 851 } |
| 947 | 852 |
| 948 | 853 |
| 949 void IndexedDBDispatcherHost::CursorDispatcherHost::Send( | 854 void IndexedDBDispatcherHost::CursorDispatcherHost::Send( |
| 950 IPC::Message* message) { | 855 IPC::Message* message) { |
| 951 // The macro magic in OnMessageReceived requires this to link, but it should | 856 // The macro magic in OnMessageReceived requires this to link, but it should |
| 952 // never actually be called. | 857 // never actually be called. |
| 953 NOTREACHED(); | 858 NOTREACHED(); |
| 954 parent_->Send(message); | 859 parent_->Send(message); |
| 955 } | 860 } |
| 956 | 861 |
| 957 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDirection( | 862 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDirection( |
| 958 int32 object_id, IPC::Message* reply_msg) { | 863 int32 object_id, IPC::Message* reply_msg) { |
| 959 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess( | 864 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess( |
| 960 &map_, object_id, reply_msg, | 865 &map_, object_id, reply_msg, IndexedDBHostMsg_CursorDirection::ID); |
| 961 ViewHostMsg_IDBCursorDirection::ID); | |
| 962 if (!idb_cursor) | 866 if (!idb_cursor) |
| 963 return; | 867 return; |
| 964 | 868 |
| 965 int direction = idb_cursor->direction(); | 869 int direction = idb_cursor->direction(); |
| 966 ViewHostMsg_IDBCursorDirection::WriteReplyParams(reply_msg, direction); | 870 IndexedDBHostMsg_CursorDirection::WriteReplyParams(reply_msg, direction); |
| 967 parent_->Send(reply_msg); | 871 parent_->Send(reply_msg); |
| 968 } | 872 } |
| 969 | 873 |
| 970 void IndexedDBDispatcherHost::CursorDispatcherHost::OnKey( | 874 void IndexedDBDispatcherHost::CursorDispatcherHost::OnKey( |
| 971 int32 object_id, IPC::Message* reply_msg) { | 875 int32 object_id, IPC::Message* reply_msg) { |
| 972 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess( | 876 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess( |
| 973 &map_, object_id, reply_msg, | 877 &map_, object_id, reply_msg, IndexedDBHostMsg_CursorKey::ID); |
| 974 ViewHostMsg_IDBCursorKey::ID); | |
| 975 if (!idb_cursor) | 878 if (!idb_cursor) |
| 976 return; | 879 return; |
| 977 | 880 |
| 978 IndexedDBKey key(idb_cursor->key()); | 881 IndexedDBKey key(idb_cursor->key()); |
| 979 ViewHostMsg_IDBCursorKey::WriteReplyParams(reply_msg, key); | 882 IndexedDBHostMsg_CursorKey::WriteReplyParams(reply_msg, key); |
| 980 parent_->Send(reply_msg); | 883 parent_->Send(reply_msg); |
| 981 } | 884 } |
| 982 | 885 |
| 983 void IndexedDBDispatcherHost::CursorDispatcherHost::OnValue( | 886 void IndexedDBDispatcherHost::CursorDispatcherHost::OnValue( |
| 984 int32 object_id, IPC::Message* reply_msg) { | 887 int32 object_id, IPC::Message* reply_msg) { |
| 985 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess( | 888 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess( |
| 986 &map_, object_id, reply_msg, | 889 &map_, object_id, reply_msg, IndexedDBHostMsg_CursorValue::ID); |
| 987 ViewHostMsg_IDBCursorValue::ID); | |
| 988 if (!idb_cursor) | 890 if (!idb_cursor) |
| 989 return; | 891 return; |
| 990 | 892 |
| 991 WebSerializedScriptValue scriptValue; | 893 WebSerializedScriptValue scriptValue; |
| 992 WebIDBKey key; | 894 WebIDBKey key; |
| 993 idb_cursor->value(scriptValue, key); | 895 idb_cursor->value(scriptValue, key); |
| 994 ViewHostMsg_IDBCursorValue::WriteReplyParams( | 896 IndexedDBHostMsg_CursorValue::WriteReplyParams( |
| 995 reply_msg, SerializedScriptValue(scriptValue), IndexedDBKey(key)); | 897 reply_msg, SerializedScriptValue(scriptValue), IndexedDBKey(key)); |
| 996 parent_->Send(reply_msg); | 898 parent_->Send(reply_msg); |
| 997 } | 899 } |
| 998 | 900 |
| 999 void IndexedDBDispatcherHost::CursorDispatcherHost::OnUpdate( | 901 void IndexedDBDispatcherHost::CursorDispatcherHost::OnUpdate( |
| 1000 int32 cursor_id, | 902 int32 cursor_id, |
| 1001 int32 response_id, | 903 int32 response_id, |
| 1002 const SerializedScriptValue& value, | 904 const SerializedScriptValue& value, |
| 1003 IPC::Message* reply_msg) { | 905 IPC::Message* reply_msg) { |
| 1004 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 906 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
| 1005 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess( | 907 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess( |
| 1006 &map_, cursor_id, NULL, ViewHostMsg_IDBCursorUpdate::ID); | 908 &map_, cursor_id, NULL, IndexedDBHostMsg_CursorUpdate::ID); |
| 1007 if (!idb_cursor) | 909 if (!idb_cursor) |
| 1008 return; | 910 return; |
| 1009 | 911 |
| 1010 WebExceptionCode ec = 0; | 912 WebExceptionCode ec = 0; |
| 1011 idb_cursor->update( | 913 idb_cursor->update( |
| 1012 value, new IndexedDBCallbacks<void>(parent_, response_id), ec); | 914 value, new IndexedDBCallbacks<void>(parent_, response_id), ec); |
| 1013 ViewHostMsg_IDBCursorUpdate::WriteReplyParams(reply_msg, ec); | 915 IndexedDBHostMsg_CursorUpdate::WriteReplyParams(reply_msg, ec); |
| 1014 parent_->Send(reply_msg); | 916 parent_->Send(reply_msg); |
| 1015 } | 917 } |
| 1016 | 918 |
| 1017 void IndexedDBDispatcherHost::CursorDispatcherHost::OnContinue( | 919 void IndexedDBDispatcherHost::CursorDispatcherHost::OnContinue( |
| 1018 int32 cursor_id, | 920 int32 cursor_id, |
| 1019 int32 response_id, | 921 int32 response_id, |
| 1020 const IndexedDBKey& key, | 922 const IndexedDBKey& key, |
| 1021 IPC::Message* reply_msg) { | 923 IPC::Message* reply_msg) { |
| 1022 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 924 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
| 1023 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess( | 925 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess( |
| 1024 &map_, cursor_id, NULL, ViewHostMsg_IDBCursorContinue::ID); | 926 &map_, cursor_id, NULL, IndexedDBHostMsg_CursorContinue::ID); |
| 1025 if (!idb_cursor) | 927 if (!idb_cursor) |
| 1026 return; | 928 return; |
| 1027 | 929 |
| 1028 WebExceptionCode ec = 0; | 930 WebExceptionCode ec = 0; |
| 1029 idb_cursor->continueFunction( | 931 idb_cursor->continueFunction( |
| 1030 key, new IndexedDBCallbacks<WebIDBCursor>(parent_, response_id), ec); | 932 key, new IndexedDBCallbacks<WebIDBCursor>(parent_, response_id), ec); |
| 1031 ViewHostMsg_IDBCursorContinue::WriteReplyParams(reply_msg, ec); | 933 IndexedDBHostMsg_CursorContinue::WriteReplyParams(reply_msg, ec); |
| 1032 parent_->Send(reply_msg); | 934 parent_->Send(reply_msg); |
| 1033 } | 935 } |
| 1034 | 936 |
| 1035 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDelete( | 937 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDelete( |
| 1036 int32 cursor_id, | 938 int32 cursor_id, |
| 1037 int32 response_id, | 939 int32 response_id, |
| 1038 IPC::Message* reply_msg) { | 940 IPC::Message* reply_msg) { |
| 1039 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 941 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
| 1040 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess( | 942 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess( |
| 1041 &map_, cursor_id, NULL, ViewHostMsg_IDBCursorUpdate::ID); | 943 &map_, cursor_id, NULL, IndexedDBHostMsg_CursorUpdate::ID); |
| 1042 if (!idb_cursor) | 944 if (!idb_cursor) |
| 1043 return; | 945 return; |
| 1044 | 946 |
| 1045 WebExceptionCode ec = 0; | 947 WebExceptionCode ec = 0; |
| 1046 // TODO(jorlow): This should be delete. | 948 // TODO(jorlow): This should be delete. |
| 1047 idb_cursor->remove(new IndexedDBCallbacks<void>(parent_, response_id), ec); | 949 idb_cursor->remove(new IndexedDBCallbacks<void>(parent_, response_id), ec); |
| 1048 ViewHostMsg_IDBCursorUpdate::WriteReplyParams(reply_msg, ec); | 950 IndexedDBHostMsg_CursorUpdate::WriteReplyParams(reply_msg, ec); |
| 1049 parent_->Send(reply_msg); | 951 parent_->Send(reply_msg); |
| 1050 } | 952 } |
| 1051 | 953 |
| 1052 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed( | 954 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed( |
| 1053 int32 object_id) { | 955 int32 object_id) { |
| 1054 parent_->DestroyObject( | 956 parent_->DestroyObject( |
| 1055 &map_, object_id, ViewHostMsg_IDBCursorDestroyed::ID); | 957 &map_, object_id, IndexedDBHostMsg_CursorDestroyed::ID); |
| 1056 } | 958 } |
| 1057 | 959 |
| 1058 ////////////////////////////////////////////////////////////////////// | 960 ////////////////////////////////////////////////////////////////////// |
| 1059 // IndexedDBDispatcherHost::TransactionDispatcherHost | 961 // IndexedDBDispatcherHost::TransactionDispatcherHost |
| 1060 // | 962 // |
| 1061 | 963 |
| 1062 IndexedDBDispatcherHost::TransactionDispatcherHost::TransactionDispatcherHost( | 964 IndexedDBDispatcherHost::TransactionDispatcherHost::TransactionDispatcherHost( |
| 1063 IndexedDBDispatcherHost* parent) | 965 IndexedDBDispatcherHost* parent) |
| 1064 : parent_(parent) { | 966 : parent_(parent) { |
| 1065 map_.set_check_on_null_data(true); | 967 map_.set_check_on_null_data(true); |
| 1066 } | 968 } |
| 1067 | 969 |
| 1068 IndexedDBDispatcherHost:: | 970 IndexedDBDispatcherHost:: |
| 1069 TransactionDispatcherHost::~TransactionDispatcherHost() { | 971 TransactionDispatcherHost::~TransactionDispatcherHost() { |
| 1070 MapType::iterator it(&map_); | 972 MapType::iterator it(&map_); |
| 1071 while (!it.IsAtEnd()) { | 973 while (!it.IsAtEnd()) { |
| 1072 it.GetCurrentValue()->abort(); | 974 it.GetCurrentValue()->abort(); |
| 1073 it.Advance(); | 975 it.Advance(); |
| 1074 } | 976 } |
| 1075 } | 977 } |
| 1076 | 978 |
| 1077 bool IndexedDBDispatcherHost::TransactionDispatcherHost::OnMessageReceived( | 979 bool IndexedDBDispatcherHost::TransactionDispatcherHost::OnMessageReceived( |
| 1078 const IPC::Message& message, bool* msg_is_ok) { | 980 const IPC::Message& message, bool* msg_is_ok) { |
| 1079 bool handled = true; | 981 bool handled = true; |
| 1080 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost::TransactionDispatcherHost, | 982 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost::TransactionDispatcherHost, |
| 1081 message, *msg_is_ok) | 983 message, *msg_is_ok) |
| 1082 IPC_MESSAGE_HANDLER(ViewHostMsg_IDBTransactionAbort, OnAbort) | 984 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_TransactionAbort, OnAbort) |
| 1083 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBTransactionMode, OnMode) | 985 IPC_MESSAGE_HANDLER_DELAY_REPLY(IndexedDBHostMsg_TransactionMode, OnMode) |
| 1084 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBTransactionObjectStore, | 986 IPC_MESSAGE_HANDLER_DELAY_REPLY(IndexedDBHostMsg_TransactionObjectStore, |
| 1085 OnObjectStore) | 987 OnObjectStore) |
| 1086 IPC_MESSAGE_HANDLER(ViewHostMsg_IDBTransactionDidCompleteTaskEvents, | 988 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_TransactionDidCompleteTaskEvents, |
| 1087 OnDidCompleteTaskEvents) | 989 OnDidCompleteTaskEvents) |
| 1088 IPC_MESSAGE_HANDLER(ViewHostMsg_IDBTransactionDestroyed, OnDestroyed) | 990 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_TransactionDestroyed, OnDestroyed) |
| 1089 IPC_MESSAGE_UNHANDLED(handled = false) | 991 IPC_MESSAGE_UNHANDLED(handled = false) |
| 1090 IPC_END_MESSAGE_MAP() | 992 IPC_END_MESSAGE_MAP() |
| 1091 return handled; | 993 return handled; |
| 1092 } | 994 } |
| 1093 | 995 |
| 1094 void IndexedDBDispatcherHost::TransactionDispatcherHost::Send( | 996 void IndexedDBDispatcherHost::TransactionDispatcherHost::Send( |
| 1095 IPC::Message* message) { | 997 IPC::Message* message) { |
| 1096 // The macro magic in OnMessageReceived requires this to link, but it should | 998 // The macro magic in OnMessageReceived requires this to link, but it should |
| 1097 // never actually be called. | 999 // never actually be called. |
| 1098 NOTREACHED(); | 1000 NOTREACHED(); |
| 1099 parent_->Send(message); | 1001 parent_->Send(message); |
| 1100 } | 1002 } |
| 1101 | 1003 |
| 1102 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnAbort( | 1004 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnAbort( |
| 1103 int32 transaction_id) { | 1005 int32 transaction_id) { |
| 1104 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 1006 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
| 1105 &map_, transaction_id, 0, ViewHostMsg_IDBTransactionAbort::ID); | 1007 &map_, transaction_id, 0, IndexedDBHostMsg_TransactionAbort::ID); |
| 1106 if (!idb_transaction) | 1008 if (!idb_transaction) |
| 1107 return; | 1009 return; |
| 1108 | 1010 |
| 1109 idb_transaction->abort(); | 1011 idb_transaction->abort(); |
| 1110 } | 1012 } |
| 1111 | 1013 |
| 1112 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnMode( | 1014 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnMode( |
| 1113 int32 transaction_id, | 1015 int32 transaction_id, |
| 1114 IPC::Message* reply_msg) { | 1016 IPC::Message* reply_msg) { |
| 1115 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 1017 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
| 1116 &map_, transaction_id, 0, ViewHostMsg_IDBTransactionMode::ID); | 1018 &map_, transaction_id, 0, IndexedDBHostMsg_TransactionMode::ID); |
| 1117 if (!idb_transaction) | 1019 if (!idb_transaction) |
| 1118 return; | 1020 return; |
| 1119 | 1021 |
| 1120 int mode = idb_transaction->mode(); | 1022 int mode = idb_transaction->mode(); |
| 1121 ViewHostMsg_IDBTransactionMode::WriteReplyParams(reply_msg, mode); | 1023 IndexedDBHostMsg_TransactionMode::WriteReplyParams(reply_msg, mode); |
| 1122 parent_->Send(reply_msg); | 1024 parent_->Send(reply_msg); |
| 1123 } | 1025 } |
| 1124 | 1026 |
| 1125 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnObjectStore( | 1027 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnObjectStore( |
| 1126 int32 transaction_id, const string16& name, IPC::Message* reply_msg) { | 1028 int32 transaction_id, const string16& name, IPC::Message* reply_msg) { |
| 1127 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 1029 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
| 1128 &map_, transaction_id, reply_msg, | 1030 &map_, transaction_id, reply_msg, |
| 1129 ViewHostMsg_IDBTransactionObjectStore::ID); | 1031 IndexedDBHostMsg_TransactionObjectStore::ID); |
| 1130 if (!idb_transaction) | 1032 if (!idb_transaction) |
| 1131 return; | 1033 return; |
| 1132 | 1034 |
| 1133 WebExceptionCode ec = 0; | 1035 WebExceptionCode ec = 0; |
| 1134 WebIDBObjectStore* object_store = idb_transaction->objectStore(name, ec); | 1036 WebIDBObjectStore* object_store = idb_transaction->objectStore(name, ec); |
| 1135 int32 object_id = object_store ? parent_->Add(object_store) : 0; | 1037 int32 object_id = object_store ? parent_->Add(object_store) : 0; |
| 1136 ViewHostMsg_IDBTransactionObjectStore::WriteReplyParams( | 1038 IndexedDBHostMsg_TransactionObjectStore::WriteReplyParams( |
| 1137 reply_msg, object_id, ec); | 1039 reply_msg, object_id, ec); |
| 1138 parent_->Send(reply_msg); | 1040 parent_->Send(reply_msg); |
| 1139 } | 1041 } |
| 1140 | 1042 |
| 1141 void IndexedDBDispatcherHost:: | 1043 void IndexedDBDispatcherHost:: |
| 1142 TransactionDispatcherHost::OnDidCompleteTaskEvents(int transaction_id) { | 1044 TransactionDispatcherHost::OnDidCompleteTaskEvents(int transaction_id) { |
| 1143 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 1045 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
| 1144 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 1046 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
| 1145 &map_, transaction_id, 0, | 1047 &map_, transaction_id, 0, |
| 1146 ViewHostMsg_IDBTransactionDidCompleteTaskEvents::ID); | 1048 IndexedDBHostMsg_TransactionDidCompleteTaskEvents::ID); |
| 1147 if (!idb_transaction) | 1049 if (!idb_transaction) |
| 1148 return; | 1050 return; |
| 1149 | 1051 |
| 1150 idb_transaction->didCompleteTaskEvents(); | 1052 idb_transaction->didCompleteTaskEvents(); |
| 1151 } | 1053 } |
| 1152 | 1054 |
| 1153 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( | 1055 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( |
| 1154 int32 object_id) { | 1056 int32 object_id) { |
| 1155 parent_->DestroyObject( | 1057 parent_->DestroyObject( |
| 1156 &map_, object_id, ViewHostMsg_IDBTransactionDestroyed::ID); | 1058 &map_, object_id, IndexedDBHostMsg_TransactionDestroyed::ID); |
| 1157 } | 1059 } |
| OLD | NEW |