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

Side by Side Diff: extensions/renderer/send_request_natives.cc

Issue 1167423002: Use V8 Maybe APIs in extensions/renderer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « extensions/renderer/script_context.cc ('k') | extensions/renderer/set_icon_natives.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/renderer/send_request_natives.h" 5 #include "extensions/renderer/send_request_natives.h"
6 6
7 #include "base/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "content/public/child/v8_value_converter.h" 8 #include "content/public/child/v8_value_converter.h"
9 #include "extensions/renderer/request_sender.h" 9 #include "extensions/renderer/request_sender.h"
10 #include "extensions/renderer/script_context.h" 10 #include "extensions/renderer/script_context.h"
(...skipping 20 matching lines...) Expand all
31 const v8::FunctionCallbackInfo<v8::Value>& args) { 31 const v8::FunctionCallbackInfo<v8::Value>& args) {
32 args.GetReturnValue().Set( 32 args.GetReturnValue().Set(
33 static_cast<int32_t>(request_sender_->GetNextRequestId())); 33 static_cast<int32_t>(request_sender_->GetNextRequestId()));
34 } 34 }
35 35
36 // Starts an API request to the browser, with an optional callback. The 36 // Starts an API request to the browser, with an optional callback. The
37 // callback will be dispatched to EventBindings::HandleResponse. 37 // callback will be dispatched to EventBindings::HandleResponse.
38 void SendRequestNatives::StartRequest( 38 void SendRequestNatives::StartRequest(
39 const v8::FunctionCallbackInfo<v8::Value>& args) { 39 const v8::FunctionCallbackInfo<v8::Value>& args) {
40 CHECK_EQ(6, args.Length()); 40 CHECK_EQ(6, args.Length());
41 CHECK(args[2]->IsInt32());
42 v8::Local<v8::Context> v8_context = context()->v8_context();
41 std::string name = *v8::String::Utf8Value(args[0]); 43 std::string name = *v8::String::Utf8Value(args[0]);
42 int request_id = args[2]->Int32Value(); 44 int request_id = args[2].As<v8::Int32>()->Value();
43 bool has_callback = args[3]->BooleanValue(); 45 bool has_callback = args[3]->BooleanValue(v8_context).FromJust();
44 bool for_io_thread = args[4]->BooleanValue(); 46 bool for_io_thread = args[4]->BooleanValue(v8_context).FromJust();
45 bool preserve_null_in_objects = args[5]->BooleanValue(); 47 bool preserve_null_in_objects = args[5]->BooleanValue(v8_context).FromJust();
46 48
47 scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create()); 49 scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create());
48 50
49 // See http://crbug.com/149880. The context menus APIs relies on this, but 51 // See http://crbug.com/149880. The context menus APIs relies on this, but
50 // we shouldn't really be doing it (e.g. for the sake of the storage API). 52 // we shouldn't really be doing it (e.g. for the sake of the storage API).
51 converter->SetFunctionAllowed(true); 53 converter->SetFunctionAllowed(true);
52 54
53 if (!preserve_null_in_objects) 55 if (!preserve_null_in_objects)
54 converter->SetStripNullFromObjects(true); 56 converter->SetStripNullFromObjects(true);
55 57
(...skipping 15 matching lines...) Expand all
71 73
72 void SendRequestNatives::GetGlobal( 74 void SendRequestNatives::GetGlobal(
73 const v8::FunctionCallbackInfo<v8::Value>& args) { 75 const v8::FunctionCallbackInfo<v8::Value>& args) {
74 CHECK_EQ(1, args.Length()); 76 CHECK_EQ(1, args.Length());
75 CHECK(args[0]->IsObject()); 77 CHECK(args[0]->IsObject());
76 args.GetReturnValue().Set( 78 args.GetReturnValue().Set(
77 v8::Local<v8::Object>::Cast(args[0])->CreationContext()->Global()); 79 v8::Local<v8::Object>::Cast(args[0])->CreationContext()->Global());
78 } 80 }
79 81
80 } // namespace extensions 82 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/renderer/script_context.cc ('k') | extensions/renderer/set_icon_natives.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698