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

Side by Side Diff: content/browser/indexed_db/indexed_db_transaction.cc

Issue 2511403003: Send IndexedDB observations through IDBDatabaseCallbacks. (Closed)
Patch Set: Rebased. 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/browser/indexed_db/indexed_db_transaction.h" 5 #include "content/browser/indexed_db/indexed_db_transaction.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "base/single_thread_task_runner.h" 11 #include "base/single_thread_task_runner.h"
12 #include "base/stl_util.h" 12 #include "base/stl_util.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "base/threading/thread_task_runner_handle.h" 14 #include "base/threading/thread_task_runner_handle.h"
15 #include "content/browser/indexed_db/indexed_db_backing_store.h" 15 #include "content/browser/indexed_db/indexed_db_backing_store.h"
16 #include "content/browser/indexed_db/indexed_db_cursor.h" 16 #include "content/browser/indexed_db/indexed_db_cursor.h"
17 #include "content/browser/indexed_db/indexed_db_database.h" 17 #include "content/browser/indexed_db/indexed_db_database.h"
18 #include "content/browser/indexed_db/indexed_db_database_callbacks.h" 18 #include "content/browser/indexed_db/indexed_db_database_callbacks.h"
19 #include "content/browser/indexed_db/indexed_db_observation.h"
20 #include "content/browser/indexed_db/indexed_db_observer_changes.h"
21 #include "content/browser/indexed_db/indexed_db_tracing.h" 19 #include "content/browser/indexed_db/indexed_db_tracing.h"
22 #include "content/browser/indexed_db/indexed_db_transaction_coordinator.h" 20 #include "content/browser/indexed_db/indexed_db_transaction_coordinator.h"
23 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseExc eption.h" 21 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseExc eption.h"
24 #include "third_party/leveldatabase/env_chromium.h" 22 #include "third_party/leveldatabase/env_chromium.h"
25 23
26 namespace content { 24 namespace content {
27 25
28 namespace { 26 namespace {
29 27
30 const int64_t kInactivityTimeoutPeriodSeconds = 60; 28 const int64_t kInactivityTimeoutPeriodSeconds = 60;
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 pending_observers_.begin(), pending_observers_.end(), 476 pending_observers_.begin(), pending_observers_.end(),
479 [&pending_observer_ids](const std::unique_ptr<IndexedDBObserver>& o) { 477 [&pending_observer_ids](const std::unique_ptr<IndexedDBObserver>& o) {
480 return base::ContainsValue(pending_observer_ids, o->id()); 478 return base::ContainsValue(pending_observer_ids, o->id());
481 }); 479 });
482 if (it != pending_observers_.end()) 480 if (it != pending_observers_.end())
483 pending_observers_.erase(it, pending_observers_.end()); 481 pending_observers_.erase(it, pending_observers_.end());
484 } 482 }
485 483
486 void IndexedDBTransaction::AddObservation( 484 void IndexedDBTransaction::AddObservation(
487 int32_t connection_id, 485 int32_t connection_id,
488 std::unique_ptr<IndexedDBObservation> observation) { 486 ::indexed_db::mojom::ObservationPtr observation) {
489 auto it = connection_changes_map_.find(connection_id); 487 auto it = connection_changes_map_.find(connection_id);
490 if (it == connection_changes_map_.end()) { 488 if (it == connection_changes_map_.end()) {
491 it = connection_changes_map_ 489 it = connection_changes_map_
492 .insert(std::make_pair( 490 .insert(std::make_pair(
493 connection_id, base::MakeUnique<IndexedDBObserverChanges>())) 491 connection_id, ::indexed_db::mojom::ObserverChanges::New()))
494 .first; 492 .first;
495 } 493 }
496 it->second->AddObservation(std::move(observation)); 494 it->second->observations.push_back(std::move(observation));
497 } 495 }
498 496
499 void IndexedDBTransaction::RecordObserverForLastObservation( 497 void IndexedDBTransaction::RecordObserverForLastObservation(
500 int32_t connection_id, 498 int32_t connection_id,
501 int32_t observer_id) { 499 int32_t observer_id) {
502 auto it = connection_changes_map_.find(connection_id); 500 auto it = connection_changes_map_.find(connection_id);
503 DCHECK(it != connection_changes_map_.end()); 501 DCHECK(it != connection_changes_map_.end());
504 it->second->RecordObserverForLastObservation(observer_id); 502 it->second->observation_index_map[observer_id].push_back(
503 it->second->observations.size() - 1);
505 } 504 }
506 505
507 } // namespace content 506 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698