OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/in_process_webkit/indexed_db_dispatcher_host.h" | 5 #include "content/browser/in_process_webkit/indexed_db_dispatcher_host.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "content/browser/in_process_webkit/indexed_db_callbacks.h" | 10 #include "content/browser/in_process_webkit/indexed_db_callbacks.h" |
11 #include "content/browser/in_process_webkit/indexed_db_context_impl.h" | 11 #include "content/browser/in_process_webkit/indexed_db_context_impl.h" |
12 #include "content/browser/in_process_webkit/indexed_db_database_callbacks.h" | 12 #include "content/browser/in_process_webkit/indexed_db_database_callbacks.h" |
13 #include "content/browser/in_process_webkit/indexed_db_transaction_callbacks.h" | 13 #include "content/browser/in_process_webkit/indexed_db_transaction_callbacks.h" |
14 #include "content/browser/renderer_host/render_message_filter.h" | 14 #include "content/browser/renderer_host/render_message_filter.h" |
15 #include "content/common/indexed_db/indexed_db_messages.h" | 15 #include "content/common/indexed_db/indexed_db_messages.h" |
16 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
17 #include "content/public/browser/user_metrics.h" | 17 #include "content/public/browser/user_metrics.h" |
18 #include "content/public/common/content_switches.h" | 18 #include "content/public/common/content_switches.h" |
19 #include "content/public/common/result_codes.h" | 19 #include "content/public/common/result_codes.h" |
20 #include "googleurl/src/gurl.h" | 20 #include "googleurl/src/gurl.h" |
21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMStringList.h" | 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMStringList.h" |
22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBCursor.h" | 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBCursor.h" |
23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabase.h" | 23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabase.h" |
24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabaseError.h " | 24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabaseError.h " |
25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBFactory.h" | 25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBFactory.h" |
26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBIndex.h" | 26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBIndex.h" |
27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKeyPath.h" | 27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKeyPath.h" |
28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKeyRange.h" | 28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKeyRange.h" |
29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBMetadata.h" | |
29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBObjectStore.h" | 30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBObjectStore.h" |
30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBTransaction.h" | 31 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBTransaction.h" |
31 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" | 32 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" |
32 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" | 33 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" |
33 #include "webkit/database/database_util.h" | 34 #include "webkit/database/database_util.h" |
34 #include "webkit/glue/webkit_glue.h" | 35 #include "webkit/glue/webkit_glue.h" |
35 | 36 |
36 using content::BrowserMessageFilter; | 37 using content::BrowserMessageFilter; |
37 using content::BrowserThread; | 38 using content::BrowserThread; |
38 using content::IndexedDBKey; | 39 using content::IndexedDBKey; |
39 using content::IndexedDBKeyPath; | 40 using content::IndexedDBKeyPath; |
40 using content::IndexedDBKeyRange; | 41 using content::IndexedDBKeyRange; |
41 using content::UserMetricsAction; | 42 using content::UserMetricsAction; |
42 using content::SerializedScriptValue; | 43 using content::SerializedScriptValue; |
43 using webkit_database::DatabaseUtil; | 44 using webkit_database::DatabaseUtil; |
44 using WebKit::WebDOMStringList; | 45 using WebKit::WebDOMStringList; |
45 using WebKit::WebExceptionCode; | 46 using WebKit::WebExceptionCode; |
46 using WebKit::WebIDBCallbacks; | 47 using WebKit::WebIDBCallbacks; |
47 using WebKit::WebIDBCursor; | 48 using WebKit::WebIDBCursor; |
48 using WebKit::WebIDBDatabase; | 49 using WebKit::WebIDBDatabase; |
49 using WebKit::WebIDBDatabaseError; | 50 using WebKit::WebIDBDatabaseError; |
51 using WebKit::WebIDBDatabaseMetadata; | |
50 using WebKit::WebIDBIndex; | 52 using WebKit::WebIDBIndex; |
53 using WebKit::WebIDBIndexMetadata; | |
51 using WebKit::WebIDBKey; | 54 using WebKit::WebIDBKey; |
52 using WebKit::WebIDBKeyPath; | 55 using WebKit::WebIDBKeyPath; |
53 using WebKit::WebIDBKeyRange; | 56 using WebKit::WebIDBKeyRange; |
54 using WebKit::WebIDBObjectStore; | 57 using WebKit::WebIDBObjectStore; |
58 using WebKit::WebIDBObjectStoreMetadata; | |
55 using WebKit::WebIDBTransaction; | 59 using WebKit::WebIDBTransaction; |
56 using WebKit::WebSecurityOrigin; | 60 using WebKit::WebSecurityOrigin; |
57 using WebKit::WebSerializedScriptValue; | 61 using WebKit::WebSerializedScriptValue; |
58 using WebKit::WebVector; | 62 using WebKit::WebVector; |
59 | 63 |
60 namespace { | 64 namespace { |
61 | 65 |
62 template <class T> | 66 template <class T> |
63 void DeleteOnWebKitThread(T* obj) { | 67 void DeleteOnWebKitThread(T* obj) { |
64 if (!BrowserThread::DeleteSoon(BrowserThread::WEBKIT_DEPRECATED, | 68 if (!BrowserThread::DeleteSoon(BrowserThread::WEBKIT_DEPRECATED, |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
317 database->close(); | 321 database->close(); |
318 parent_->Context()->ConnectionClosed(iter->second); | 322 parent_->Context()->ConnectionClosed(iter->second); |
319 } | 323 } |
320 } | 324 } |
321 | 325 |
322 bool IndexedDBDispatcherHost::DatabaseDispatcherHost::OnMessageReceived( | 326 bool IndexedDBDispatcherHost::DatabaseDispatcherHost::OnMessageReceived( |
323 const IPC::Message& message, bool* msg_is_ok) { | 327 const IPC::Message& message, bool* msg_is_ok) { |
324 bool handled = true; | 328 bool handled = true; |
325 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost::DatabaseDispatcherHost, | 329 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost::DatabaseDispatcherHost, |
326 message, *msg_is_ok) | 330 message, *msg_is_ok) |
331 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseMetadata, OnMetadata) | |
327 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseName, OnName) | 332 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseName, OnName) |
328 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseVersion, OnVersion) | 333 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseVersion, OnVersion) |
329 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseObjectStoreNames, | 334 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseObjectStoreNames, |
330 OnObjectStoreNames) | 335 OnObjectStoreNames) |
331 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateObjectStore, | 336 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateObjectStore, |
332 OnCreateObjectStore) | 337 OnCreateObjectStore) |
333 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDeleteObjectStore, | 338 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDeleteObjectStore, |
334 OnDeleteObjectStore) | 339 OnDeleteObjectStore) |
335 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseSetVersion, OnSetVersion) | 340 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseSetVersion, OnSetVersion) |
336 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseTransaction, OnTransaction) | 341 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseTransaction, OnTransaction) |
337 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseClose, OnClose) | 342 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseClose, OnClose) |
338 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseOpen, OnOpen) | 343 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseOpen, OnOpen) |
339 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDestroyed, OnDestroyed) | 344 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDestroyed, OnDestroyed) |
340 IPC_MESSAGE_UNHANDLED(handled = false) | 345 IPC_MESSAGE_UNHANDLED(handled = false) |
341 IPC_END_MESSAGE_MAP() | 346 IPC_END_MESSAGE_MAP() |
342 return handled; | 347 return handled; |
343 } | 348 } |
344 | 349 |
345 void IndexedDBDispatcherHost::DatabaseDispatcherHost::Send( | 350 void IndexedDBDispatcherHost::DatabaseDispatcherHost::Send( |
346 IPC::Message* message) { | 351 IPC::Message* message) { |
347 parent_->Send(message); | 352 parent_->Send(message); |
348 } | 353 } |
349 | 354 |
355 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnMetadata( | |
356 int32 idb_database_id, IndexedDBDatabaseMetadata* metadata) { | |
357 WebIDBDatabase* idb_database = parent_->GetOrTerminateProcess( | |
358 &map_, idb_database_id); | |
359 if (!idb_database) | |
360 return; | |
361 | |
362 WebIDBDatabaseMetadata web_db_metadata = idb_database->metadata(); | |
363 metadata->name = web_db_metadata.name; | |
364 metadata->version = web_db_metadata.version; | |
365 for (size_t i = 0; i < web_db_metadata.objectStores.size(); ++i) { | |
366 | |
jam
2012/06/12 00:44:33
nit: blank line
| |
367 const WebIDBObjectStoreMetadata& web_store_metadata = | |
368 web_db_metadata.objectStores[i]; | |
369 IndexedDBObjectStoreMetadata idb_store_metadata; | |
370 idb_store_metadata.name = web_store_metadata.name; | |
371 idb_store_metadata.keyPath = IndexedDBKeyPath(web_store_metadata.keyPath); | |
372 idb_store_metadata.autoIncrement = web_store_metadata.autoIncrement; | |
373 | |
374 for (size_t j = 0; j < web_store_metadata.indexes.size(); ++j) { | |
375 | |
jam
2012/06/12 00:44:33
ditto
| |
376 const WebIDBIndexMetadata& web_index_metadata = | |
377 web_store_metadata.indexes[j]; | |
378 IndexedDBIndexMetadata idb_index_metadata; | |
379 idb_index_metadata.name = web_index_metadata.name; | |
380 idb_index_metadata.keyPath = IndexedDBKeyPath(web_index_metadata.keyPath); | |
381 idb_index_metadata.unique = web_index_metadata.unique; | |
382 idb_index_metadata.multiEntry = web_index_metadata.multiEntry; | |
383 | |
384 idb_store_metadata.indexes.push_back(idb_index_metadata); | |
385 } | |
386 | |
387 metadata->object_stores.push_back(idb_store_metadata); | |
388 } | |
389 } | |
390 | |
350 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnName( | 391 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnName( |
351 int32 object_id, string16* name) { | 392 int32 object_id, string16* name) { |
352 parent_->SyncGetter<string16>(&map_, object_id, name, &WebIDBDatabase::name); | 393 parent_->SyncGetter<string16>(&map_, object_id, name, &WebIDBDatabase::name); |
353 } | 394 } |
354 | 395 |
355 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnVersion( | 396 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnVersion( |
356 int32 object_id, string16* version) { | 397 int32 object_id, string16* version) { |
357 parent_->SyncGetter<string16>( | 398 parent_->SyncGetter<string16>( |
358 &map_, object_id, version, &WebIDBDatabase::version); | 399 &map_, object_id, version, &WebIDBDatabase::version); |
359 } | 400 } |
(...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1221 } | 1262 } |
1222 idb_transaction->didCompleteTaskEvents(); | 1263 idb_transaction->didCompleteTaskEvents(); |
1223 } | 1264 } |
1224 | 1265 |
1225 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( | 1266 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( |
1226 int32 object_id) { | 1267 int32 object_id) { |
1227 transaction_size_map_.erase(object_id); | 1268 transaction_size_map_.erase(object_id); |
1228 transaction_url_map_.erase(object_id); | 1269 transaction_url_map_.erase(object_id); |
1229 parent_->DestroyObject(&map_, object_id); | 1270 parent_->DestroyObject(&map_, object_id); |
1230 } | 1271 } |
OLD | NEW |