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

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

Issue 2846743002: Switch SupportsUserData uses to use unique_ptr. (Closed)
Patch Set: Created 3 years, 7 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/native_extension_bindings_system.h" 5 #include "extensions/renderer/native_extension_bindings_system.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "content/public/common/console_message_level.h" 9 #include "content/public/common/console_message_level.h"
10 #include "content/public/common/content_switches.h" 10 #include "content/public/common/content_switches.h"
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 void NativeExtensionBindingsSystem::DidCreateScriptContext( 363 void NativeExtensionBindingsSystem::DidCreateScriptContext(
364 ScriptContext* context) { 364 ScriptContext* context) {
365 v8::Isolate* isolate = context->isolate(); 365 v8::Isolate* isolate = context->isolate();
366 v8::HandleScope handle_scope(isolate); 366 v8::HandleScope handle_scope(isolate);
367 v8::Local<v8::Context> v8_context = context->v8_context(); 367 v8::Local<v8::Context> v8_context = context->v8_context();
368 gin::PerContextData* per_context_data = gin::PerContextData::From(v8_context); 368 gin::PerContextData* per_context_data = gin::PerContextData::From(v8_context);
369 DCHECK(per_context_data); 369 DCHECK(per_context_data);
370 DCHECK(!per_context_data->GetUserData(kBindingsSystemPerContextKey)); 370 DCHECK(!per_context_data->GetUserData(kBindingsSystemPerContextKey));
371 auto data = base::MakeUnique<BindingsSystemPerContextData>( 371 auto data = base::MakeUnique<BindingsSystemPerContextData>(
372 weak_factory_.GetWeakPtr()); 372 weak_factory_.GetWeakPtr());
373 per_context_data->SetUserData(kBindingsSystemPerContextKey, data.release()); 373 per_context_data->SetUserData(kBindingsSystemPerContextKey, std::move(data));
374 374
375 if (get_internal_api_.IsEmpty()) { 375 if (get_internal_api_.IsEmpty()) {
376 get_internal_api_.Set( 376 get_internal_api_.Set(
377 isolate, v8::FunctionTemplate::New( 377 isolate, v8::FunctionTemplate::New(
378 isolate, &NativeExtensionBindingsSystem::GetInternalAPI, 378 isolate, &NativeExtensionBindingsSystem::GetInternalAPI,
379 v8::Local<v8::Value>(), v8::Local<v8::Signature>(), 0, 379 v8::Local<v8::Value>(), v8::Local<v8::Signature>(), 0,
380 v8::ConstructorBehavior::kThrow)); 380 v8::ConstructorBehavior::kThrow));
381 } 381 }
382 382
383 // Note: it's a shame we can't delay this (until, say, we knew an API would 383 // Note: it's a shame we can't delay this (until, say, we knew an API would
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 v8::Local<v8::Value>* binding_util_out) { 671 v8::Local<v8::Value>* binding_util_out) {
672 gin::Handle<APIBindingJSUtil> handle = gin::CreateHandle( 672 gin::Handle<APIBindingJSUtil> handle = gin::CreateHandle(
673 context->GetIsolate(), 673 context->GetIsolate(),
674 new APIBindingJSUtil( 674 new APIBindingJSUtil(
675 api_system_.type_reference_map(), api_system_.request_handler(), 675 api_system_.type_reference_map(), api_system_.request_handler(),
676 api_system_.event_handler(), base::Bind(&CallJsFunction))); 676 api_system_.event_handler(), base::Bind(&CallJsFunction)));
677 *binding_util_out = handle.ToV8(); 677 *binding_util_out = handle.ToV8();
678 } 678 }
679 679
680 } // namespace extensions 680 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/renderer/api_event_handler.cc ('k') | extensions/shell/browser/shell_extension_web_contents_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698