Change DtmfSenderHandler to handle events on the signaling thread.
[chromium-blink-merge.git] / extensions / renderer / scripts_run_info.cc
bloba4073d1a5ec78fce9f2ae808f6256745a8749861
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
3 // found in the LICENSE file.
5 #include "extensions/renderer/scripts_run_info.h"
7 #include "base/metrics/histogram.h"
8 #include "content/public/renderer/render_view.h"
9 #include "extensions/common/extension_messages.h"
10 #include "extensions/renderer/script_context.h"
11 #include "third_party/WebKit/public/web/WebFrame.h"
13 namespace extensions {
15 ScriptsRunInfo::ScriptsRunInfo() : num_css(0u), num_js(0u) {
18 ScriptsRunInfo::~ScriptsRunInfo() {
21 void ScriptsRunInfo::LogRun(blink::WebFrame* frame,
22 UserScript::RunLocation location) {
23 // Notify the browser if any extensions are now executing scripts.
24 if (!executing_scripts.empty()) {
25 content::RenderView* render_view =
26 content::RenderView::FromWebView(frame->view());
27 render_view->Send(new ExtensionHostMsg_ContentScriptsExecuting(
28 render_view->GetRoutingID(),
29 executing_scripts,
30 ScriptContext::GetDataSourceURLForFrame(frame)));
33 switch (location) {
34 case UserScript::DOCUMENT_START:
35 UMA_HISTOGRAM_COUNTS_100("Extensions.InjectStart_CssCount", num_css);
36 UMA_HISTOGRAM_COUNTS_100("Extensions.InjectStart_ScriptCount", num_js);
37 if (num_css || num_js)
38 UMA_HISTOGRAM_TIMES("Extensions.InjectStart_Time", timer.Elapsed());
39 break;
40 case UserScript::DOCUMENT_END:
41 UMA_HISTOGRAM_COUNTS_100("Extensions.InjectEnd_ScriptCount", num_js);
42 if (num_js)
43 UMA_HISTOGRAM_TIMES("Extensions.InjectEnd_Time", timer.Elapsed());
44 break;
45 case UserScript::DOCUMENT_IDLE:
46 UMA_HISTOGRAM_COUNTS_100("Extensions.InjectIdle_ScriptCount", num_js);
47 if (num_js)
48 UMA_HISTOGRAM_TIMES("Extensions.InjectIdle_Time", timer.Elapsed());
49 break;
50 case UserScript::RUN_DEFERRED:
51 case UserScript::BROWSER_DRIVEN:
52 // TODO(rdevlin.cronin): Add histograms.
53 break;
54 case UserScript::UNDEFINED:
55 case UserScript::RUN_LOCATION_LAST:
56 NOTREACHED();
60 } // namespace extensions