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

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

Issue 2062203004: IDBObserver: Lifetime Management: Adding Observer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adding Observer 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 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/core/v8/ExceptionStatePlaceholder.h"
8 #include "bindings/modules/v8/ToV8ForModules.h" 9 #include "bindings/modules/v8/ToV8ForModules.h"
9 #include "bindings/modules/v8/V8BindingForModules.h" 10 #include "bindings/modules/v8/V8BindingForModules.h"
11 #include "core/dom/ExceptionCode.h"
12 #include "modules/indexeddb/IDBDatabase.h"
10 #include "modules/indexeddb/IDBObserverCallback.h" 13 #include "modules/indexeddb/IDBObserverCallback.h"
11 #include "modules/indexeddb/IDBObserverChanges.h" 14 #include "modules/indexeddb/IDBObserverChanges.h"
12 #include "modules/indexeddb/IDBObserverInit.h" 15 #include "modules/indexeddb/IDBObserverInit.h"
13 #include <v8.h>
14 16
15 namespace blink { 17 namespace blink {
16 18
17 IDBObserver* IDBObserver::create(IDBObserverCallback& callback, const IDBObserve rInit& options) 19 IDBObserver* IDBObserver::create(IDBObserverCallback& callback, const IDBObserve rInit& options)
18 { 20 {
19 return new IDBObserver(callback, options); 21 return new IDBObserver(callback, options);
20 } 22 }
21 23
22 IDBObserver::IDBObserver(IDBObserverCallback& callback, const IDBObserverInit& o ptions) 24 IDBObserver::IDBObserver(IDBObserverCallback& callback, const IDBObserverInit& o ptions)
23 : m_callback(&callback) 25 : m_callback(&callback)
24 , m_transaction(options.transaction()) 26 , m_transaction(options.transaction())
25 , m_values(options.values()) 27 , m_values(options.values())
26 , m_noRecords(options.noRecords()) 28 , m_noRecords(options.noRecords())
27 { 29 {
28 } 30 }
29 31
30 void IDBObserver::observe(IDBDatabase* database, IDBTransaction* transaction, Ex ceptionState& exceptionState) 32 void IDBObserver::observe(IDBDatabase* database, IDBTransaction* transaction, Ex ceptionState& exceptionState)
31 { 33 {
32 // TODO(palakj): Finish implementation. 34 if (transaction->isFinished() || transaction->isFinishing()) {
35 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionFinishedErrorMessage);
36 return;
37 }
38 if (!transaction->isActive()) {
39 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionInactiveErrorMessage);
40 return;
41 }
42 if (!database->backend()) {
43 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage);
44 return;
45 }
46 database->backend()->observe(this, transaction->id());
33 } 47 }
34 48
35 DEFINE_TRACE(IDBObserver) 49 DEFINE_TRACE(IDBObserver)
36 { 50 {
37 visitor->trace(m_callback); 51 visitor->trace(m_callback);
38 } 52 }
39 53
40 } // namespace blink 54 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698