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

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

Issue 2125213002: [IndexedDB] Propogating changes to observers : Renderer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lifetime
Patch Set: Filtering Changes to Observer : Browser End Created 4 years, 5 months 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_observer.h" 19 #include "content/browser/indexed_db/indexed_db_observer.h"
20 #include "content/browser/indexed_db/indexed_db_tracing.h" 20 #include "content/browser/indexed_db/indexed_db_tracing.h"
21 #include "content/browser/indexed_db/indexed_db_transaction_coordinator.h" 21 #include "content/browser/indexed_db/indexed_db_transaction_coordinator.h"
22 #include "content/common/indexed_db/indexed_db_observation.h"
22 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseExc eption.h" 23 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseExc eption.h"
23 #include "third_party/leveldatabase/env_chromium.h" 24 #include "third_party/leveldatabase/env_chromium.h"
24 25
25 namespace content { 26 namespace content {
26 27
27 namespace { 28 namespace {
28 29
29 const int64_t kInactivityTimeoutPeriodSeconds = 60; 30 const int64_t kInactivityTimeoutPeriodSeconds = 60;
30 31
31 // Helper for posting a task to call IndexedDBTransaction::Commit when we know 32 // Helper for posting a task to call IndexedDBTransaction::Commit when we know
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 // TODO (palakj) : Send Observations to observers 350 // TODO (palakj) : Send Observations to observers
350 if (!pending_observers_.empty() && connection_) 351 if (!pending_observers_.empty() && connection_)
351 connection_->ActivatePendingObservers(std::move(pending_observers_)); 352 connection_->ActivatePendingObservers(std::move(pending_observers_));
352 abort_task_stack_.clear(); 353 abort_task_stack_.clear();
353 { 354 {
354 IDB_TRACE1( 355 IDB_TRACE1(
355 "IndexedDBTransaction::CommitPhaseTwo.TransactionCompleteCallbacks", 356 "IndexedDBTransaction::CommitPhaseTwo.TransactionCompleteCallbacks",
356 "txn.id", id()); 357 "txn.id", id());
357 callbacks_->OnComplete(id_); 358 callbacks_->OnComplete(id_);
358 } 359 }
360 database_->SendObservations(std::move(connection_changes_map_));
359 database_->TransactionFinished(this, true); 361 database_->TransactionFinished(this, true);
360 } else { 362 } else {
361 while (!abort_task_stack_.empty()) 363 while (!abort_task_stack_.empty())
362 abort_task_stack_.pop().Run(NULL); 364 abort_task_stack_.pop().Run(NULL);
363 365
364 IndexedDBDatabaseError error; 366 IndexedDBDatabaseError error;
365 if (leveldb_env::IndicatesDiskFull(s)) { 367 if (leveldb_env::IndicatesDiskFull(s)) {
366 error = IndexedDBDatabaseError( 368 error = IndexedDBDatabaseError(
367 blink::WebIDBDatabaseExceptionQuotaError, 369 blink::WebIDBDatabaseExceptionQuotaError,
368 "Encountered disk full while committing transaction."); 370 "Encountered disk full while committing transaction.");
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 452
451 void IndexedDBTransaction::CloseOpenCursors() { 453 void IndexedDBTransaction::CloseOpenCursors() {
452 IDB_TRACE1("IndexedDBTransaction::CloseOpenCursors", "txn.id", id()); 454 IDB_TRACE1("IndexedDBTransaction::CloseOpenCursors", "txn.id", id());
453 for (auto* cursor : open_cursors_) 455 for (auto* cursor : open_cursors_)
454 cursor->Close(); 456 cursor->Close();
455 open_cursors_.clear(); 457 open_cursors_.clear();
456 } 458 }
457 459
458 void IndexedDBTransaction::AddPendingObserver(int32_t observer_id) { 460 void IndexedDBTransaction::AddPendingObserver(int32_t observer_id) {
459 pending_observers_.push_back( 461 pending_observers_.push_back(
460 base::WrapUnique(new IndexedDBObserver(observer_id))); 462 base::WrapUnique(new IndexedDBObserver(observer_id, object_store_ids_)));
461 } 463 }
462 464
463 void IndexedDBTransaction::RemovePendingObservers( 465 void IndexedDBTransaction::RemovePendingObservers(
464 const std::vector<int32_t>& pending_observer_ids) { 466 const std::vector<int32_t>& pending_observer_ids) {
465 const auto& it = std::remove_if( 467 const auto& it = std::remove_if(
466 pending_observers_.begin(), pending_observers_.end(), 468 pending_observers_.begin(), pending_observers_.end(),
467 [&pending_observer_ids](const std::unique_ptr<IndexedDBObserver>& o) { 469 [&pending_observer_ids](const std::unique_ptr<IndexedDBObserver>& o) {
468 return ContainsValue(pending_observer_ids, o->id()); 470 return ContainsValue(pending_observer_ids, o->id());
469 }); 471 });
470 if (it != pending_observers_.end()) 472 if (it != pending_observers_.end())
471 pending_observers_.erase(it, pending_observers_.end()); 473 pending_observers_.erase(it, pending_observers_.end());
472 } 474 }
473 475
476 void IndexedDBTransaction::AddObservation(
477 int32_t connection_id,
478 std::unique_ptr<IndexedDBObservation> observation) {
479 connection_changes_map_[connection_id]->AddObservation(
480 std::move(observation));
481 }
482
483 void IndexedDBTransaction::AddObservationIndex(int32_t observer_id,
484 int32_t connection_id) {
485 connection_changes_map_[connection_id]->AddObservationIndex(observer_id);
486 }
487
474 } // namespace content 488 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698