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

Side by Side Diff: chrome/renderer/extensions/pepper_request_proxy.cc

Issue 107083006: More v8-API-related cleanup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 "chrome/renderer/extensions/pepper_request_proxy.h" 5 #include "chrome/renderer/extensions/pepper_request_proxy.h"
6 6
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "chrome/renderer/extensions/chrome_v8_context.h" 8 #include "chrome/renderer/extensions/chrome_v8_context.h"
9 #include "content/public/renderer/v8_value_converter.h" 9 #include "content/public/renderer/v8_value_converter.h"
10 10
(...skipping 14 matching lines...) Expand all
25 pending_request_map_[request_id] = callback; 25 pending_request_map_[request_id] = callback;
26 26
27 // TODO(sammc): Converting from base::Value to v8::Value and then back to 27 // TODO(sammc): Converting from base::Value to v8::Value and then back to
28 // base::Value is not optimal. For most API calls the JS code doesn't do much. 28 // base::Value is not optimal. For most API calls the JS code doesn't do much.
29 // http://crbug.com/324115. 29 // http://crbug.com/324115.
30 v8::HandleScope scope(isolate_); 30 v8::HandleScope scope(isolate_);
31 scoped_ptr<content::V8ValueConverter> converter( 31 scoped_ptr<content::V8ValueConverter> converter(
32 content::V8ValueConverter::create()); 32 content::V8ValueConverter::create());
33 std::vector<v8::Handle<v8::Value> > v8_args; 33 std::vector<v8::Handle<v8::Value> > v8_args;
34 v8_args.push_back(v8::String::NewFromUtf8(isolate_, request_name.c_str())); 34 v8_args.push_back(v8::String::NewFromUtf8(isolate_, request_name.c_str()));
35 v8_args.push_back(v8::Integer::New(request_id)); 35 v8_args.push_back(v8::Integer::New(isolate_, request_id));
36 for (base::ListValue::const_iterator it = args.begin(); it != args.end(); 36 for (base::ListValue::const_iterator it = args.begin(); it != args.end();
37 ++it) { 37 ++it) {
38 v8_args.push_back(converter->ToV8Value(*it, context_->v8_context())); 38 v8_args.push_back(converter->ToV8Value(*it, context_->v8_context()));
39 } 39 }
40 v8::Handle<v8::Value> v8_error = context_->module_system()->CallModuleMethod( 40 v8::Handle<v8::Value> v8_error = context_->module_system()->CallModuleMethod(
41 "pepper_request", "startRequest", &v8_args); 41 "pepper_request", "startRequest", &v8_args);
42 if (v8_error->IsString()) { 42 if (v8_error->IsString()) {
43 if (error) { 43 if (error) {
44 *error = *v8::String::Utf8Value(v8_error); 44 *error = *v8::String::Utf8Value(v8_error);
45 pending_request_map_.erase(request_id); 45 pending_request_map_.erase(request_id);
46 } 46 }
47 return false; 47 return false;
48 } 48 }
49 49
50 return true; 50 return true;
51 } 51 }
52 52
53 void PepperRequestProxy::OnResponseReceived(int request_id, 53 void PepperRequestProxy::OnResponseReceived(int request_id,
54 bool success, 54 bool success,
55 const base::ListValue& args, 55 const base::ListValue& args,
56 const std::string& error) { 56 const std::string& error) {
57 PendingRequestMap::iterator it = pending_request_map_.find(request_id); 57 PendingRequestMap::iterator it = pending_request_map_.find(request_id);
58 DCHECK(it != pending_request_map_.end()); 58 DCHECK(it != pending_request_map_.end());
59 it->second.Run(success, args, error); 59 it->second.Run(success, args, error);
60 pending_request_map_.erase(it); 60 pending_request_map_.erase(it);
61 } 61 }
62 62
63 } // namespace extensions 63 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/page_actions_custom_bindings.cc ('k') | chrome/renderer/extensions/runtime_custom_bindings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698