Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(205)

Side by Side Diff: chrome/browser/in_process_webkit/indexed_db_dispatcher_host.cc

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

Powered by Google App Engine
This is Rietveld 408576698