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..712d6160b080c669d46842ede7a0f59d9e28f728 100644 |
| --- a/content/child/indexed_db/webidbdatabase_impl.cc |
| +++ b/content/child/indexed_db/webidbdatabase_impl.cc |
| @@ -19,7 +19,9 @@ |
| #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/Source/modules/indexeddb/IDBObserver.h" |
| +using blink::IDBObserver; |
| using blink::WebBlobInfo; |
| using blink::WebIDBCallbacks; |
| using blink::WebIDBCursor; |
| @@ -29,6 +31,7 @@ using blink::WebIDBMetadata; |
| using blink::WebIDBKey; |
| using blink::WebIDBKeyPath; |
| using blink::WebIDBKeyRange; |
| +using blink::WebIDBObserver; |
| using blink::WebString; |
| using blink::WebVector; |
| @@ -90,6 +93,11 @@ void WebIDBDatabaseImpl::createTransaction( |
| void WebIDBDatabaseImpl::close() { |
| IndexedDBDispatcher* dispatcher = |
| IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get()); |
| + // TODO(palakj): Can pass observers_id along with RequestIDBDatabaseClose. |
|
dmurph
2016/06/22 01:09:50
Yes, you could do that also.
palakj1
2016/06/23 20:56:30
Would you prefer that over the current implementat
|
| + if (!observers_id_.empty()) { |
| + dispatcher->ClearIDBObserver(observers_id_); |
| + observers_id_.clear(); // Do I need to do this? |
|
dmurph
2016/06/22 01:09:50
sure.
|
| + } |
| dispatcher->RequestIDBDatabaseClose(ipc_database_id_, |
| ipc_database_callbacks_id_); |
| } |
| @@ -100,6 +108,28 @@ void WebIDBDatabaseImpl::versionChangeIgnored() { |
| dispatcher->NotifyIDBDatabaseVersionChangeIgnored(ipc_database_id_); |
| } |
| +void WebIDBDatabaseImpl::observe(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, observer); |
| + observers_id_.push_back(observer_id); |
| +} |
| + |
| +void WebIDBDatabaseImpl::unobserve(blink::WebIDBObserver* observer) { |
| + IndexedDBDispatcher* dispatcher = |
| + IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get()); |
| + std::vector<int32_t> observersToRemove = |
|
dmurph
2016/06/22 01:09:50
no camelCase.
palakj1
2016/06/23 20:56:30
Changed.
|
| + dispatcher->RemoveIDBObservers(ipc_database_id_, observer, observers_id_); |
| + |
| + for (uint32_t i = 0; i < observersToRemove.size(); i++) { |
| + std::vector<int>::iterator position = std::find( |
|
dmurph
2016/06/22 01:09:50
I think using observer_ids_.find would be simpler.
|
| + observers_id_.begin(), observers_id_.end(), observersToRemove[i]); |
| + observers_id_.erase(position); |
| + } |
| +} |
| + |
| void WebIDBDatabaseImpl::get(long long transaction_id, |
| long long object_store_id, |
| long long index_id, |