Chromium Code Reviews| Index: content/child/indexed_db/webidbdatabase_impl.cc |
| diff --git a/content/child/indexed_db/webidbdatabase_impl.cc b/content/child/indexed_db/webidbdatabase_impl.cc |
| index fedb0e7333974ecdce6127249739b0b4ea4ccdae..20801368a92892a12d7b62050459c85e0c4ce76b 100644 |
| --- a/content/child/indexed_db/webidbdatabase_impl.cc |
| +++ b/content/child/indexed_db/webidbdatabase_impl.cc |
| @@ -9,6 +9,7 @@ |
| #include <string> |
| #include <vector> |
| +#include "base/stl_util.h" |
| #include "content/child/indexed_db/indexed_db_dispatcher.h" |
| #include "content/child/indexed_db/indexed_db_key_builders.h" |
| #include "content/child/thread_safe_sender.h" |
| @@ -19,6 +20,7 @@ |
| #include "third_party/WebKit/public/platform/WebVector.h" |
| #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBKeyPath.h" |
| #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBMetadata.h" |
| +#include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBObserver.h" |
| using blink::WebBlobInfo; |
| using blink::WebIDBCallbacks; |
| @@ -29,6 +31,7 @@ using blink::WebIDBMetadata; |
| using blink::WebIDBKey; |
| using blink::WebIDBKeyPath; |
| using blink::WebIDBKeyRange; |
| +using blink::WebIDBObserver; |
|
cmumford
2016/07/01 18:35:01
Either forward declare (if possible), or #include
palakj1
2016/07/02 00:48:14
Done.
|
| using blink::WebString; |
| using blink::WebVector; |
| @@ -90,6 +93,7 @@ void WebIDBDatabaseImpl::createTransaction( |
| void WebIDBDatabaseImpl::close() { |
| IndexedDBDispatcher* dispatcher = |
| IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get()); |
| + dispatcher->RemoveIDBObservers(observer_ids_); |
| dispatcher->RequestIDBDatabaseClose(ipc_database_id_, |
| ipc_database_callbacks_id_); |
| } |
| @@ -100,6 +104,33 @@ void WebIDBDatabaseImpl::versionChangeIgnored() { |
| dispatcher->NotifyIDBDatabaseVersionChangeIgnored(ipc_database_id_); |
| } |
| +int32_t WebIDBDatabaseImpl::addObserver( |
| + std::unique_ptr<WebIDBObserver> observer, |
| + long long transaction_id) { |
| + IndexedDBDispatcher* dispatcher = |
| + IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get()); |
| + |
| + int32_t observer_id = dispatcher->AddIDBObserver( |
| + ipc_database_id_, transaction_id, std::move(observer)); |
| + observer_ids_.insert(observer_id); |
| + return observer_id; |
| +} |
| + |
| +bool WebIDBDatabaseImpl::containsObserverId(int32_t id) const { |
| + return ContainsValue(observer_ids_, id); |
| +} |
| + |
| +void WebIDBDatabaseImpl::removeObservers( |
| + const std::vector<int32_t>& observer_ids_to_remove) { |
| + for (int32_t id : observer_ids_to_remove) |
| + observer_ids_.erase(id); |
| + |
| + IndexedDBDispatcher* dispatcher = |
| + IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get()); |
| + dispatcher->RemoveIDBObserversFromDatabase(ipc_database_id_, |
| + observer_ids_to_remove); |
| +} |
| + |
| void WebIDBDatabaseImpl::get(long long transaction_id, |
| long long object_store_id, |
| long long index_id, |