| OLD | NEW |
| 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 11 matching lines...) Expand all Loading... |
| 22 IDBObserver* IDBObserver::Create(IDBObserverCallback* callback) { | 22 IDBObserver* IDBObserver::Create(IDBObserverCallback* callback) { |
| 23 return new IDBObserver(callback); | 23 return new IDBObserver(callback); |
| 24 } | 24 } |
| 25 | 25 |
| 26 IDBObserver::IDBObserver(IDBObserverCallback* callback) : callback_(callback) {} | 26 IDBObserver::IDBObserver(IDBObserverCallback* callback) : callback_(callback) {} |
| 27 | 27 |
| 28 void IDBObserver::observe(IDBDatabase* database, | 28 void IDBObserver::observe(IDBDatabase* database, |
| 29 IDBTransaction* transaction, | 29 IDBTransaction* transaction, |
| 30 const IDBObserverInit& options, | 30 const IDBObserverInit& options, |
| 31 ExceptionState& exception_state) { | 31 ExceptionState& exception_state) { |
| 32 if (transaction->IsFinished() || transaction->IsFinishing()) { | |
| 33 exception_state.ThrowDOMException( | |
| 34 kTransactionInactiveError, | |
| 35 IDBDatabase::kTransactionFinishedErrorMessage); | |
| 36 return; | |
| 37 } | |
| 38 if (!transaction->IsActive()) { | 32 if (!transaction->IsActive()) { |
| 39 exception_state.ThrowDOMException( | 33 exception_state.ThrowDOMException(kTransactionInactiveError, |
| 40 kTransactionInactiveError, | 34 transaction->InactiveErrorMessage()); |
| 41 IDBDatabase::kTransactionInactiveErrorMessage); | |
| 42 return; | 35 return; |
| 43 } | 36 } |
| 44 if (transaction->IsVersionChange()) { | 37 if (transaction->IsVersionChange()) { |
| 45 exception_state.ThrowDOMException( | 38 exception_state.ThrowDOMException( |
| 46 kTransactionInactiveError, | 39 kTransactionInactiveError, |
| 47 IDBDatabase::kCannotObserveVersionChangeTransaction); | 40 IDBDatabase::kCannotObserveVersionChangeTransaction); |
| 48 return; | 41 return; |
| 49 } | 42 } |
| 50 if (!database->Backend()) { | 43 if (!database->Backend()) { |
| 51 exception_state.ThrowDOMException(kInvalidStateError, | 44 exception_state.ThrowDOMException(kInvalidStateError, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 if (!observer_ids_to_remove.IsEmpty()) | 96 if (!observer_ids_to_remove.IsEmpty()) |
| 104 database->RemoveObservers(observer_ids_to_remove); | 97 database->RemoveObservers(observer_ids_to_remove); |
| 105 } | 98 } |
| 106 | 99 |
| 107 DEFINE_TRACE(IDBObserver) { | 100 DEFINE_TRACE(IDBObserver) { |
| 108 visitor->Trace(callback_); | 101 visitor->Trace(callback_); |
| 109 visitor->Trace(observer_ids_); | 102 visitor->Trace(observer_ids_); |
| 110 } | 103 } |
| 111 | 104 |
| 112 } // namespace blink | 105 } // namespace blink |
| OLD | NEW |