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

Side by Side Diff: content/renderer/mojo_bindings_controller.cc

Issue 2842833003: Update SupportsUserData uses with unique_ptr. (Closed)
Patch Set: rebase 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 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 "content/renderer/mojo_bindings_controller.h" 5 #include "content/renderer/mojo_bindings_controller.h"
6 6
7 #include "base/memory/ptr_util.h"
7 #include "content/common/view_messages.h" 8 #include "content/common/view_messages.h"
8 #include "content/public/renderer/render_frame.h" 9 #include "content/public/renderer/render_frame.h"
9 #include "content/public/renderer/render_view.h" 10 #include "content/public/renderer/render_view.h"
10 #include "content/renderer/mojo_context_state.h" 11 #include "content/renderer/mojo_context_state.h"
11 #include "gin/per_context_data.h" 12 #include "gin/per_context_data.h"
12 #include "third_party/WebKit/public/web/WebKit.h" 13 #include "third_party/WebKit/public/web/WebKit.h"
13 #include "third_party/WebKit/public/web/WebLocalFrame.h" 14 #include "third_party/WebKit/public/web/WebLocalFrame.h"
14 #include "third_party/WebKit/public/web/WebView.h" 15 #include "third_party/WebKit/public/web/WebView.h"
15 #include "v8/include/v8.h" 16 #include "v8/include/v8.h"
16 17
(...skipping 16 matching lines...) Expand all
33 bindings_type_(bindings_type) {} 34 bindings_type_(bindings_type) {}
34 35
35 MojoBindingsController::~MojoBindingsController() { 36 MojoBindingsController::~MojoBindingsController() {
36 } 37 }
37 38
38 void MojoBindingsController::CreateContextState() { 39 void MojoBindingsController::CreateContextState() {
39 v8::HandleScope handle_scope(blink::MainThreadIsolate()); 40 v8::HandleScope handle_scope(blink::MainThreadIsolate());
40 blink::WebLocalFrame* frame = render_frame()->GetWebFrame(); 41 blink::WebLocalFrame* frame = render_frame()->GetWebFrame();
41 v8::Local<v8::Context> context = frame->MainWorldScriptContext(); 42 v8::Local<v8::Context> context = frame->MainWorldScriptContext();
42 gin::PerContextData* context_data = gin::PerContextData::From(context); 43 gin::PerContextData* context_data = gin::PerContextData::From(context);
43 MojoContextStateData* data = new MojoContextStateData; 44 auto data = base::MakeUnique<MojoContextStateData>();
44 data->state.reset(new MojoContextState(frame, context, bindings_type_)); 45 data->state.reset(new MojoContextState(frame, context, bindings_type_));
45 context_data->SetUserData(kMojoContextStateKey, data); 46 context_data->SetUserData(kMojoContextStateKey, std::move(data));
46 } 47 }
47 48
48 void MojoBindingsController::DestroyContextState( 49 void MojoBindingsController::DestroyContextState(
49 v8::Local<v8::Context> context) { 50 v8::Local<v8::Context> context) {
50 gin::PerContextData* context_data = gin::PerContextData::From(context); 51 gin::PerContextData* context_data = gin::PerContextData::From(context);
51 if (!context_data) 52 if (!context_data)
52 return; 53 return;
53 context_data->RemoveUserData(kMojoContextStateKey); 54 context_data->RemoveUserData(kMojoContextStateKey);
54 } 55 }
55 56
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 97
97 v8::HandleScope handle_scope(blink::MainThreadIsolate()); 98 v8::HandleScope handle_scope(blink::MainThreadIsolate());
98 DestroyContextState(render_frame()->GetWebFrame()->MainWorldScriptContext()); 99 DestroyContextState(render_frame()->GetWebFrame()->MainWorldScriptContext());
99 } 100 }
100 101
101 void MojoBindingsController::OnDestruct() { 102 void MojoBindingsController::OnDestruct() {
102 delete this; 103 delete this;
103 } 104 }
104 105
105 } // namespace content 106 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/internal_document_state_data.cc ('k') | content/test/web_contents_observer_sanity_checker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698