| Index: third_party/WebKit/Source/modules/indexeddb/IDBObserver.cpp
|
| diff --git a/third_party/WebKit/Source/modules/indexeddb/IDBObserver.cpp b/third_party/WebKit/Source/modules/indexeddb/IDBObserver.cpp
|
| index 17e8494068c422100ba2844d5735abde6a19ae48..dd013c6911b7838779c23faf949e1d0f20917e01 100644
|
| --- a/third_party/WebKit/Source/modules/indexeddb/IDBObserver.cpp
|
| +++ b/third_party/WebKit/Source/modules/indexeddb/IDBObserver.cpp
|
| @@ -5,8 +5,11 @@
|
| #include "modules/indexeddb/IDBObserver.h"
|
|
|
| #include "bindings/core/v8/ExceptionState.h"
|
| +#include "bindings/core/v8/ExceptionStatePlaceholder.h"
|
| #include "bindings/modules/v8/ToV8ForModules.h"
|
| #include "bindings/modules/v8/V8BindingForModules.h"
|
| +#include "core/dom/ExceptionCode.h"
|
| +#include "modules/indexeddb/IDBDatabase.h"
|
| #include "modules/indexeddb/IDBObserverCallback.h"
|
| #include "modules/indexeddb/IDBObserverInit.h"
|
|
|
| @@ -29,7 +32,28 @@ IDBObserver::~IDBObserver() {}
|
|
|
| void IDBObserver::observe(IDBDatabase* database, IDBTransaction* transaction, ExceptionState& exceptionState)
|
| {
|
| - // TODO(palakj): Finish implementation.
|
| + if (transaction->isFinished() || transaction->isFinishing()) {
|
| + exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::transactionFinishedErrorMessage);
|
| + return;
|
| + }
|
| + if (!transaction->isActive()) {
|
| + exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::transactionInactiveErrorMessage);
|
| + return;
|
| + }
|
| + if (!database->backend()) {
|
| + exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databaseClosedErrorMessage);
|
| + return;
|
| + }
|
| + database->backend()->observe(this, transaction->id());
|
| +}
|
| +
|
| +void IDBObserver::unobserve(IDBDatabase* database, ExceptionState& exceptionState)
|
| +{
|
| + if (!database->backend()) {
|
| + exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databaseClosedErrorMessage);
|
| + return;
|
| + }
|
| + database->backend()->unobserve(this);
|
| }
|
|
|
| DEFINE_TRACE(IDBObserver)
|
|
|