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

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: Some (incomplete) work on struct traits. 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 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/indexeddb/IDBDatabase.h" 11 #include "modules/indexeddb/IDBDatabase.h"
12 #include "modules/indexeddb/IDBDatabaseProxy.h"
12 #include "modules/indexeddb/IDBObserverCallback.h" 13 #include "modules/indexeddb/IDBObserverCallback.h"
13 #include "modules/indexeddb/IDBObserverInit.h" 14 #include "modules/indexeddb/IDBObserverInit.h"
14 #include "modules/indexeddb/IDBTransaction.h" 15 #include "modules/indexeddb/IDBTransaction.h"
15 #include "modules/indexeddb/WebIDBObserverImpl.h" 16 #include "modules/indexeddb/WebIDBObserverImpl.h"
16 17
17 namespace blink { 18 namespace blink {
18 19
19 IDBObserver* IDBObserver::create(IDBObserverCallback& callback, const IDBObserve rInit& options) 20 IDBObserver* IDBObserver::create(IDBObserverCallback& callback, const IDBObserve rInit& options)
20 { 21 {
21 return new IDBObserver(callback, options); 22 return new IDBObserver(callback, options);
(...skipping 17 matching lines...) Expand all
39 } 40 }
40 if (!transaction->isActive()) { 41 if (!transaction->isActive()) {
41 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionInactiveErrorMessage); 42 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionInactiveErrorMessage);
42 return; 43 return;
43 } 44 }
44 if (!database->backend()) { 45 if (!database->backend()) {
45 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage); 46 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage);
46 return; 47 return;
47 } 48 }
48 49
50 // TODO(cmumford): Implement observers. This is still under construction.
51 #if 0
49 std::unique_ptr<WebIDBObserverImpl> observer = WebIDBObserverImpl::create(th is); 52 std::unique_ptr<WebIDBObserverImpl> observer = WebIDBObserverImpl::create(th is);
50 WebIDBObserverImpl* observerPtr = observer.get(); 53 WebIDBObserverImpl* observerPtr = observer.get();
51 int32_t observerId = database->backend()->addObserver(std::move(observer), t ransaction->id()); 54 int32_t observerId = database->backend()->addObserver(std::move(observer), t ransaction->id());
52 m_observerIds.insert(observerId); 55 m_observerIds.insert(observerId);
53 observerPtr->setId(observerId); 56 observerPtr->setId(observerId);
57 #endif
54 } 58 }
55 59
56 void IDBObserver::unobserve(IDBDatabase* database, ExceptionState& exceptionStat e) 60 void IDBObserver::unobserve(IDBDatabase* database, ExceptionState& exceptionStat e)
57 { 61 {
62 #if 0
58 if (!database->backend()) { 63 if (!database->backend()) {
59 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage); 64 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage);
60 return; 65 return;
61 } 66 }
62 auto it = m_observerIds.begin(); 67 auto it = m_observerIds.begin();
63 std::vector<int32_t> observerIdsToRemove; 68 std::vector<int32_t> observerIdsToRemove;
64 while (it != m_observerIds.end()) { 69 while (it != m_observerIds.end()) {
65 if (database->backend()->containsObserverId(*it)) { 70 if (database->backend()->containsObserverId(*it)) {
66 observerIdsToRemove.push_back(*it); 71 observerIdsToRemove.push_back(*it);
67 it = m_observerIds.erase(it); 72 it = m_observerIds.erase(it);
68 } else { 73 } else {
69 it++; 74 it++;
70 } 75 }
71 } 76 }
72 if (!observerIdsToRemove.empty()) 77 if (!observerIdsToRemove.empty())
73 database->backend()->removeObservers(observerIdsToRemove); 78 database->backend()->removeObservers(observerIdsToRemove);
79 #endif
74 } 80 }
75 81
76 void IDBObserver::removeObserver(int32_t id) 82 void IDBObserver::removeObserver(int32_t id)
77 { 83 {
78 m_observerIds.erase(id); 84 m_observerIds.erase(id);
79 } 85 }
80 86
81 DEFINE_TRACE(IDBObserver) 87 DEFINE_TRACE(IDBObserver)
82 { 88 {
83 visitor->trace(m_callback); 89 visitor->trace(m_callback);
84 } 90 }
85 91
86 } // namespace blink 92 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698