Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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("Extensions.InjectStart_ExecutionTime", elapsed); | |
|
Devlin
2017/03/21 20:40:47
I'd recommend using a histogram suffix here, and m
Kunihiko Sakamoto
2017/03/22 07:46:34
Ah I've forgotten about histogram_suffixes.
Done,
| |
| 331 break; | |
| 332 case UserScript::DOCUMENT_END: | |
| 333 UMA_HISTOGRAM_TIMES("Extensions.InjectEnd_ExecutionTime", elapsed); | |
| 334 break; | |
| 335 case UserScript::DOCUMENT_IDLE: | |
| 336 UMA_HISTOGRAM_TIMES("Extensions.InjectIdle_ExecutionTime", elapsed); | |
| 337 break; | |
| 338 default: | |
| 339 break; | |
| 340 } | |
| 341 } | |
| 328 | 342 |
| 329 bool expects_results = injector_->ExpectsResults(); | 343 bool expects_results = injector_->ExpectsResults(); |
| 330 if (expects_results) { | 344 if (expects_results) { |
| 331 if (!results.empty() && !results[0].IsEmpty()) { | 345 if (!results.empty() && !results[0].IsEmpty()) { |
| 332 // Right now, we only support returning single results (per frame). | 346 // Right now, we only support returning single results (per frame). |
| 333 std::unique_ptr<content::V8ValueConverter> v8_converter( | 347 std::unique_ptr<content::V8ValueConverter> v8_converter( |
| 334 content::V8ValueConverter::create()); | 348 content::V8ValueConverter::create()); |
| 335 // It's safe to always use the main world context when converting | 349 // It's safe to always use the main world context when converting |
| 336 // here. V8ValueConverterImpl shouldn't actually care about the | 350 // here. V8ValueConverterImpl shouldn't actually care about the |
| 337 // context scope, and it switches to v8::Object's creation context | 351 // context scope, and it switches to v8::Object's creation context |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 359 void ScriptInjection::InjectCss(std::set<std::string>* injected_stylesheets, | 373 void ScriptInjection::InjectCss(std::set<std::string>* injected_stylesheets, |
| 360 size_t* num_injected_stylesheets) { | 374 size_t* num_injected_stylesheets) { |
| 361 std::vector<blink::WebString> css_sources = injector_->GetCssSources( | 375 std::vector<blink::WebString> css_sources = injector_->GetCssSources( |
| 362 run_location_, injected_stylesheets, num_injected_stylesheets); | 376 run_location_, injected_stylesheets, num_injected_stylesheets); |
| 363 blink::WebLocalFrame* web_frame = render_frame_->GetWebFrame(); | 377 blink::WebLocalFrame* web_frame = render_frame_->GetWebFrame(); |
| 364 for (const blink::WebString& css : css_sources) | 378 for (const blink::WebString& css : css_sources) |
| 365 web_frame->document().insertStyleSheet(css); | 379 web_frame->document().insertStyleSheet(css); |
| 366 } | 380 } |
| 367 | 381 |
| 368 } // namespace extensions | 382 } // namespace extensions |
| OLD | NEW |