| 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..06d606b13606ddd6c8238cce51af45f66f1d32b8 100644
|
| --- a/third_party/WebKit/Source/modules/indexeddb/IDBObserver.cpp
|
| +++ b/third_party/WebKit/Source/modules/indexeddb/IDBObserver.cpp
|
| @@ -7,8 +7,12 @@
|
| #include "bindings/core/v8/ExceptionState.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"
|
| +#include "modules/indexeddb/IDBTransaction.h"
|
| +#include "public/platform/modules/indexeddb/WebIDBObserver.h"
|
|
|
| namespace blink {
|
|
|
| @@ -29,7 +33,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(std::unique_ptr<WebIDBObserver>(new WebIDBObserver(this)), transaction->id());
|
| +}
|
| +
|
| +void IDBObserver::unobserve(IDBDatabase* database, ExceptionState& exceptionState)
|
| +{
|
| + if (!database->backend()) {
|
| + exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databaseClosedErrorMessage);
|
| + return;
|
| + }
|
| + database->backend()->unobserve(std::unique_ptr<WebIDBObserver>(new WebIDBObserver(this)));
|
| }
|
|
|
| DEFINE_TRACE(IDBObserver)
|
|
|