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

Side by Side Diff: content/renderer/pepper/v8_var_converter.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 | « no previous file | content/renderer/skia_benchmarking_extension.cc » ('j') | 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/pepper/v8_var_converter.h" 5 #include "content/renderer/pepper/v8_var_converter.h"
6 6
7 #include <map> 7 #include <map>
8 #include <stack> 8 #include <stack>
9 #include <string> 9 #include <string>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/containers/hash_tables.h" 12 #include "base/containers/hash_tables.h"
13 #include "base/location.h" 13 #include "base/location.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "content/public/renderer/renderer_ppapi_host.h" 16 #include "content/public/renderer/renderer_ppapi_host.h"
17 #include "content/renderer/pepper/host_array_buffer_var.h" 17 #include "content/renderer/pepper/host_array_buffer_var.h"
18 #include "content/renderer/pepper/resource_converter.h" 18 #include "content/renderer/pepper/resource_converter.h"
19 #include "ppapi/shared_impl/array_var.h" 19 #include "ppapi/shared_impl/array_var.h"
20 #include "ppapi/shared_impl/dictionary_var.h" 20 #include "ppapi/shared_impl/dictionary_var.h"
21 #include "ppapi/shared_impl/var.h" 21 #include "ppapi/shared_impl/var.h"
22 #include "ppapi/shared_impl/var_tracker.h" 22 #include "ppapi/shared_impl/var_tracker.h"
23 #include "third_party/WebKit/public/platform/WebArrayBuffer.h" 23 #include "third_party/WebKit/public/platform/WebArrayBuffer.h"
24 #include "third_party/WebKit/public/web/WebArrayBufferConverter.h"
24 25
25 using ppapi::ArrayBufferVar; 26 using ppapi::ArrayBufferVar;
26 using ppapi::ArrayVar; 27 using ppapi::ArrayVar;
27 using ppapi::DictionaryVar; 28 using ppapi::DictionaryVar;
28 using ppapi::ScopedPPVar; 29 using ppapi::ScopedPPVar;
29 using ppapi::StringVar; 30 using ppapi::StringVar;
30 using std::make_pair; 31 using std::make_pair;
31 32
32 namespace { 33 namespace {
33 34
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 } 137 }
137 case PP_VARTYPE_ARRAY_BUFFER: { 138 case PP_VARTYPE_ARRAY_BUFFER: {
138 ArrayBufferVar* buffer = ArrayBufferVar::FromPPVar(var); 139 ArrayBufferVar* buffer = ArrayBufferVar::FromPPVar(var);
139 if (!buffer) { 140 if (!buffer) {
140 NOTREACHED(); 141 NOTREACHED();
141 result->Clear(); 142 result->Clear();
142 return false; 143 return false;
143 } 144 }
144 HostArrayBufferVar* host_buffer = 145 HostArrayBufferVar* host_buffer =
145 static_cast<HostArrayBufferVar*>(buffer); 146 static_cast<HostArrayBufferVar*>(buffer);
146 *result = host_buffer->webkit_buffer().toV8Value(); 147 *result = blink::WebArrayBufferConverter::toV8Value(
148 &host_buffer->webkit_buffer());
147 break; 149 break;
148 } 150 }
149 case PP_VARTYPE_ARRAY: 151 case PP_VARTYPE_ARRAY:
150 *result = v8::Array::New(isolate); 152 *result = v8::Array::New(isolate);
151 break; 153 break;
152 case PP_VARTYPE_DICTIONARY: 154 case PP_VARTYPE_DICTIONARY:
153 *result = v8::Object::New(isolate); 155 *result = v8::Object::New(isolate);
154 break; 156 break;
155 case PP_VARTYPE_OBJECT: 157 case PP_VARTYPE_OBJECT:
156 case PP_VARTYPE_RESOURCE: 158 case PP_VARTYPE_RESOURCE:
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 *result = PP_MakeInt32(val->ToInt32()->Value()); 208 *result = PP_MakeInt32(val->ToInt32()->Value());
207 } else if (val->IsNumber() || val->IsNumberObject()) { 209 } else if (val->IsNumber() || val->IsNumberObject()) {
208 *result = PP_MakeDouble(val->ToNumber()->Value()); 210 *result = PP_MakeDouble(val->ToNumber()->Value());
209 } else if (val->IsString() || val->IsStringObject()) { 211 } else if (val->IsString() || val->IsStringObject()) {
210 v8::String::Utf8Value utf8(val->ToString()); 212 v8::String::Utf8Value utf8(val->ToString());
211 *result = StringVar::StringToPPVar(std::string(*utf8, utf8.length())); 213 *result = StringVar::StringToPPVar(std::string(*utf8, utf8.length()));
212 } else if (val->IsArray()) { 214 } else if (val->IsArray()) {
213 *result = (new ArrayVar())->GetPPVar(); 215 *result = (new ArrayVar())->GetPPVar();
214 } else if (val->IsObject()) { 216 } else if (val->IsObject()) {
215 scoped_ptr<blink::WebArrayBuffer> web_array_buffer( 217 scoped_ptr<blink::WebArrayBuffer> web_array_buffer(
216 blink::WebArrayBuffer::createFromV8Value(val)); 218 blink::WebArrayBufferConverter::createFromV8Value(val));
217 if (web_array_buffer.get()) { 219 if (web_array_buffer.get()) {
218 scoped_refptr<HostArrayBufferVar> buffer_var(new HostArrayBufferVar( 220 scoped_refptr<HostArrayBufferVar> buffer_var(new HostArrayBufferVar(
219 *web_array_buffer)); 221 *web_array_buffer));
220 *result = buffer_var->GetPPVar(); 222 *result = buffer_var->GetPPVar();
221 } else { 223 } else {
222 bool was_resource; 224 bool was_resource;
223 if (!resource_converter->FromV8Value(val->ToObject(), context, result, 225 if (!resource_converter->FromV8Value(val->ToObject(), context, result,
224 &was_resource)) 226 &was_resource))
225 return false; 227 return false;
226 if (!was_resource) { 228 if (!was_resource) {
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 bool success = dict_var->SetWithStringKey( 520 bool success = dict_var->SetWithStringKey(
519 std::string(*name_utf8, name_utf8.length()), child_var); 521 std::string(*name_utf8, name_utf8.length()), child_var);
520 DCHECK(success); 522 DCHECK(success);
521 } 523 }
522 } 524 }
523 } 525 }
524 resource_converter_->Flush(base::Bind(callback, root)); 526 resource_converter_->Flush(base::Bind(callback, root));
525 } 527 }
526 528
527 } // namespace content 529 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/renderer/skia_benchmarking_extension.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698