Chromium Code Reviews| Index: third_party/WebKit/Source/modules/indexeddb/WebIDBObserverImpl.cpp |
| diff --git a/third_party/WebKit/Source/modules/indexeddb/WebIDBObserverImpl.cpp b/third_party/WebKit/Source/modules/indexeddb/WebIDBObserverImpl.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e55179c0147f24cd02fe55fc123a1a4b430958a5 |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/modules/indexeddb/WebIDBObserverImpl.cpp |
| @@ -0,0 +1,37 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "modules/indexeddb/WebIDBObserverImpl.h" |
| + |
| +#include "modules/indexeddb/IDBObserver.h" |
| +#include "wtf/PtrUtil.h" |
| + |
| +namespace blink { |
| + |
| +// static |
| +std::unique_ptr<WebIDBObserverImpl> WebIDBObserverImpl::create(IDBObserver* observer) |
| +{ |
| + return wrapUnique(new WebIDBObserverImpl(observer)); |
| +} |
| + |
| +WebIDBObserverImpl::WebIDBObserverImpl(IDBObserver* observer) |
| + : m_id(kInvalidObserverId) |
| + , m_observer(observer) |
| +{ |
| +} |
| + |
| +// Remove observe call id from IDBObserver. |
| +WebIDBObserverImpl::~WebIDBObserverImpl() |
| +{ |
| + DCHECK_NE(kInvalidObserverId, m_id); |
|
cmumford
2016/07/07 19:48:51
I think this is OK to have a runtime check - not a
palakj1
2016/07/07 21:14:48
replacing this with a if check
if (m_id != kInvali
|
| + m_observer->removeObserver(m_id); |
| +} |
| + |
| +void WebIDBObserverImpl::setId(int32_t id) |
| +{ |
| + DCHECK_EQ(kInvalidObserverId, m_id); |
| + m_id = id; |
| +} |
| + |
| +} // namespace blink |