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

Side by Side Diff: content/browser/indexed_db/indexed_db_database.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_database.h" 5 #include "content/browser/indexed_db/indexed_db_database.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include <limits> 9 #include <limits>
10 #include <memory> 10 #include <memory>
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 // backend before this call so it is safe to ignore it. 539 // backend before this call so it is safe to ignore it.
540 IndexedDBTransaction* transaction = GetTransaction(transaction_id); 540 IndexedDBTransaction* transaction = GetTransaction(transaction_id);
541 if (transaction) 541 if (transaction)
542 transaction->Abort(error); 542 transaction->Abort(error);
543 } 543 }
544 544
545 void IndexedDBDatabase::Observe(int64_t transaction_id, int64_t observer_id) { 545 void IndexedDBDatabase::Observe(int64_t transaction_id, int64_t observer_id) {
546 IndexedDBTransaction* transaction = GetTransaction(transaction_id); 546 IndexedDBTransaction* transaction = GetTransaction(transaction_id);
547 if (!transaction) 547 if (!transaction)
548 return; 548 return;
549 transaction->AddPendingObserver( 549 transaction->AddPendingObserver(observer_id,
550 base::WrapUnique(new IndexedDBObserver(observer_id))); 550 new IndexedDBObserver(observer_id));
551 }
552
553 void IndexedDBDatabase::Unobserve(std::vector<int64_t> observersToRemove) {
554 // TODO (palakj): Remove observer from pending_observer queue of transactions
555 typedef std::map<int64_t, IndexedDBObserver*>::iterator Iterator;
556 for (uint32_t i = 0; i < observersToRemove.size(); i++) {
557 Iterator obs = active_observers_.find(observersToRemove[i]);
558 if (obs != active_observers_.end()) {
559 active_observers_.erase(obs);
dmurph 2016/06/16 07:30:33 I believe you can just do active_observers_.erase(
palakj1 2016/06/16 17:51:41 Done
palakj1 2016/06/16 17:51:41 Done
560 }
561 }
551 } 562 }
552 563
553 void IndexedDBDatabase::GetAll(int64_t transaction_id, 564 void IndexedDBDatabase::GetAll(int64_t transaction_id,
554 int64_t object_store_id, 565 int64_t object_store_id,
555 int64_t index_id, 566 int64_t index_id,
556 std::unique_ptr<IndexedDBKeyRange> key_range, 567 std::unique_ptr<IndexedDBKeyRange> key_range,
557 bool key_only, 568 bool key_only,
558 int64_t max_count, 569 int64_t max_count,
559 scoped_refptr<IndexedDBCallbacks> callbacks) { 570 scoped_refptr<IndexedDBCallbacks> callbacks) {
560 IDB_TRACE1("IndexedDBDatabase::GetAll", "txn.id", transaction_id); 571 IDB_TRACE1("IndexedDBDatabase::GetAll", "txn.id", transaction_id);
(...skipping 1398 matching lines...) Expand 10 before | Expand all | Expand 10 after
1959 1970
1960 void IndexedDBDatabase::VersionChangeAbortOperation( 1971 void IndexedDBDatabase::VersionChangeAbortOperation(
1961 int64_t previous_version, 1972 int64_t previous_version,
1962 IndexedDBTransaction* transaction) { 1973 IndexedDBTransaction* transaction) {
1963 DCHECK(!transaction); 1974 DCHECK(!transaction);
1964 IDB_TRACE("IndexedDBDatabase::VersionChangeAbortOperation"); 1975 IDB_TRACE("IndexedDBDatabase::VersionChangeAbortOperation");
1965 metadata_.version = previous_version; 1976 metadata_.version = previous_version;
1966 } 1977 }
1967 1978
1968 } // namespace content 1979 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698