Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(295)

Side by Side Diff: third_party/WebKit/Source/modules/indexeddb/IDBObservation.cpp

Issue 2125213002: [IndexedDB] Propogating changes to observers : Renderer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lifetime
Patch Set: Minor bugs fixed Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/IDBObserverChangesRecord.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 IDBObserverChangesRecord::~IDBObserverChangesRecord() {} 20 IDBObservation::~IDBObservation() {}
20 21
21 ScriptValue IDBObserverChangesRecord::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, IDBAny::createUndefined());
jsbell 2016/07/14 20:08:14 I'd lean towards: return ScriptValue(scriptState,
palakj1 2016/07/15 20:16:05 Was looking for something like that. Thanks for po
26
27 return ScriptValue::from(scriptState, m_keyRange);
24 } 28 }
25 29
26 ScriptValue IDBObserverChangesRecord::value(ScriptState* scriptState) 30 ScriptValue IDBObservation::value(ScriptState* scriptState)
27 { 31 {
28 IDBAny* value; 32 IDBAny* value;
29 if (!m_value) { 33 if (!m_value) {
jsbell 2016/07/14 20:08:14 Not this CL but: don't need {} if every branch of
palakj1 2016/07/15 20:16:05 Done.
30 value = IDBAny::createUndefined(); 34 value = IDBAny::createUndefined();
31 } else { 35 } else {
32 value = IDBAny::create(m_value); 36 value = IDBAny::create(m_value);
33 } 37 }
34 ScriptValue scriptValue = ScriptValue::from(scriptState, value); 38 ScriptValue scriptValue = ScriptValue::from(scriptState, value);
jsbell 2016/07/14 20:08:14 Not this CL but: why is there a temp variable here
35 return scriptValue; 39 return scriptValue;
36 } 40 }
37 41
38 WebIDBOperationType IDBObserverChangesRecord::stringToOperationType(const String & type) 42 WebIDBOperationType IDBObservation::stringToOperationType(const String& type)
39 { 43 {
40 if (type == IndexedDBNames::add) 44 if (type == IndexedDBNames::add)
41 return WebIDBAdd; 45 return WebIDBAdd;
42 if (type == IndexedDBNames::put) 46 if (type == IndexedDBNames::put)
43 return WebIDBPut; 47 return WebIDBPut;
44 if (type == IndexedDBNames::kDelete) 48 if (type == IndexedDBNames::kDelete)
45 return WebIDBDelete; 49 return WebIDBDelete;
46 if (type == IndexedDBNames::clear) 50 if (type == IndexedDBNames::clear)
47 return WebIDBClear; 51 return WebIDBClear;
48 52
49 NOTREACHED(); 53 NOTREACHED();
50 return WebIDBAdd; 54 return WebIDBAdd;
51 } 55 }
52 56
53 const String& IDBObserverChangesRecord::type() const 57 const String& IDBObservation::type() const
54 { 58 {
55 switch (m_operationType) { 59 switch (m_operationType) {
56 case WebIDBAdd: 60 case WebIDBAdd:
57 return IndexedDBNames::add; 61 return IndexedDBNames::add;
58 62
59 case WebIDBPut: 63 case WebIDBPut:
60 return IndexedDBNames::put; 64 return IndexedDBNames::put;
61 65
62 case WebIDBDelete: 66 case WebIDBDelete:
63 return IndexedDBNames::kDelete; 67 return IndexedDBNames::kDelete;
64 68
65 case WebIDBClear: 69 case WebIDBClear:
66 return IndexedDBNames::clear; 70 return IndexedDBNames::clear;
67 71
68 default: 72 default:
69 NOTREACHED(); 73 NOTREACHED();
70 return IndexedDBNames::add; 74 return IndexedDBNames::add;
71 } 75 }
72 } 76 }
73 77
74 IDBObserverChangesRecord* IDBObserverChangesRecord::create(IDBKey* key, PassRefP tr<IDBValue> value, WebIDBOperationType type) 78 IDBObservation* IDBObservation::create(const WebIDBObservation& observation)
75 { 79 {
76 return new IDBObserverChangesRecord(key, value, type); 80 return new IDBObservation(observation);
77 } 81 }
78 82
79 IDBObserverChangesRecord::IDBObserverChangesRecord(IDBKey* key, PassRefPtr<IDBVa lue> value, WebIDBOperationType type) 83 IDBObservation::IDBObservation(const WebIDBObservation& observation)
80 : m_key(key) 84 : m_keyRange(observation.keyRange)
81 , m_value(value) 85 , m_value(IDBValue::create(observation.value))
82 , m_operationType(type) 86 , m_operationType(observation.type)
83 { 87 {
84 } 88 }
85 89
86 DEFINE_TRACE(IDBObserverChangesRecord) 90 DEFINE_TRACE(IDBObservation)
87 { 91 {
88 visitor->trace(m_key); 92 visitor->trace(m_keyRange);
89 } 93 }
90 94
91 } // namespace blink 95 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698