Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "modules/indexeddb/IDBObserverChangesRecord.h" | |
| 6 | |
| 7 #include "bindings/core/v8/ExceptionState.h" | |
| 8 #include "bindings/core/v8/ScriptState.h" | |
| 9 #include "bindings/core/v8/ToV8.h" | |
| 10 #include "bindings/modules/v8/ToV8ForModules.h" | |
| 11 #include "bindings/modules/v8/V8BindingForModules.h" | |
| 12 #include "modules/IndexedDBNames.h" | |
| 13 #include "modules/indexeddb/IDBAny.h" | |
| 14 #include "modules/indexeddb/IDBKey.h" | |
| 15 #include "modules/indexeddb/IDBValue.h" | |
| 16 | |
| 17 namespace blink { | |
| 18 | |
| 19 IDBObserverChangesRecord::~IDBObserverChangesRecord() {} | |
| 20 | |
| 21 ScriptValue IDBObserverChangesRecord::key(ScriptState* scriptState) | |
| 22 { | |
| 23 return ScriptValue::from(scriptState, m_key); | |
| 24 } | |
| 25 | |
| 26 ScriptValue IDBObserverChangesRecord::value(ScriptState* scriptState) | |
| 27 { | |
| 28 IDBAny* value; | |
| 29 if (!m_value) { | |
| 30 value = IDBAny::createUndefined(); | |
| 31 } else { | |
| 32 value = IDBAny::create(m_value); | |
| 33 } | |
| 34 ScriptValue scriptValue = ScriptValue::from(scriptState, value); | |
| 35 return scriptValue; | |
| 36 } | |
| 37 | |
| 38 WebIDBOperationType IDBObserverChangesRecord::stringToOperationType(const String & type) | |
| 39 { | |
| 40 if (type == IndexedDBNames::add) | |
| 41 return WebIDBAdd; | |
| 42 if (type == IndexedDBNames::put) | |
| 43 return WebIDBPut; | |
| 44 if (type == IndexedDBNames::del) | |
| 45 return WebIDBDelete; | |
| 46 if (type == IndexedDBNames::clear) | |
| 47 return WebIDBClear; | |
| 48 | |
| 49 NOTREACHED(); | |
| 50 return WebIDBAdd; | |
| 51 } | |
| 52 | |
| 53 const String& IDBObserverChangesRecord::type() const | |
| 54 { | |
| 55 switch (m_operationType) { | |
| 56 case WebIDBAdd: | |
| 57 return IndexedDBNames::add; | |
| 58 | |
| 59 case WebIDBPut: | |
| 60 return IndexedDBNames::put; | |
| 61 | |
| 62 case WebIDBDelete: | |
|
Marijn Kruisselbrink
2016/06/15 13:02:44
is this missing a return IndexedDBNames::del?
palakj1
2016/06/15 19:16:30
oops! corrected.
| |
| 63 | |
| 64 case WebIDBClear: | |
| 65 return IndexedDBNames::clear; | |
| 66 | |
| 67 default: | |
| 68 NOTREACHED(); | |
| 69 return IndexedDBNames::add; | |
| 70 } | |
| 71 } | |
| 72 | |
| 73 IDBObserverChangesRecord* IDBObserverChangesRecord::create(IDBKey* key, IDBValue * value, WebIDBOperationType type) | |
| 74 { | |
| 75 return new IDBObserverChangesRecord(key, value, type); | |
| 76 } | |
| 77 | |
| 78 IDBObserverChangesRecord::IDBObserverChangesRecord(IDBKey* key, IDBValue* value, WebIDBOperationType type) | |
| 79 : m_key(key) | |
| 80 , m_value(value) | |
| 81 , m_operationType(type) | |
| 82 { | |
| 83 } | |
| 84 | |
| 85 DEFINE_TRACE(IDBObserverChangesRecord) | |
| 86 { | |
| 87 visitor->trace(m_key); | |
| 88 } | |
| 89 | |
| 90 } // namespace blink | |
| OLD | NEW |