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

Side by Side Diff: third_party/WebKit/Source/modules/indexeddb/IDBObserver.cpp

Issue 2671933002: Migrate WTF::HashMap::add() to ::insert() (Closed)
Patch Set: rebase, add TODOs Created 3 years, 10 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "modules/indexeddb/IDBObserver.h" 5 #include "modules/indexeddb/IDBObserver.h"
6 6
7 #include <bitset> 7 #include <bitset>
8 8
9 #include "bindings/core/v8/ExceptionState.h" 9 #include "bindings/core/v8/ExceptionState.h"
10 #include "bindings/modules/v8/IDBObserverCallback.h" 10 #include "bindings/modules/v8/IDBObserverCallback.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 } else { 74 } else {
75 exceptionState.throwTypeError( 75 exceptionState.throwTypeError(
76 "Unknown operation type in observe options: " + operationType); 76 "Unknown operation type in observe options: " + operationType);
77 return; 77 return;
78 } 78 }
79 } 79 }
80 80
81 int32_t observerId = 81 int32_t observerId =
82 database->addObserver(this, transaction->id(), options.transaction(), 82 database->addObserver(this, transaction->id(), options.transaction(),
83 options.noRecords(), options.values(), types); 83 options.noRecords(), options.values(), types);
84 m_observerIds.add(observerId, database); 84 m_observerIds.insert(observerId, database);
85 } 85 }
86 86
87 void IDBObserver::unobserve(IDBDatabase* database, 87 void IDBObserver::unobserve(IDBDatabase* database,
88 ExceptionState& exceptionState) { 88 ExceptionState& exceptionState) {
89 if (!database->backend()) { 89 if (!database->backend()) {
90 exceptionState.throwDOMException(InvalidStateError, 90 exceptionState.throwDOMException(InvalidStateError,
91 IDBDatabase::databaseClosedErrorMessage); 91 IDBDatabase::databaseClosedErrorMessage);
92 return; 92 return;
93 } 93 }
94 94
95 Vector<int32_t> observerIdsToRemove; 95 Vector<int32_t> observerIdsToRemove;
96 for (const auto& it : m_observerIds) { 96 for (const auto& it : m_observerIds) {
97 if (it.value == database) 97 if (it.value == database)
98 observerIdsToRemove.push_back(it.key); 98 observerIdsToRemove.push_back(it.key);
99 } 99 }
100 m_observerIds.removeAll(observerIdsToRemove); 100 m_observerIds.removeAll(observerIdsToRemove);
101 101
102 if (!observerIdsToRemove.isEmpty()) 102 if (!observerIdsToRemove.isEmpty())
103 database->removeObservers(observerIdsToRemove); 103 database->removeObservers(observerIdsToRemove);
104 } 104 }
105 105
106 DEFINE_TRACE(IDBObserver) { 106 DEFINE_TRACE(IDBObserver) {
107 visitor->trace(m_callback); 107 visitor->trace(m_callback);
108 visitor->trace(m_observerIds); 108 visitor->trace(m_observerIds);
109 } 109 }
110 110
111 } // namespace blink 111 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698