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

Side by Side Diff: chromecast/renderer/cast_content_renderer_client.cc

Issue 2535313004: [Chromecast] Clarify lifetime of CastGinRunner. (Closed)
Patch Set: Address nits Created 4 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
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 "chromecast/renderer/cast_content_renderer_client.h" 5 #include "chromecast/renderer/cast_content_renderer_client.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <string> 8 #include <string>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 } 141 }
142 142
143 void CastContentRendererClient::RunScriptsAtDocumentStart( 143 void CastContentRendererClient::RunScriptsAtDocumentStart(
144 content::RenderFrame* render_frame) { 144 content::RenderFrame* render_frame) {
145 // This method enables Mojo bindings in JavaScript for Chromecast. 145 // This method enables Mojo bindings in JavaScript for Chromecast.
146 146
147 v8::HandleScope handle_scope(blink::mainThreadIsolate()); 147 v8::HandleScope handle_scope(blink::mainThreadIsolate());
148 v8::Local<v8::Context> context = 148 v8::Local<v8::Context> context =
149 render_frame->GetWebFrame()->mainWorldScriptContext(); 149 render_frame->GetWebFrame()->mainWorldScriptContext();
150 150
151 // CastGinRunner manages its own lifetime. 151 CastGinRunner* runner = CastGinRunner::Get(render_frame);
152 CastGinRunner* runner = new CastGinRunner(render_frame);
153 gin::Runner::Scope scoper(runner); 152 gin::Runner::Scope scoper(runner);
154 153
155 // Initialize AMD API for Mojo. 154 // Initialize AMD API for Mojo.
156 render_frame->EnsureMojoBuiltinsAreAvailable(context->GetIsolate(), context); 155 render_frame->EnsureMojoBuiltinsAreAvailable(context->GetIsolate(), context);
157 gin::ModuleRegistry::InstallGlobals(context->GetIsolate(), context->Global()); 156 gin::ModuleRegistry::InstallGlobals(context->GetIsolate(), context->Global());
158 157
159 // Inject JavaScript files in the correct dependency order. 158 // Inject JavaScript files in the correct dependency order.
160 static const int mojo_resource_ids[] = { 159 static const int mojo_resource_ids[] = {
161 IDR_MOJO_UNICODE_JS, 160 IDR_MOJO_UNICODE_JS,
162 IDR_MOJO_BUFFER_JS, 161 IDR_MOJO_BUFFER_JS,
(...skipping 11 matching lines...) Expand all
174 173
175 void ExecuteJavaScript(content::RenderFrame* render_frame, int resource_id) { 174 void ExecuteJavaScript(content::RenderFrame* render_frame, int resource_id) {
176 const std::string& js_string = ui::ResourceBundle::GetSharedInstance() 175 const std::string& js_string = ui::ResourceBundle::GetSharedInstance()
177 .GetRawDataResource(resource_id) 176 .GetRawDataResource(resource_id)
178 .as_string(); 177 .as_string();
179 render_frame->ExecuteJavaScript(base::UTF8ToUTF16(js_string)); 178 render_frame->ExecuteJavaScript(base::UTF8ToUTF16(js_string));
180 } 179 }
181 180
182 } // namespace shell 181 } // namespace shell
183 } // namespace chromecast 182 } // namespace chromecast
OLDNEW
« no previous file with comments | « no previous file | chromecast/renderer/cast_gin_runner.h » ('j') | chromecast/renderer/cast_gin_runner.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698