OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/child/indexed_db/webidbdatabase_impl.h" | 5 #include "content/child/indexed_db/webidbdatabase_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
13 #include "content/child/indexed_db/indexed_db_dispatcher.h" | 13 #include "content/child/indexed_db/indexed_db_dispatcher.h" |
14 #include "content/child/indexed_db/indexed_db_key_builders.h" | 14 #include "content/child/indexed_db/indexed_db_key_builders.h" |
15 #include "content/child/thread_safe_sender.h" | 15 #include "content/child/thread_safe_sender.h" |
16 #include "content/child/worker_thread_registry.h" | 16 #include "content/child/worker_thread_registry.h" |
17 #include "content/common/indexed_db/indexed_db_messages.h" | 17 #include "content/common/indexed_db/indexed_db_messages.h" |
18 #include "third_party/WebKit/public/platform/WebBlobInfo.h" | 18 #include "third_party/WebKit/public/platform/WebBlobInfo.h" |
19 #include "third_party/WebKit/public/platform/WebString.h" | 19 #include "third_party/WebKit/public/platform/WebString.h" |
20 #include "third_party/WebKit/public/platform/WebVector.h" | 20 #include "third_party/WebKit/public/platform/WebVector.h" |
21 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBKeyPath.h" | 21 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBKeyPath.h" |
22 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBMetadata.h" | 22 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBMetadata.h" |
23 | 23 |
24 using blink::WebBlobInfo; | 24 using blink::WebBlobInfo; |
25 using blink::WebIDBCallbacks; | 25 using blink::WebIDBCallbacks; |
26 using blink::WebIDBCursor; | 26 using blink::WebIDBCursor; |
27 using blink::WebIDBDatabase; | 27 using blink::WebIDBDatabase; |
28 using blink::WebIDBDatabaseCallbacks; | |
29 using blink::WebIDBMetadata; | 28 using blink::WebIDBMetadata; |
30 using blink::WebIDBKey; | 29 using blink::WebIDBKey; |
31 using blink::WebIDBKeyPath; | 30 using blink::WebIDBKeyPath; |
32 using blink::WebIDBKeyRange; | 31 using blink::WebIDBKeyRange; |
33 using blink::WebIDBObserver; | 32 using blink::WebIDBObserver; |
34 using blink::WebString; | 33 using blink::WebString; |
35 using blink::WebVector; | 34 using blink::WebVector; |
36 | 35 |
37 namespace content { | 36 namespace content { |
38 | 37 |
39 WebIDBDatabaseImpl::WebIDBDatabaseImpl(int32_t ipc_database_id, | 38 WebIDBDatabaseImpl::WebIDBDatabaseImpl(int32_t ipc_database_id, |
40 int32_t ipc_database_callbacks_id, | |
41 ThreadSafeSender* thread_safe_sender) | 39 ThreadSafeSender* thread_safe_sender) |
42 : ipc_database_id_(ipc_database_id), | 40 : ipc_database_id_(ipc_database_id), |
43 ipc_database_callbacks_id_(ipc_database_callbacks_id), | |
44 thread_safe_sender_(thread_safe_sender) {} | 41 thread_safe_sender_(thread_safe_sender) {} |
45 | 42 |
46 WebIDBDatabaseImpl::~WebIDBDatabaseImpl() { | 43 WebIDBDatabaseImpl::~WebIDBDatabaseImpl() { |
47 // It's not possible for there to be pending callbacks that address this | 44 // It's not possible for there to be pending callbacks that address this |
48 // object since inside WebKit, they hold a reference to the object which owns | 45 // object since inside WebKit, they hold a reference to the object which owns |
49 // this object. But, if that ever changed, then we'd need to invalidate | 46 // this object. But, if that ever changed, then we'd need to invalidate |
50 // any such pointers. | 47 // any such pointers. |
51 thread_safe_sender_->Send( | 48 thread_safe_sender_->Send( |
52 new IndexedDBHostMsg_DatabaseDestroyed(ipc_database_id_)); | 49 new IndexedDBHostMsg_DatabaseDestroyed(ipc_database_id_)); |
53 IndexedDBDispatcher* dispatcher = | 50 IndexedDBDispatcher* dispatcher = |
(...skipping 19 matching lines...) Expand all Loading... |
73 } | 70 } |
74 | 71 |
75 void WebIDBDatabaseImpl::deleteObjectStore(long long transaction_id, | 72 void WebIDBDatabaseImpl::deleteObjectStore(long long transaction_id, |
76 long long object_store_id) { | 73 long long object_store_id) { |
77 thread_safe_sender_->Send(new IndexedDBHostMsg_DatabaseDeleteObjectStore( | 74 thread_safe_sender_->Send(new IndexedDBHostMsg_DatabaseDeleteObjectStore( |
78 ipc_database_id_, transaction_id, object_store_id)); | 75 ipc_database_id_, transaction_id, object_store_id)); |
79 } | 76 } |
80 | 77 |
81 void WebIDBDatabaseImpl::createTransaction( | 78 void WebIDBDatabaseImpl::createTransaction( |
82 long long transaction_id, | 79 long long transaction_id, |
83 WebIDBDatabaseCallbacks* callbacks, | |
84 const WebVector<long long>& object_store_ids, | 80 const WebVector<long long>& object_store_ids, |
85 blink::WebIDBTransactionMode mode) { | 81 blink::WebIDBTransactionMode mode) { |
86 IndexedDBDispatcher* dispatcher = | 82 IndexedDBDispatcher* dispatcher = |
87 IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get()); | 83 IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get()); |
88 dispatcher->RequestIDBDatabaseCreateTransaction( | 84 dispatcher->RequestIDBDatabaseCreateTransaction( |
89 ipc_database_id_, transaction_id, callbacks, object_store_ids, mode); | 85 ipc_database_id_, transaction_id, object_store_ids, mode); |
90 } | 86 } |
91 | 87 |
92 void WebIDBDatabaseImpl::close() { | 88 void WebIDBDatabaseImpl::close() { |
93 IndexedDBDispatcher* dispatcher = | 89 IndexedDBDispatcher* dispatcher = |
94 IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get()); | 90 IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get()); |
95 dispatcher->RemoveIDBObservers(observer_ids_); | 91 dispatcher->RemoveIDBObservers(observer_ids_); |
96 dispatcher->RequestIDBDatabaseClose(ipc_database_id_, | 92 dispatcher->RequestIDBDatabaseClose(ipc_database_id_); |
97 ipc_database_callbacks_id_); | |
98 } | 93 } |
99 | 94 |
100 void WebIDBDatabaseImpl::versionChangeIgnored() { | 95 void WebIDBDatabaseImpl::versionChangeIgnored() { |
101 IndexedDBDispatcher* dispatcher = | 96 IndexedDBDispatcher* dispatcher = |
102 IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get()); | 97 IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get()); |
103 dispatcher->NotifyIDBDatabaseVersionChangeIgnored(ipc_database_id_); | 98 dispatcher->NotifyIDBDatabaseVersionChangeIgnored(ipc_database_id_); |
104 } | 99 } |
105 | 100 |
106 int32_t WebIDBDatabaseImpl::addObserver( | 101 int32_t WebIDBDatabaseImpl::addObserver( |
107 std::unique_ptr<WebIDBObserver> observer, | 102 std::unique_ptr<WebIDBObserver> observer, |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 | 315 |
321 void WebIDBDatabaseImpl::ackReceivedBlobs(const WebVector<WebString>& uuids) { | 316 void WebIDBDatabaseImpl::ackReceivedBlobs(const WebVector<WebString>& uuids) { |
322 DCHECK(uuids.size()); | 317 DCHECK(uuids.size()); |
323 std::vector<std::string> param(uuids.size()); | 318 std::vector<std::string> param(uuids.size()); |
324 for (size_t i = 0; i < uuids.size(); ++i) | 319 for (size_t i = 0; i < uuids.size(); ++i) |
325 param[i] = uuids[i].latin1().data(); | 320 param[i] = uuids[i].latin1().data(); |
326 thread_safe_sender_->Send(new IndexedDBHostMsg_AckReceivedBlobs(param)); | 321 thread_safe_sender_->Send(new IndexedDBHostMsg_AckReceivedBlobs(param)); |
327 } | 322 } |
328 | 323 |
329 } // namespace content | 324 } // namespace content |
OLD | NEW |