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

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

Issue 2821443002: Revert of Move ScriptState::GetExecutionContext (Part 5) (Closed)
Patch Set: Revert Created 3 years, 8 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 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 12 matching lines...) Expand all
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #include "modules/indexeddb/IDBKeyRange.h" 26 #include "modules/indexeddb/IDBKeyRange.h"
27 27
28 #include "bindings/core/v8/ExceptionState.h" 28 #include "bindings/core/v8/ExceptionState.h"
29 #include "bindings/core/v8/ToV8ForCore.h" 29 #include "bindings/core/v8/ToV8ForCore.h"
30 #include "bindings/modules/v8/ToV8ForModules.h" 30 #include "bindings/modules/v8/ToV8ForModules.h"
31 #include "bindings/modules/v8/V8BindingForModules.h" 31 #include "bindings/modules/v8/V8BindingForModules.h"
32 #include "core/dom/ExceptionCode.h" 32 #include "core/dom/ExceptionCode.h"
33 #include "core/dom/ExecutionContext.h"
34 #include "modules/indexeddb/IDBDatabase.h" 33 #include "modules/indexeddb/IDBDatabase.h"
35 34
36 namespace blink { 35 namespace blink {
37 36
38 IDBKeyRange* IDBKeyRange::FromScriptValue(ExecutionContext* context, 37 IDBKeyRange* IDBKeyRange::FromScriptValue(ExecutionContext* context,
39 const ScriptValue& value, 38 const ScriptValue& value,
40 ExceptionState& exception_state) { 39 ExceptionState& exception_state) {
41 if (value.IsUndefined() || value.IsNull()) 40 if (value.IsUndefined() || value.IsNull())
42 return nullptr; 41 return nullptr;
43 42
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 return nullptr; 87 return nullptr;
89 } 88 }
90 89
91 return IDBKeyRange::Create(key, key, kLowerBoundClosed, kUpperBoundClosed); 90 return IDBKeyRange::Create(key, key, kLowerBoundClosed, kUpperBoundClosed);
92 } 91 }
93 92
94 IDBKeyRange* IDBKeyRange::only(ScriptState* script_state, 93 IDBKeyRange* IDBKeyRange::only(ScriptState* script_state,
95 const ScriptValue& key_value, 94 const ScriptValue& key_value,
96 ExceptionState& exception_state) { 95 ExceptionState& exception_state) {
97 IDBKey* key = 96 IDBKey* key =
98 ScriptValue::To<IDBKey*>(ToIsolate(ExecutionContext::From(script_state)), 97 ScriptValue::To<IDBKey*>(ToIsolate(script_state->GetExecutionContext()),
99 key_value, exception_state); 98 key_value, exception_state);
100 if (exception_state.HadException()) 99 if (exception_state.HadException())
101 return nullptr; 100 return nullptr;
102 if (!key || !key->IsValid()) { 101 if (!key || !key->IsValid()) {
103 exception_state.ThrowDOMException(kDataError, 102 exception_state.ThrowDOMException(kDataError,
104 IDBDatabase::kNotValidKeyErrorMessage); 103 IDBDatabase::kNotValidKeyErrorMessage);
105 return nullptr; 104 return nullptr;
106 } 105 }
107 106
108 return IDBKeyRange::Create(key, key, kLowerBoundClosed, kUpperBoundClosed); 107 return IDBKeyRange::Create(key, key, kLowerBoundClosed, kUpperBoundClosed);
109 } 108 }
110 109
111 IDBKeyRange* IDBKeyRange::lowerBound(ScriptState* script_state, 110 IDBKeyRange* IDBKeyRange::lowerBound(ScriptState* script_state,
112 const ScriptValue& bound_value, 111 const ScriptValue& bound_value,
113 bool open, 112 bool open,
114 ExceptionState& exception_state) { 113 ExceptionState& exception_state) {
115 IDBKey* bound = 114 IDBKey* bound =
116 ScriptValue::To<IDBKey*>(ToIsolate(ExecutionContext::From(script_state)), 115 ScriptValue::To<IDBKey*>(ToIsolate(script_state->GetExecutionContext()),
117 bound_value, exception_state); 116 bound_value, exception_state);
118 if (exception_state.HadException()) 117 if (exception_state.HadException())
119 return nullptr; 118 return nullptr;
120 if (!bound || !bound->IsValid()) { 119 if (!bound || !bound->IsValid()) {
121 exception_state.ThrowDOMException(kDataError, 120 exception_state.ThrowDOMException(kDataError,
122 IDBDatabase::kNotValidKeyErrorMessage); 121 IDBDatabase::kNotValidKeyErrorMessage);
123 return nullptr; 122 return nullptr;
124 } 123 }
125 124
126 return IDBKeyRange::Create(bound, nullptr, 125 return IDBKeyRange::Create(bound, nullptr,
127 open ? kLowerBoundOpen : kLowerBoundClosed, 126 open ? kLowerBoundOpen : kLowerBoundClosed,
128 kUpperBoundOpen); 127 kUpperBoundOpen);
129 } 128 }
130 129
131 IDBKeyRange* IDBKeyRange::upperBound(ScriptState* script_state, 130 IDBKeyRange* IDBKeyRange::upperBound(ScriptState* script_state,
132 const ScriptValue& bound_value, 131 const ScriptValue& bound_value,
133 bool open, 132 bool open,
134 ExceptionState& exception_state) { 133 ExceptionState& exception_state) {
135 IDBKey* bound = 134 IDBKey* bound =
136 ScriptValue::To<IDBKey*>(ToIsolate(ExecutionContext::From(script_state)), 135 ScriptValue::To<IDBKey*>(ToIsolate(script_state->GetExecutionContext()),
137 bound_value, exception_state); 136 bound_value, exception_state);
138 if (exception_state.HadException()) 137 if (exception_state.HadException())
139 return nullptr; 138 return nullptr;
140 if (!bound || !bound->IsValid()) { 139 if (!bound || !bound->IsValid()) {
141 exception_state.ThrowDOMException(kDataError, 140 exception_state.ThrowDOMException(kDataError,
142 IDBDatabase::kNotValidKeyErrorMessage); 141 IDBDatabase::kNotValidKeyErrorMessage);
143 return nullptr; 142 return nullptr;
144 } 143 }
145 144
146 return IDBKeyRange::Create(nullptr, bound, kLowerBoundOpen, 145 return IDBKeyRange::Create(nullptr, bound, kLowerBoundOpen,
147 open ? kUpperBoundOpen : kUpperBoundClosed); 146 open ? kUpperBoundOpen : kUpperBoundClosed);
148 } 147 }
149 148
150 IDBKeyRange* IDBKeyRange::bound(ScriptState* script_state, 149 IDBKeyRange* IDBKeyRange::bound(ScriptState* script_state,
151 const ScriptValue& lower_value, 150 const ScriptValue& lower_value,
152 const ScriptValue& upper_value, 151 const ScriptValue& upper_value,
153 bool lower_open, 152 bool lower_open,
154 bool upper_open, 153 bool upper_open,
155 ExceptionState& exception_state) { 154 ExceptionState& exception_state) {
156 IDBKey* lower = 155 IDBKey* lower =
157 ScriptValue::To<IDBKey*>(ToIsolate(ExecutionContext::From(script_state)), 156 ScriptValue::To<IDBKey*>(ToIsolate(script_state->GetExecutionContext()),
158 lower_value, exception_state); 157 lower_value, exception_state);
159 if (exception_state.HadException()) 158 if (exception_state.HadException())
160 return nullptr; 159 return nullptr;
161 if (!lower || !lower->IsValid()) { 160 if (!lower || !lower->IsValid()) {
162 exception_state.ThrowDOMException(kDataError, 161 exception_state.ThrowDOMException(kDataError,
163 IDBDatabase::kNotValidKeyErrorMessage); 162 IDBDatabase::kNotValidKeyErrorMessage);
164 return nullptr; 163 return nullptr;
165 } 164 }
166 165
167 IDBKey* upper = 166 IDBKey* upper =
168 ScriptValue::To<IDBKey*>(ToIsolate(ExecutionContext::From(script_state)), 167 ScriptValue::To<IDBKey*>(ToIsolate(script_state->GetExecutionContext()),
169 upper_value, exception_state); 168 upper_value, exception_state);
170 if (exception_state.HadException()) 169 if (exception_state.HadException())
171 return nullptr; 170 return nullptr;
172 if (!upper || !upper->IsValid()) { 171 if (!upper || !upper->IsValid()) {
173 exception_state.ThrowDOMException(kDataError, 172 exception_state.ThrowDOMException(kDataError,
174 IDBDatabase::kNotValidKeyErrorMessage); 173 IDBDatabase::kNotValidKeyErrorMessage);
175 return nullptr; 174 return nullptr;
176 } 175 }
177 176
178 if (upper->IsLessThan(lower)) { 177 if (upper->IsLessThan(lower)) {
(...skipping 10 matching lines...) Expand all
189 188
190 return IDBKeyRange::Create(lower, upper, 189 return IDBKeyRange::Create(lower, upper,
191 lower_open ? kLowerBoundOpen : kLowerBoundClosed, 190 lower_open ? kLowerBoundOpen : kLowerBoundClosed,
192 upper_open ? kUpperBoundOpen : kUpperBoundClosed); 191 upper_open ? kUpperBoundOpen : kUpperBoundClosed);
193 } 192 }
194 193
195 bool IDBKeyRange::includes(ScriptState* script_state, 194 bool IDBKeyRange::includes(ScriptState* script_state,
196 const ScriptValue& key_value, 195 const ScriptValue& key_value,
197 ExceptionState& exception_state) { 196 ExceptionState& exception_state) {
198 IDBKey* key = 197 IDBKey* key =
199 ScriptValue::To<IDBKey*>(ToIsolate(ExecutionContext::From(script_state)), 198 ScriptValue::To<IDBKey*>(ToIsolate(script_state->GetExecutionContext()),
200 key_value, exception_state); 199 key_value, exception_state);
201 if (exception_state.HadException()) 200 if (exception_state.HadException())
202 return false; 201 return false;
203 if (!key || !key->IsValid()) { 202 if (!key || !key->IsValid()) {
204 exception_state.ThrowDOMException(kDataError, 203 exception_state.ThrowDOMException(kDataError,
205 IDBDatabase::kNotValidKeyErrorMessage); 204 IDBDatabase::kNotValidKeyErrorMessage);
206 return false; 205 return false;
207 } 206 }
208 207
209 if (lower_) { 208 if (lower_) {
(...skipping 14 matching lines...) Expand all
224 return false; 223 return false;
225 } else { 224 } else {
226 if (c > 0) 225 if (c > 0)
227 return false; 226 return false;
228 } 227 }
229 } 228 }
230 return true; 229 return true;
231 } 230 }
232 231
233 } // namespace blink 232 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698