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

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

Issue 1963293002: Replacing Indexed DB Chromium IPC with Mojo Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refactoring after Passing URLRequestContextGetter. Created 4 years, 4 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 "bindings/core/v8/ExceptionState.h" 7 #include "bindings/core/v8/ExceptionState.h"
8 #include "bindings/modules/v8/ToV8ForModules.h" 8 #include "bindings/modules/v8/ToV8ForModules.h"
9 #include "bindings/modules/v8/V8BindingForModules.h" 9 #include "bindings/modules/v8/V8BindingForModules.h"
10 #include "core/dom/ExceptionCode.h" 10 #include "core/dom/ExceptionCode.h"
11 #include "modules/IndexedDBNames.h" 11 #include "modules/IndexedDBNames.h"
12 #include "modules/indexeddb/IDBDatabase.h" 12 #include "modules/indexeddb/IDBDatabase.h"
13 #include "modules/indexeddb/IDBDatabaseProxy.h"
13 #include "modules/indexeddb/IDBObserverCallback.h" 14 #include "modules/indexeddb/IDBObserverCallback.h"
14 #include "modules/indexeddb/IDBObserverChanges.h" 15 #include "modules/indexeddb/IDBObserverChanges.h"
15 #include "modules/indexeddb/IDBObserverInit.h" 16 #include "modules/indexeddb/IDBObserverInit.h"
16 #include "modules/indexeddb/IDBTransaction.h" 17 #include "modules/indexeddb/IDBTransaction.h"
17 #include "modules/indexeddb/WebIDBObserverImpl.h" 18 #include "modules/indexeddb/WebIDBObserverImpl.h"
18 19
19 namespace blink { 20 namespace blink {
20 21
21 IDBObserver* IDBObserver::create(IDBObserverCallback& callback, const IDBObserve rInit& options) 22 IDBObserver* IDBObserver::create(IDBObserverCallback& callback, const IDBObserve rInit& options)
22 { 23 {
(...skipping 23 matching lines...) Expand all
46 } 47 }
47 if (!transaction->isActive()) { 48 if (!transaction->isActive()) {
48 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionInactiveErrorMessage); 49 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionInactiveErrorMessage);
49 return; 50 return;
50 } 51 }
51 if (!database->backend()) { 52 if (!database->backend()) {
52 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage); 53 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage);
53 return; 54 return;
54 } 55 }
55 56
57 // TODO(cmumford): Implement observers. This is still under construction.
58 #if 0
56 std::unique_ptr<WebIDBObserverImpl> observer = WebIDBObserverImpl::create(th is); 59 std::unique_ptr<WebIDBObserverImpl> observer = WebIDBObserverImpl::create(th is);
57 WebIDBObserverImpl* observerPtr = observer.get(); 60 WebIDBObserverImpl* observerPtr = observer.get();
58 int32_t observerId = database->backend()->addObserver(std::move(observer), t ransaction->id()); 61 int32_t observerId = database->backend()->addObserver(std::move(observer), t ransaction->id());
59 m_observerIds.add(observerId, database); 62 m_observerIds.add(observerId, database);
60 observerPtr->setId(observerId); 63 observerPtr->setId(observerId);
64 #endif
61 } 65 }
62 66
63 void IDBObserver::unobserve(IDBDatabase* database, ExceptionState& exceptionStat e) 67 void IDBObserver::unobserve(IDBDatabase* database, ExceptionState& exceptionStat e)
64 { 68 {
69 #if 0
65 if (!database->backend()) { 70 if (!database->backend()) {
66 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage); 71 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage);
67 return; 72 return;
68 } 73 }
69 74
70 Vector<int32_t> observerIdsToRemove; 75 Vector<int32_t> observerIdsToRemove;
71 for (const auto& it : m_observerIds) { 76 for (const auto& it : m_observerIds) {
72 if (it.value == database) 77 if (it.value == database)
73 observerIdsToRemove.append(it.key); 78 observerIdsToRemove.append(it.key);
74 } 79 }
75 m_observerIds.removeAll(observerIdsToRemove); 80 m_observerIds.removeAll(observerIdsToRemove);
76 81
77 if (!observerIdsToRemove.isEmpty()) 82 if (!observerIdsToRemove.isEmpty())
78 database->backend()->removeObservers(observerIdsToRemove); 83 database->backend()->removeObservers(observerIdsToRemove);
84 #endif
79 } 85 }
80 86
81 void IDBObserver::removeObserver(int32_t id) 87 void IDBObserver::removeObserver(int32_t id)
82 { 88 {
83 m_observerIds.remove(id); 89 m_observerIds.remove(id);
84 } 90 }
85 91
86 void IDBObserver::onChange(int32_t id, const WebVector<WebIDBObservation>& obser vations, const WebVector<int32_t>& observationIndex) 92 void IDBObserver::onChange(int32_t id, const WebVector<WebIDBObservation>& obser vations, const WebVector<int32_t>& observationIndex)
87 { 93 {
88 auto it = m_observerIds.find(id); 94 auto it = m_observerIds.find(id);
89 DCHECK(it != m_observerIds.end()); 95 DCHECK(it != m_observerIds.end());
90 m_callback->handleChanges(*IDBObserverChanges::create(it->value, observation s, observationIndex), *this); 96 m_callback->handleChanges(*IDBObserverChanges::create(it->value, observation s, observationIndex), *this);
91 } 97 }
92 98
93 DEFINE_TRACE(IDBObserver) 99 DEFINE_TRACE(IDBObserver)
94 { 100 {
95 visitor->trace(m_callback); 101 visitor->trace(m_callback);
96 visitor->trace(m_observerIds); 102 visitor->trace(m_observerIds);
97 } 103 }
98 104
99 } // namespace blink 105 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698