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

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

Issue 1899083003: Convert //extensions/renderer from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 8 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_injector.h ('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 <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "content/public/child/v8_value_converter.h" 10 #include "content/public/child/v8_value_converter.h"
(...skipping 21 matching lines...) Expand all
32 const v8::FunctionCallbackInfo<v8::Value>& args) { 32 const v8::FunctionCallbackInfo<v8::Value>& args) {
33 CHECK_EQ(5, args.Length()); 33 CHECK_EQ(5, args.Length());
34 std::string name = *v8::String::Utf8Value(args[0]); 34 std::string name = *v8::String::Utf8Value(args[0]);
35 bool has_callback = args[2]->BooleanValue(); 35 bool has_callback = args[2]->BooleanValue();
36 bool for_io_thread = args[3]->BooleanValue(); 36 bool for_io_thread = args[3]->BooleanValue();
37 bool preserve_null_in_objects = args[4]->BooleanValue(); 37 bool preserve_null_in_objects = args[4]->BooleanValue();
38 38
39 int request_id = request_sender_->GetNextRequestId(); 39 int request_id = request_sender_->GetNextRequestId();
40 args.GetReturnValue().Set(static_cast<int32_t>(request_id)); 40 args.GetReturnValue().Set(static_cast<int32_t>(request_id));
41 41
42 scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create()); 42 std::unique_ptr<V8ValueConverter> converter(V8ValueConverter::create());
43 43
44 // See http://crbug.com/149880. The context menus APIs relies on this, but 44 // See http://crbug.com/149880. The context menus APIs relies on this, but
45 // we shouldn't really be doing it (e.g. for the sake of the storage API). 45 // we shouldn't really be doing it (e.g. for the sake of the storage API).
46 converter->SetFunctionAllowed(true); 46 converter->SetFunctionAllowed(true);
47 47
48 if (!preserve_null_in_objects) 48 if (!preserve_null_in_objects)
49 converter->SetStripNullFromObjects(true); 49 converter->SetStripNullFromObjects(true);
50 50
51 scoped_ptr<base::Value> value_args( 51 std::unique_ptr<base::Value> value_args(
52 converter->FromV8Value(args[1], context()->v8_context())); 52 converter->FromV8Value(args[1], context()->v8_context()));
53 if (!value_args.get() || !value_args->IsType(base::Value::TYPE_LIST)) { 53 if (!value_args.get() || !value_args->IsType(base::Value::TYPE_LIST)) {
54 NOTREACHED() << "Unable to convert args passed to StartRequest"; 54 NOTREACHED() << "Unable to convert args passed to StartRequest";
55 return; 55 return;
56 } 56 }
57 57
58 request_sender_->StartRequest( 58 request_sender_->StartRequest(
59 context(), 59 context(),
60 name, 60 name,
61 request_id, 61 request_id,
62 has_callback, 62 has_callback,
63 for_io_thread, 63 for_io_thread,
64 static_cast<base::ListValue*>(value_args.get())); 64 static_cast<base::ListValue*>(value_args.get()));
65 } 65 }
66 66
67 void SendRequestNatives::GetGlobal( 67 void SendRequestNatives::GetGlobal(
68 const v8::FunctionCallbackInfo<v8::Value>& args) { 68 const v8::FunctionCallbackInfo<v8::Value>& args) {
69 CHECK_EQ(1, args.Length()); 69 CHECK_EQ(1, args.Length());
70 CHECK(args[0]->IsObject()); 70 CHECK(args[0]->IsObject());
71 v8::Local<v8::Context> v8_context = 71 v8::Local<v8::Context> v8_context =
72 v8::Local<v8::Object>::Cast(args[0])->CreationContext(); 72 v8::Local<v8::Object>::Cast(args[0])->CreationContext();
73 if (ContextCanAccessObject(context()->v8_context(), v8_context->Global(), 73 if (ContextCanAccessObject(context()->v8_context(), v8_context->Global(),
74 false)) { 74 false)) {
75 args.GetReturnValue().Set(v8_context->Global()); 75 args.GetReturnValue().Set(v8_context->Global());
76 } 76 }
77 } 77 }
78 78
79 } // namespace extensions 79 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/renderer/script_injector.h ('k') | extensions/renderer/set_icon_natives.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698