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

Side by Side Diff: Source/bindings/v8/IDBBindingUtilities.cpp

Issue 170603003: Use nullptr_t for RefPtr, PassRefPtr and RawPtr. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Final rebase Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « Source/bindings/v8/Dictionary.cpp ('k') | Source/bindings/v8/ScriptCallStackFactory.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 // input type is constrained to Uint8Array to match the output type. 180 // input type is constrained to Uint8Array to match the output type.
181 ArrayBufferView* view = WebCore::V8ArrayBufferView::toNative(value->ToOb ject()); 181 ArrayBufferView* view = WebCore::V8ArrayBufferView::toNative(value->ToOb ject());
182 const char* start = static_cast<const char*>(view->baseAddress()); 182 const char* start = static_cast<const char*>(view->baseAddress());
183 size_t length = view->byteLength(); 183 size_t length = view->byteLength();
184 return IDBKey::createBinary(SharedBuffer::create(start, length)); 184 return IDBKey::createBinary(SharedBuffer::create(start, length));
185 } 185 }
186 if (value->IsArray()) { 186 if (value->IsArray()) {
187 v8::Handle<v8::Array> array = v8::Handle<v8::Array>::Cast(value); 187 v8::Handle<v8::Array> array = v8::Handle<v8::Array>::Cast(value);
188 188
189 if (stack.contains(array)) 189 if (stack.contains(array))
190 return 0; 190 return nullptr;
191 if (stack.size() >= maximumDepth) 191 if (stack.size() >= maximumDepth)
192 return 0; 192 return nullptr;
193 stack.append(array); 193 stack.append(array);
194 194
195 IDBKey::KeyArray subkeys; 195 IDBKey::KeyArray subkeys;
196 uint32_t length = array->Length(); 196 uint32_t length = array->Length();
197 for (uint32_t i = 0; i < length; ++i) { 197 for (uint32_t i = 0; i < length; ++i) {
198 v8::Local<v8::Value> item = array->Get(v8::Int32::New(isolate, i)); 198 v8::Local<v8::Value> item = array->Get(v8::Int32::New(isolate, i));
199 RefPtr<IDBKey> subkey = createIDBKeyFromValue(item, stack, isolate, allowExperimentalTypes); 199 RefPtr<IDBKey> subkey = createIDBKeyFromValue(item, stack, isolate, allowExperimentalTypes);
200 if (!subkey) 200 if (!subkey)
201 subkeys.append(IDBKey::createInvalid()); 201 subkeys.append(IDBKey::createInvalid());
202 else 202 else
203 subkeys.append(subkey); 203 subkeys.append(subkey);
204 } 204 }
205 205
206 stack.removeLast(); 206 stack.removeLast();
207 return IDBKey::createArray(subkeys); 207 return IDBKey::createArray(subkeys);
208 } 208 }
209 return 0; 209 return nullptr;
210 } 210 }
211 211
212 static PassRefPtr<IDBKey> createIDBKeyFromValue(v8::Handle<v8::Value> value, v8: :Isolate* isolate, bool allowExperimentalTypes = false) 212 static PassRefPtr<IDBKey> createIDBKeyFromValue(v8::Handle<v8::Value> value, v8: :Isolate* isolate, bool allowExperimentalTypes = false)
213 { 213 {
214 Vector<v8::Handle<v8::Array> > stack; 214 Vector<v8::Handle<v8::Array> > stack;
215 RefPtr<IDBKey> key = createIDBKeyFromValue(value, stack, isolate, allowExper imentalTypes); 215 RefPtr<IDBKey> key = createIDBKeyFromValue(value, stack, isolate, allowExper imentalTypes);
216 if (key) 216 if (key)
217 return key; 217 return key;
218 return IDBKey::createInvalid(); 218 return IDBKey::createInvalid();
219 } 219 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 Vector<String> keyPathElements; 310 Vector<String> keyPathElements;
311 IDBKeyPathParseError error; 311 IDBKeyPathParseError error;
312 IDBParseKeyPath(keyPath, keyPathElements, error); 312 IDBParseKeyPath(keyPath, keyPathElements, error);
313 ASSERT(error == IDBKeyPathParseErrorNone); 313 ASSERT(error == IDBKeyPathParseErrorNone);
314 ASSERT(isolate->InContext()); 314 ASSERT(isolate->InContext());
315 315
316 v8::HandleScope handleScope(isolate); 316 v8::HandleScope handleScope(isolate);
317 v8::Handle<v8::Value> v8Value(value.v8Value()); 317 v8::Handle<v8::Value> v8Value(value.v8Value());
318 v8::Handle<v8::Value> v8Key(getNthValueOnKeyPath(v8Value, keyPathElements, k eyPathElements.size(), isolate)); 318 v8::Handle<v8::Value> v8Key(getNthValueOnKeyPath(v8Value, keyPathElements, k eyPathElements.size(), isolate));
319 if (v8Key.IsEmpty()) 319 if (v8Key.IsEmpty())
320 return 0; 320 return nullptr;
321 return createIDBKeyFromValue(v8Key, isolate, allowExperimentalTypes); 321 return createIDBKeyFromValue(v8Key, isolate, allowExperimentalTypes);
322 } 322 }
323 323
324 static PassRefPtr<IDBKey> createIDBKeyFromScriptValueAndKeyPath(const ScriptValu e& value, const IDBKeyPath& keyPath, v8::Isolate* isolate, bool allowExperimenta lTypes = false) 324 static PassRefPtr<IDBKey> createIDBKeyFromScriptValueAndKeyPath(const ScriptValu e& value, const IDBKeyPath& keyPath, v8::Isolate* isolate, bool allowExperimenta lTypes = false)
325 { 325 {
326 ASSERT(!keyPath.isNull()); 326 ASSERT(!keyPath.isNull());
327 v8::HandleScope handleScope(isolate); 327 v8::HandleScope handleScope(isolate);
328 if (keyPath.type() == IDBKeyPath::ArrayType) { 328 if (keyPath.type() == IDBKeyPath::ArrayType) {
329 IDBKey::KeyArray result; 329 IDBKey::KeyArray result;
330 const Vector<String>& array = keyPath.array(); 330 const Vector<String>& array = keyPath.array();
331 for (size_t i = 0; i < array.size(); ++i) { 331 for (size_t i = 0; i < array.size(); ++i) {
332 RefPtr<IDBKey> key = createIDBKeyFromScriptValueAndKeyPath(value, ar ray[i], isolate, allowExperimentalTypes); 332 RefPtr<IDBKey> key = createIDBKeyFromScriptValueAndKeyPath(value, ar ray[i], isolate, allowExperimentalTypes);
333 if (!key) 333 if (!key)
334 return 0; 334 return nullptr;
335 result.append(key); 335 result.append(key);
336 } 336 }
337 return IDBKey::createArray(result); 337 return IDBKey::createArray(result);
338 } 338 }
339 339
340 ASSERT(keyPath.type() == IDBKeyPath::StringType); 340 ASSERT(keyPath.type() == IDBKeyPath::StringType);
341 return createIDBKeyFromScriptValueAndKeyPath(value, keyPath.string(), isolat e, allowExperimentalTypes); 341 return createIDBKeyFromScriptValueAndKeyPath(value, keyPath.string(), isolat e, allowExperimentalTypes);
342 } 342 }
343 343
344 PassRefPtr<IDBKey> createIDBKeyFromScriptValueAndKeyPath(DOMRequestState* state, const ScriptValue& value, const IDBKeyPath& keyPath) 344 PassRefPtr<IDBKey> createIDBKeyFromScriptValueAndKeyPath(DOMRequestState* state, const ScriptValue& value, const IDBKeyPath& keyPath)
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 const bool allowExperimentalTypes = true; 454 const bool allowExperimentalTypes = true;
455 RefPtr<IDBKey> expectedKey = createIDBKeyFromScriptValueAndKeyPath(scriptVal ue, keyPath, isolate, allowExperimentalTypes); 455 RefPtr<IDBKey> expectedKey = createIDBKeyFromScriptValueAndKeyPath(scriptVal ue, keyPath, isolate, allowExperimentalTypes);
456 ASSERT(!expectedKey || expectedKey->isEqual(key.get())); 456 ASSERT(!expectedKey || expectedKey->isEqual(key.get()));
457 457
458 bool injected = injectV8KeyIntoV8Value(keyValue.v8Value(), scriptValue.v8Val ue(), keyPath, isolate); 458 bool injected = injectV8KeyIntoV8Value(keyValue.v8Value(), scriptValue.v8Val ue(), keyPath, isolate);
459 ASSERT_UNUSED(injected, injected); 459 ASSERT_UNUSED(injected, injected);
460 } 460 }
461 #endif 461 #endif
462 462
463 } // namespace WebCore 463 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/v8/Dictionary.cpp ('k') | Source/bindings/v8/ScriptCallStackFactory.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698