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

Side by Side Diff: chrome/renderer/extensions/user_script_slave.cc

Issue 112203003: Fix renderer crashes when frame gets detached while injectng user scripts. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated patch to latest WebFrame/Frame lifetime changes. Created 6 years, 10 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/renderer/extensions/user_script_slave.h" 5 #include "chrome/renderer/extensions/user_script_slave.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 iter != sources.end(); ++iter) { 343 iter != sources.end(); ++iter) {
344 extensions_executing_scripts[extension->id()].insert( 344 extensions_executing_scripts[extension->id()].insert(
345 GURL(iter->url).path()); 345 GURL(iter->url).path());
346 } 346 }
347 } 347 }
348 } 348 }
349 349
350 // Notify the browser if any extensions are now executing scripts. 350 // Notify the browser if any extensions are now executing scripts.
351 if (!extensions_executing_scripts.empty()) { 351 if (!extensions_executing_scripts.empty()) {
352 blink::WebFrame* top_frame = frame->top(); 352 blink::WebFrame* top_frame = frame->top();
353 content::RenderView* render_view = 353 if (top_frame) {
dcheng 2014/02/07 16:53:37 top() should really never return 0... if you can w
354 content::RenderView::FromWebView(top_frame->view()); 354 content::RenderView* render_view =
355 render_view->Send(new ExtensionHostMsg_ContentScriptsExecuting( 355 content::RenderView::FromWebView(top_frame->view());
356 render_view->GetRoutingID(), 356 if (render_view) {
357 extensions_executing_scripts, 357 render_view->Send(new ExtensionHostMsg_ContentScriptsExecuting(
358 render_view->GetPageId(), 358 render_view->GetRoutingID(),
359 GetDataSourceURLForFrame(top_frame))); 359 extensions_executing_scripts,
360 render_view->GetPageId(),
361 GetDataSourceURLForFrame(top_frame)));
362 }
363 }
360 } 364 }
361 365
362 // Log debug info. 366 // Log debug info.
363 if (location == UserScript::DOCUMENT_START) { 367 if (location == UserScript::DOCUMENT_START) {
364 UMA_HISTOGRAM_COUNTS_100("Extensions.InjectStart_CssCount", num_css); 368 UMA_HISTOGRAM_COUNTS_100("Extensions.InjectStart_CssCount", num_css);
365 UMA_HISTOGRAM_COUNTS_100("Extensions.InjectStart_ScriptCount", num_scripts); 369 UMA_HISTOGRAM_COUNTS_100("Extensions.InjectStart_ScriptCount", num_scripts);
366 if (num_css || num_scripts) 370 if (num_css || num_scripts)
367 UMA_HISTOGRAM_TIMES("Extensions.InjectStart_Time", timer.Elapsed()); 371 UMA_HISTOGRAM_TIMES("Extensions.InjectStart_Time", timer.Elapsed());
368 } else if (location == UserScript::DOCUMENT_END) { 372 } else if (location == UserScript::DOCUMENT_END) {
369 UMA_HISTOGRAM_COUNTS_100("Extensions.InjectEnd_ScriptCount", num_scripts); 373 UMA_HISTOGRAM_COUNTS_100("Extensions.InjectEnd_ScriptCount", num_scripts);
370 if (num_scripts) 374 if (num_scripts)
371 UMA_HISTOGRAM_TIMES("Extensions.InjectEnd_Time", timer.Elapsed()); 375 UMA_HISTOGRAM_TIMES("Extensions.InjectEnd_Time", timer.Elapsed());
372 } else if (location == UserScript::DOCUMENT_IDLE) { 376 } else if (location == UserScript::DOCUMENT_IDLE) {
373 UMA_HISTOGRAM_COUNTS_100("Extensions.InjectIdle_ScriptCount", num_scripts); 377 UMA_HISTOGRAM_COUNTS_100("Extensions.InjectIdle_ScriptCount", num_scripts);
374 if (num_scripts) 378 if (num_scripts)
375 UMA_HISTOGRAM_TIMES("Extensions.InjectIdle_Time", timer.Elapsed()); 379 UMA_HISTOGRAM_TIMES("Extensions.InjectIdle_Time", timer.Elapsed());
376 } else { 380 } else {
377 NOTREACHED(); 381 NOTREACHED();
378 } 382 }
379 } 383 }
380 384
381 } // namespace extensions 385 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | components/autofill/content/renderer/page_click_tracker.cc » ('j') | content/renderer/render_view_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698