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

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

Issue 2089333002: [Extensions] Add renderer-side logic to short circuit activity logging (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Guard adding dom activity loggers Created 4 years, 5 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/scripts_run_info.h ('k') | extensions/renderer/user_script_set.h » ('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/scripts_run_info.h" 5 #include "extensions/renderer/scripts_run_info.h"
6 6
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "content/public/renderer/render_frame.h" 8 #include "content/public/renderer/render_frame.h"
9 #include "content/public/renderer/render_thread.h" 9 #include "content/public/renderer/render_thread.h"
10 #include "extensions/common/extension_messages.h" 10 #include "extensions/common/extension_messages.h"
11 #include "extensions/renderer/script_context.h" 11 #include "extensions/renderer/script_context.h"
12 #include "third_party/WebKit/public/web/WebLocalFrame.h" 12 #include "third_party/WebKit/public/web/WebLocalFrame.h"
13 13
14 namespace extensions { 14 namespace extensions {
15 15
16 ScriptsRunInfo::ScriptsRunInfo(content::RenderFrame* render_frame, 16 ScriptsRunInfo::ScriptsRunInfo(content::RenderFrame* render_frame,
17 UserScript::RunLocation location) 17 UserScript::RunLocation location)
18 : num_css(0u), 18 : num_css(0u),
19 num_js(0u), 19 num_js(0u),
20 num_blocking_js(0u), 20 num_blocking_js(0u),
21 routing_id_(render_frame->GetRoutingID()), 21 routing_id_(render_frame->GetRoutingID()),
22 run_location_(location), 22 run_location_(location),
23 frame_url_(ScriptContext::GetDataSourceURLForFrame( 23 frame_url_(ScriptContext::GetDataSourceURLForFrame(
24 render_frame->GetWebFrame())) { 24 render_frame->GetWebFrame())) {
25 } 25 }
26 26
27 ScriptsRunInfo::~ScriptsRunInfo() { 27 ScriptsRunInfo::~ScriptsRunInfo() {
28 } 28 }
29 29
30 void ScriptsRunInfo::LogRun() { 30 void ScriptsRunInfo::LogRun(bool send_script_activity) {
31 // Notify the browser if any extensions are now executing scripts. 31 // Notify the browser if any extensions are now executing scripts.
32 if (!executing_scripts.empty()) { 32 if (!executing_scripts.empty() && send_script_activity) {
33 content::RenderThread::Get()->Send( 33 content::RenderThread::Get()->Send(
34 new ExtensionHostMsg_ContentScriptsExecuting( 34 new ExtensionHostMsg_ContentScriptsExecuting(
35 routing_id_, executing_scripts, frame_url_)); 35 routing_id_, executing_scripts, frame_url_));
36 } 36 }
37 37
38 switch (run_location_) { 38 switch (run_location_) {
39 case UserScript::DOCUMENT_START: 39 case UserScript::DOCUMENT_START:
40 UMA_HISTOGRAM_COUNTS_100("Extensions.InjectStart_CssCount", num_css); 40 UMA_HISTOGRAM_COUNTS_100("Extensions.InjectStart_CssCount", num_css);
41 UMA_HISTOGRAM_COUNTS_100("Extensions.InjectStart_ScriptCount", num_js); 41 UMA_HISTOGRAM_COUNTS_100("Extensions.InjectStart_ScriptCount", num_js);
42 if (num_blocking_js) { 42 if (num_blocking_js) {
(...skipping 25 matching lines...) Expand all
68 case UserScript::BROWSER_DRIVEN: 68 case UserScript::BROWSER_DRIVEN:
69 // TODO(rdevlin.cronin): Add histograms. 69 // TODO(rdevlin.cronin): Add histograms.
70 break; 70 break;
71 case UserScript::UNDEFINED: 71 case UserScript::UNDEFINED:
72 case UserScript::RUN_LOCATION_LAST: 72 case UserScript::RUN_LOCATION_LAST:
73 NOTREACHED(); 73 NOTREACHED();
74 } 74 }
75 } 75 }
76 76
77 } // namespace extensions 77 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/renderer/scripts_run_info.h ('k') | extensions/renderer/user_script_set.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698