| 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/IDBObservation.h" | 5 #include "modules/indexeddb/IDBObservation.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
| 8 #include "bindings/core/v8/ScriptState.h" | 8 #include "bindings/core/v8/ScriptState.h" |
| 9 #include "bindings/core/v8/ToV8.h" | 9 #include "bindings/core/v8/ToV8.h" |
| 10 #include "bindings/modules/v8/ToV8ForModules.h" | 10 #include "bindings/modules/v8/ToV8ForModules.h" |
| 11 #include "bindings/modules/v8/V8BindingForModules.h" | 11 #include "bindings/modules/v8/V8BindingForModules.h" |
| 12 #include "modules/IndexedDBNames.h" | 12 #include "modules/IndexedDBNames.h" |
| 13 #include "modules/indexeddb/IDBAny.h" | 13 #include "modules/indexeddb/IDBAny.h" |
| 14 #include "modules/indexeddb/IDBKey.h" | 14 #include "modules/indexeddb/IDBKeyRange.h" |
| 15 #include "modules/indexeddb/IDBValue.h" | 15 #include "modules/indexeddb/IDBValue.h" |
| 16 #include "public/platform/modules/indexeddb/WebIDBObservation.h" |
| 16 | 17 |
| 17 namespace blink { | 18 namespace blink { |
| 18 | 19 |
| 19 IDBObservation::~IDBObservation() {} | 20 IDBObservation::~IDBObservation() {} |
| 20 | 21 |
| 21 ScriptValue IDBObservation::key(ScriptState* scriptState) | 22 ScriptValue IDBObservation::key(ScriptState* scriptState) |
| 22 { | 23 { |
| 23 return ScriptValue::from(scriptState, m_key); | 24 if (!m_keyRange) |
| 25 return ScriptValue::from(scriptState, v8::Undefined(scriptState->isolate
())); |
| 26 |
| 27 return ScriptValue::from(scriptState, m_keyRange); |
| 24 } | 28 } |
| 25 | 29 |
| 26 ScriptValue IDBObservation::value(ScriptState* scriptState) | 30 ScriptValue IDBObservation::value(ScriptState* scriptState) |
| 27 { | 31 { |
| 28 IDBAny* value; | 32 if (!m_value) |
| 29 if (!m_value) { | 33 return ScriptValue::from(scriptState, v8::Undefined(scriptState->isolate
())); |
| 30 value = IDBAny::createUndefined(); | 34 |
| 31 } else { | 35 return ScriptValue::from(scriptState, IDBAny::create(m_value)); |
| 32 value = IDBAny::create(m_value); | |
| 33 } | |
| 34 ScriptValue scriptValue = ScriptValue::from(scriptState, value); | |
| 35 return scriptValue; | |
| 36 } | 36 } |
| 37 | 37 |
| 38 WebIDBOperationType IDBObservation::stringToOperationType(const String& type) | 38 WebIDBOperationType IDBObservation::stringToOperationType(const String& type) |
| 39 { | 39 { |
| 40 if (type == IndexedDBNames::add) | 40 if (type == IndexedDBNames::add) |
| 41 return WebIDBAdd; | 41 return WebIDBAdd; |
| 42 if (type == IndexedDBNames::put) | 42 if (type == IndexedDBNames::put) |
| 43 return WebIDBPut; | 43 return WebIDBPut; |
| 44 if (type == IndexedDBNames::kDelete) | 44 if (type == IndexedDBNames::kDelete) |
| 45 return WebIDBDelete; | 45 return WebIDBDelete; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 64 | 64 |
| 65 case WebIDBClear: | 65 case WebIDBClear: |
| 66 return IndexedDBNames::clear; | 66 return IndexedDBNames::clear; |
| 67 | 67 |
| 68 default: | 68 default: |
| 69 NOTREACHED(); | 69 NOTREACHED(); |
| 70 return IndexedDBNames::add; | 70 return IndexedDBNames::add; |
| 71 } | 71 } |
| 72 } | 72 } |
| 73 | 73 |
| 74 IDBObservation* IDBObservation::create(IDBKey* key, PassRefPtr<IDBValue> value,
WebIDBOperationType type) | 74 IDBObservation* IDBObservation::create(const WebIDBObservation& observation) |
| 75 { | 75 { |
| 76 return new IDBObservation(key, value, type); | 76 return new IDBObservation(observation); |
| 77 } | 77 } |
| 78 | 78 |
| 79 IDBObservation::IDBObservation(IDBKey* key, PassRefPtr<IDBValue> value, WebIDBOp
erationType type) | 79 IDBObservation::IDBObservation(const WebIDBObservation& observation) |
| 80 : m_key(key) | 80 : m_keyRange(observation.keyRange) |
| 81 , m_value(value) | 81 , m_value(IDBValue::create(observation.value)) |
| 82 , m_operationType(type) | 82 , m_operationType(observation.type) |
| 83 { | 83 { |
| 84 } | 84 } |
| 85 | 85 |
| 86 DEFINE_TRACE(IDBObservation) | 86 DEFINE_TRACE(IDBObservation) |
| 87 { | 87 { |
| 88 visitor->trace(m_key); | 88 visitor->trace(m_keyRange); |
| 89 } | 89 } |
| 90 | 90 |
| 91 } // namespace blink | 91 } // namespace blink |
| OLD | NEW |