Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1355)

Unified Diff: content/child/indexed_db/indexed_db_dispatcher.cc

Issue 2511403003: Send IndexedDB observations through IDBDatabaseCallbacks. (Closed)
Patch Set: Remove unnecessary forward declaration. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/child/indexed_db/indexed_db_dispatcher.cc
diff --git a/content/child/indexed_db/indexed_db_dispatcher.cc b/content/child/indexed_db/indexed_db_dispatcher.cc
index 26084c777bf20d039131865920dcfecead845f34..f7b0d2071c4668947dbbd1b6ab523e5bc72ef42f 100644
--- a/content/child/indexed_db/indexed_db_dispatcher.cc
+++ b/content/child/indexed_db/indexed_db_dispatcher.cc
@@ -10,14 +10,12 @@
#include "base/threading/thread_local.h"
#include "content/child/indexed_db/indexed_db_key_builders.h"
#include "content/child/indexed_db/webidbcursor_impl.h"
-#include "content/common/indexed_db/indexed_db_messages.h"
#include "ipc/ipc_channel.h"
#include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseCallbacks.h"
#include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBObservation.h"
using blink::WebIDBKey;
using blink::WebIDBObservation;
-using blink::WebIDBObserver;
using base::ThreadLocalPointer;
namespace content {
@@ -61,45 +59,6 @@ void IndexedDBDispatcher::WillStopCurrentWorkerThread() {
delete this;
}
-std::vector<WebIDBObservation> IndexedDBDispatcher::ConvertObservations(
- const std::vector<IndexedDBMsg_Observation>& idb_observations) {
- std::vector<WebIDBObservation> web_observations;
- for (const auto& idb_observation : idb_observations) {
- WebIDBObservation web_observation;
- web_observation.objectStoreId = idb_observation.object_store_id;
- web_observation.type = idb_observation.type;
- web_observation.keyRange =
- WebIDBKeyRangeBuilder::Build(idb_observation.key_range);
- // TODO(palakj): Assign value to web_observation.
- web_observations.push_back(std::move(web_observation));
- }
- return web_observations;
-}
-
-void IndexedDBDispatcher::OnMessageReceived(const IPC::Message& msg) {
- bool handled = true;
- IPC_BEGIN_MESSAGE_MAP(IndexedDBDispatcher, msg)
- IPC_MESSAGE_HANDLER(IndexedDBMsg_DatabaseCallbacksChanges,
- OnDatabaseChanges)
- IPC_MESSAGE_UNHANDLED(handled = false)
- IPC_END_MESSAGE_MAP()
- // If a message gets here, IndexedDBMessageFilter already determined that it
- // is an IndexedDB message.
- DCHECK(handled) << "Didn't handle a message defined at line "
- << IPC_MESSAGE_ID_LINE(msg.type());
-}
-
-int32_t IndexedDBDispatcher::RegisterObserver(
- std::unique_ptr<WebIDBObserver> observer) {
- return observers_.Add(observer.release());
-}
-
-void IndexedDBDispatcher::RemoveObservers(
- const std::vector<int32_t>& observer_ids_to_remove) {
- for (int32_t id : observer_ids_to_remove)
- observers_.Remove(id);
-}
-
void IndexedDBDispatcher::RegisterMojoOwnedCallbacks(
IndexedDBCallbacksImpl::InternalState* callbacks) {
mojo_owned_callback_state_[callbacks] = base::WrapUnique(callbacks);
@@ -132,23 +91,6 @@ void IndexedDBDispatcher::UnregisterMojoOwnedDatabaseCallbacks(
mojo_owned_database_callback_state_.erase(it);
}
-void IndexedDBDispatcher::OnDatabaseChanges(
- int32_t ipc_thread_id,
- const IndexedDBMsg_ObserverChanges& changes) {
- DCHECK_EQ(ipc_thread_id, CurrentWorkerId());
- std::vector<WebIDBObservation> observations(
- ConvertObservations(changes.observations));
- for (auto& it : changes.observation_index) {
- WebIDBObserver* observer = observers_.Lookup(it.first);
- // An observer can be removed from the renderer, but still exist in the
- // backend. Moreover, observer might have recorded some changes before being
- // removed from the backend and thus, have its id be present in changes.
- if (!observer)
- continue;
- observer->onChange(observations, std::move(it.second));
- }
-}
-
void IndexedDBDispatcher::RegisterCursor(WebIDBCursorImpl* cursor) {
DCHECK(!base::ContainsValue(cursors_, cursor));
cursors_.insert(cursor);
« no previous file with comments | « content/child/indexed_db/indexed_db_dispatcher.h ('k') | content/child/indexed_db/indexed_db_message_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698