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

Side by Side Diff: content/renderer/v8_value_converter_impl.cc

Issue 149133005: Update callers of WebArrayBuffer/V8 conversions to use WebArrayBufferConverter (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 | « content/renderer/skia_benchmarking_extension.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/renderer/v8_value_converter_impl.h" 5 #include "content/renderer/v8_value_converter_impl.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/float_util.h" 9 #include "base/float_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "third_party/WebKit/public/platform/WebArrayBuffer.h" 13 #include "third_party/WebKit/public/platform/WebArrayBuffer.h"
14 #include "third_party/WebKit/public/web/WebArrayBufferConverter.h"
14 #include "third_party/WebKit/public/web/WebArrayBufferView.h" 15 #include "third_party/WebKit/public/web/WebArrayBufferView.h"
15 #include "v8/include/v8.h" 16 #include "v8/include/v8.h"
16 17
17 namespace content { 18 namespace content {
18 19
19 namespace { 20 namespace {
20 21
21 // For the sake of the storage API, make this quite large. 22 // For the sake of the storage API, make this quite large.
22 const int kMaxRecursionDepth = 100; 23 const int kMaxRecursionDepth = 100;
23 24
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 } 222 }
222 223
223 return result; 224 return result;
224 } 225 }
225 226
226 v8::Handle<v8::Value> V8ValueConverterImpl::ToArrayBuffer( 227 v8::Handle<v8::Value> V8ValueConverterImpl::ToArrayBuffer(
227 const base::BinaryValue* value) const { 228 const base::BinaryValue* value) const {
228 blink::WebArrayBuffer buffer = 229 blink::WebArrayBuffer buffer =
229 blink::WebArrayBuffer::create(value->GetSize(), 1); 230 blink::WebArrayBuffer::create(value->GetSize(), 1);
230 memcpy(buffer.data(), value->GetBuffer(), value->GetSize()); 231 memcpy(buffer.data(), value->GetBuffer(), value->GetSize());
231 return buffer.toV8Value(); 232 return blink::WebArrayBufferConverter::toV8Value(&buffer);
232 } 233 }
233 234
234 base::Value* V8ValueConverterImpl::FromV8ValueImpl( 235 base::Value* V8ValueConverterImpl::FromV8ValueImpl(
235 v8::Handle<v8::Value> val, 236 v8::Handle<v8::Value> val,
236 FromV8ValueState* state, 237 FromV8ValueState* state,
237 v8::Isolate* isolate) const { 238 v8::Isolate* isolate) const {
238 CHECK(!val.IsEmpty()); 239 CHECK(!val.IsEmpty());
239 240
240 FromV8ValueState::Level state_level(state); 241 FromV8ValueState::Level state_level(state);
241 if (state->HasReachedMaxRecursionDepth()) 242 if (state->HasReachedMaxRecursionDepth())
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 } 351 }
351 return result; 352 return result;
352 } 353 }
353 354
354 base::BinaryValue* V8ValueConverterImpl::FromV8Buffer( 355 base::BinaryValue* V8ValueConverterImpl::FromV8Buffer(
355 v8::Handle<v8::Value> val) const { 356 v8::Handle<v8::Value> val) const {
356 char* data = NULL; 357 char* data = NULL;
357 size_t length = 0; 358 size_t length = 0;
358 359
359 scoped_ptr<blink::WebArrayBuffer> array_buffer( 360 scoped_ptr<blink::WebArrayBuffer> array_buffer(
360 blink::WebArrayBuffer::createFromV8Value(val)); 361 blink::WebArrayBufferConverter::createFromV8Value(val));
361 scoped_ptr<blink::WebArrayBufferView> view; 362 scoped_ptr<blink::WebArrayBufferView> view;
362 if (array_buffer) { 363 if (array_buffer) {
363 data = reinterpret_cast<char*>(array_buffer->data()); 364 data = reinterpret_cast<char*>(array_buffer->data());
364 length = array_buffer->byteLength(); 365 length = array_buffer->byteLength();
365 } else { 366 } else {
366 view.reset(blink::WebArrayBufferView::createFromV8Value(val)); 367 view.reset(blink::WebArrayBufferView::createFromV8Value(val));
367 if (view) { 368 if (view) {
368 data = reinterpret_cast<char*>(view->baseAddress()) + view->byteOffset(); 369 data = reinterpret_cast<char*>(view->baseAddress()) + view->byteOffset();
369 length = view->byteLength(); 370 length = view->byteLength();
370 } 371 }
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 continue; 468 continue;
468 469
469 result->SetWithoutPathExpansion(std::string(*name_utf8, name_utf8.length()), 470 result->SetWithoutPathExpansion(std::string(*name_utf8, name_utf8.length()),
470 child.release()); 471 child.release());
471 } 472 }
472 473
473 return result.release(); 474 return result.release();
474 } 475 }
475 476
476 } // namespace content 477 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/skia_benchmarking_extension.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698