| 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 "content/child/indexed_db/indexed_db_dispatcher.h" | 13 #include "content/child/indexed_db/indexed_db_dispatcher.h" |
| 13 #include "content/child/indexed_db/indexed_db_key_builders.h" | 14 #include "content/child/indexed_db/indexed_db_key_builders.h" |
| 14 #include "content/child/thread_safe_sender.h" | 15 #include "content/child/thread_safe_sender.h" |
| 15 #include "content/child/worker_thread_registry.h" | 16 #include "content/child/worker_thread_registry.h" |
| 16 #include "content/common/indexed_db/indexed_db_messages.h" | 17 #include "content/common/indexed_db/indexed_db_messages.h" |
| 17 #include "third_party/WebKit/public/platform/WebBlobInfo.h" | 18 #include "third_party/WebKit/public/platform/WebBlobInfo.h" |
| 18 #include "third_party/WebKit/public/platform/WebString.h" | 19 #include "third_party/WebKit/public/platform/WebString.h" |
| 19 #include "third_party/WebKit/public/platform/WebVector.h" | 20 #include "third_party/WebKit/public/platform/WebVector.h" |
| 20 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBKeyPath.h" | 21 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBKeyPath.h" |
| 21 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBMetadata.h" | 22 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBMetadata.h" |
| 22 | 23 |
| 23 using blink::WebBlobInfo; | 24 using blink::WebBlobInfo; |
| 24 using blink::WebIDBCallbacks; | 25 using blink::WebIDBCallbacks; |
| 25 using blink::WebIDBCursor; | 26 using blink::WebIDBCursor; |
| 26 using blink::WebIDBDatabase; | 27 using blink::WebIDBDatabase; |
| 27 using blink::WebIDBDatabaseCallbacks; | 28 using blink::WebIDBDatabaseCallbacks; |
| 28 using blink::WebIDBMetadata; | 29 using blink::WebIDBMetadata; |
| 29 using blink::WebIDBKey; | 30 using blink::WebIDBKey; |
| 30 using blink::WebIDBKeyPath; | 31 using blink::WebIDBKeyPath; |
| 31 using blink::WebIDBKeyRange; | 32 using blink::WebIDBKeyRange; |
| 33 using blink::WebIDBObserver; |
| 32 using blink::WebString; | 34 using blink::WebString; |
| 33 using blink::WebVector; | 35 using blink::WebVector; |
| 34 | 36 |
| 35 namespace content { | 37 namespace content { |
| 36 | 38 |
| 37 WebIDBDatabaseImpl::WebIDBDatabaseImpl(int32_t ipc_database_id, | 39 WebIDBDatabaseImpl::WebIDBDatabaseImpl(int32_t ipc_database_id, |
| 38 int32_t ipc_database_callbacks_id, | 40 int32_t ipc_database_callbacks_id, |
| 39 ThreadSafeSender* thread_safe_sender) | 41 ThreadSafeSender* thread_safe_sender) |
| 40 : ipc_database_id_(ipc_database_id), | 42 : ipc_database_id_(ipc_database_id), |
| 41 ipc_database_callbacks_id_(ipc_database_callbacks_id), | 43 ipc_database_callbacks_id_(ipc_database_callbacks_id), |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 blink::WebIDBTransactionMode mode) { | 85 blink::WebIDBTransactionMode mode) { |
| 84 IndexedDBDispatcher* dispatcher = | 86 IndexedDBDispatcher* dispatcher = |
| 85 IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get()); | 87 IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get()); |
| 86 dispatcher->RequestIDBDatabaseCreateTransaction( | 88 dispatcher->RequestIDBDatabaseCreateTransaction( |
| 87 ipc_database_id_, transaction_id, callbacks, object_store_ids, mode); | 89 ipc_database_id_, transaction_id, callbacks, object_store_ids, mode); |
| 88 } | 90 } |
| 89 | 91 |
| 90 void WebIDBDatabaseImpl::close() { | 92 void WebIDBDatabaseImpl::close() { |
| 91 IndexedDBDispatcher* dispatcher = | 93 IndexedDBDispatcher* dispatcher = |
| 92 IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get()); | 94 IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get()); |
| 95 dispatcher->RemoveIDBObservers(observer_ids_); |
| 93 dispatcher->RequestIDBDatabaseClose(ipc_database_id_, | 96 dispatcher->RequestIDBDatabaseClose(ipc_database_id_, |
| 94 ipc_database_callbacks_id_); | 97 ipc_database_callbacks_id_); |
| 95 } | 98 } |
| 96 | 99 |
| 97 void WebIDBDatabaseImpl::versionChangeIgnored() { | 100 void WebIDBDatabaseImpl::versionChangeIgnored() { |
| 98 IndexedDBDispatcher* dispatcher = | 101 IndexedDBDispatcher* dispatcher = |
| 99 IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get()); | 102 IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get()); |
| 100 dispatcher->NotifyIDBDatabaseVersionChangeIgnored(ipc_database_id_); | 103 dispatcher->NotifyIDBDatabaseVersionChangeIgnored(ipc_database_id_); |
| 101 } | 104 } |
| 102 | 105 |
| 106 int32_t WebIDBDatabaseImpl::addObserver( |
| 107 std::unique_ptr<WebIDBObserver> observer, |
| 108 long long transaction_id) { |
| 109 IndexedDBDispatcher* dispatcher = |
| 110 IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get()); |
| 111 |
| 112 int32_t observer_id = dispatcher->AddIDBObserver( |
| 113 ipc_database_id_, transaction_id, std::move(observer)); |
| 114 observer_ids_.insert(observer_id); |
| 115 return observer_id; |
| 116 } |
| 117 |
| 118 bool WebIDBDatabaseImpl::containsObserverId(int32_t id) const { |
| 119 return ContainsValue(observer_ids_, id); |
| 120 } |
| 121 |
| 122 void WebIDBDatabaseImpl::removeObservers( |
| 123 const std::vector<int32_t>& observer_ids_to_remove) { |
| 124 for (int32_t id : observer_ids_to_remove) |
| 125 observer_ids_.erase(id); |
| 126 |
| 127 IndexedDBDispatcher* dispatcher = |
| 128 IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get()); |
| 129 dispatcher->RemoveIDBObserversFromDatabase(ipc_database_id_, |
| 130 observer_ids_to_remove); |
| 131 } |
| 132 |
| 103 void WebIDBDatabaseImpl::get(long long transaction_id, | 133 void WebIDBDatabaseImpl::get(long long transaction_id, |
| 104 long long object_store_id, | 134 long long object_store_id, |
| 105 long long index_id, | 135 long long index_id, |
| 106 const WebIDBKeyRange& key_range, | 136 const WebIDBKeyRange& key_range, |
| 107 bool key_only, | 137 bool key_only, |
| 108 WebIDBCallbacks* callbacks) { | 138 WebIDBCallbacks* callbacks) { |
| 109 IndexedDBDispatcher* dispatcher = | 139 IndexedDBDispatcher* dispatcher = |
| 110 IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get()); | 140 IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get()); |
| 111 dispatcher->RequestIDBDatabaseGet(ipc_database_id_, | 141 dispatcher->RequestIDBDatabaseGet(ipc_database_id_, |
| 112 transaction_id, | 142 transaction_id, |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 | 321 |
| 292 void WebIDBDatabaseImpl::ackReceivedBlobs(const WebVector<WebString>& uuids) { | 322 void WebIDBDatabaseImpl::ackReceivedBlobs(const WebVector<WebString>& uuids) { |
| 293 DCHECK(uuids.size()); | 323 DCHECK(uuids.size()); |
| 294 std::vector<std::string> param(uuids.size()); | 324 std::vector<std::string> param(uuids.size()); |
| 295 for (size_t i = 0; i < uuids.size(); ++i) | 325 for (size_t i = 0; i < uuids.size(); ++i) |
| 296 param[i] = uuids[i].latin1().data(); | 326 param[i] = uuids[i].latin1().data(); |
| 297 thread_safe_sender_->Send(new IndexedDBHostMsg_AckReceivedBlobs(param)); | 327 thread_safe_sender_->Send(new IndexedDBHostMsg_AckReceivedBlobs(param)); |
| 298 } | 328 } |
| 299 | 329 |
| 300 } // namespace content | 330 } // namespace content |
| OLD | NEW |