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

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

Issue 2062203004: IDBObserver: Lifetime Management: Adding Observer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Unobserve functionality Created 4 years, 6 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/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 base::ASCIIToUTF16("Transaction timed out due to inactivity."))); 417 base::ASCIIToUTF16("Transaction timed out due to inactivity.")));
418 } 418 }
419 419
420 void IndexedDBTransaction::CloseOpenCursors() { 420 void IndexedDBTransaction::CloseOpenCursors() {
421 IDB_TRACE1("IndexedDBTransaction::CloseOpenCursors", "txn.id", id()); 421 IDB_TRACE1("IndexedDBTransaction::CloseOpenCursors", "txn.id", id());
422 for (auto* cursor : open_cursors_) 422 for (auto* cursor : open_cursors_)
423 cursor->Close(); 423 cursor->Close();
424 open_cursors_.clear(); 424 open_cursors_.clear();
425 } 425 }
426 426
427 void IndexedDBTransaction::AddPendingObserver( 427 void IndexedDBTransaction::AddPendingObserver(int64_t observer_id,
428 std::unique_ptr<IndexedDBObserver> observer) { 428 IndexedDBObserver* observer) {
429 pending_observers_.push_back(std::move(observer)); 429 pending_observers_[observer_id] = observer;
430 } 430 }
431 431
432 void IndexedDBTransaction::ActivatePendingObserver() { 432 void IndexedDBTransaction::ActivatePendingObserver() {
433 for (size_t i = 0; i < pending_observers_.size(); i++) { 433 database_->active_observers_.insert(pending_observers_.begin(),
434 database_->active_observers_.push_back(std::move(pending_observers_[i])); 434 pending_observers_.end());
435 }
436 } 435 }
437 436
438 } // namespace content 437 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698