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

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

Issue 2766603002: Add breakdown histograms for injected script execution time (Closed)
Patch Set: suffix labels Created 3 years, 9 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 | « no previous file | tools/metrics/histograms/histograms.xml » ('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/script_injection.h" 5 #include "extensions/renderer/script_injection.h"
6 6
7 #include <map> 7 #include <map>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 world_id, &sources.front(), sources.size(), is_user_gesture, option, 316 world_id, &sources.front(), sources.size(), is_user_gesture, option,
317 callback.release()); 317 callback.release());
318 } 318 }
319 } 319 }
320 320
321 void ScriptInjection::OnJsInjectionCompleted( 321 void ScriptInjection::OnJsInjectionCompleted(
322 const std::vector<v8::Local<v8::Value>>& results, 322 const std::vector<v8::Local<v8::Value>>& results,
323 base::TimeDelta elapsed) { 323 base::TimeDelta elapsed) {
324 DCHECK(!did_inject_js_); 324 DCHECK(!did_inject_js_);
325 325
326 if (injection_host_->id().type() == HostID::EXTENSIONS) 326 if (injection_host_->id().type() == HostID::EXTENSIONS) {
327 UMA_HISTOGRAM_TIMES("Extensions.InjectedScriptExecutionTime", elapsed); 327 UMA_HISTOGRAM_TIMES("Extensions.InjectedScriptExecutionTime", elapsed);
328 switch (run_location_) {
329 case UserScript::DOCUMENT_START:
330 UMA_HISTOGRAM_TIMES(
331 "Extensions.InjectedScriptExecutionTime.DocumentStart", elapsed);
332 break;
333 case UserScript::DOCUMENT_END:
334 UMA_HISTOGRAM_TIMES(
335 "Extensions.InjectedScriptExecutionTime.DocumentEnd", elapsed);
336 break;
337 case UserScript::DOCUMENT_IDLE:
338 UMA_HISTOGRAM_TIMES(
339 "Extensions.InjectedScriptExecutionTime.DocumentIdle", elapsed);
340 break;
341 default:
342 break;
343 }
344 }
328 345
329 bool expects_results = injector_->ExpectsResults(); 346 bool expects_results = injector_->ExpectsResults();
330 if (expects_results) { 347 if (expects_results) {
331 if (!results.empty() && !results[0].IsEmpty()) { 348 if (!results.empty() && !results[0].IsEmpty()) {
332 // Right now, we only support returning single results (per frame). 349 // Right now, we only support returning single results (per frame).
333 std::unique_ptr<content::V8ValueConverter> v8_converter( 350 std::unique_ptr<content::V8ValueConverter> v8_converter(
334 content::V8ValueConverter::create()); 351 content::V8ValueConverter::create());
335 // It's safe to always use the main world context when converting 352 // It's safe to always use the main world context when converting
336 // here. V8ValueConverterImpl shouldn't actually care about the 353 // here. V8ValueConverterImpl shouldn't actually care about the
337 // context scope, and it switches to v8::Object's creation context 354 // context scope, and it switches to v8::Object's creation context
(...skipping 21 matching lines...) Expand all
359 void ScriptInjection::InjectCss(std::set<std::string>* injected_stylesheets, 376 void ScriptInjection::InjectCss(std::set<std::string>* injected_stylesheets,
360 size_t* num_injected_stylesheets) { 377 size_t* num_injected_stylesheets) {
361 std::vector<blink::WebString> css_sources = injector_->GetCssSources( 378 std::vector<blink::WebString> css_sources = injector_->GetCssSources(
362 run_location_, injected_stylesheets, num_injected_stylesheets); 379 run_location_, injected_stylesheets, num_injected_stylesheets);
363 blink::WebLocalFrame* web_frame = render_frame_->GetWebFrame(); 380 blink::WebLocalFrame* web_frame = render_frame_->GetWebFrame();
364 for (const blink::WebString& css : css_sources) 381 for (const blink::WebString& css : css_sources)
365 web_frame->document().insertStyleSheet(css); 382 web_frame->document().insertStyleSheet(css);
366 } 383 }
367 384
368 } // namespace extensions 385 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698