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

Side by Side Diff: components/html_viewer/html_document.cc

Issue 1278673002: Add stats collection for telemetry startup.warm.blank_page test. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup Created 5 years, 4 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 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 "components/html_viewer/html_document.h" 5 #include "components/html_viewer/html_document.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/single_thread_task_runner.h" 11 #include "base/single_thread_task_runner.h"
12 #include "base/stl_util.h" 12 #include "base/stl_util.h"
13 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
14 #include "base/thread_task_runner_handle.h" 14 #include "base/thread_task_runner_handle.h"
15 #include "components/devtools_service/public/cpp/switches.h" 15 #include "components/devtools_service/public/cpp/switches.h"
16 #include "components/html_viewer/blink_input_events_type_converters.h" 16 #include "components/html_viewer/blink_input_events_type_converters.h"
17 #include "components/html_viewer/blink_url_request_type_converters.h" 17 #include "components/html_viewer/blink_url_request_type_converters.h"
18 #include "components/html_viewer/devtools_agent_impl.h" 18 #include "components/html_viewer/devtools_agent_impl.h"
19 #include "components/html_viewer/geolocation_client_impl.h" 19 #include "components/html_viewer/geolocation_client_impl.h"
20 #include "components/html_viewer/global_state.h" 20 #include "components/html_viewer/global_state.h"
21 #include "components/html_viewer/media_factory.h" 21 #include "components/html_viewer/media_factory.h"
22 #include "components/html_viewer/stats_collection_controller.h"
22 #include "components/html_viewer/web_layer_tree_view_impl.h" 23 #include "components/html_viewer/web_layer_tree_view_impl.h"
23 #include "components/html_viewer/web_storage_namespace_impl.h" 24 #include "components/html_viewer/web_storage_namespace_impl.h"
24 #include "components/html_viewer/web_url_loader_impl.h" 25 #include "components/html_viewer/web_url_loader_impl.h"
25 #include "components/view_manager/public/cpp/view.h" 26 #include "components/view_manager/public/cpp/view.h"
26 #include "components/view_manager/public/cpp/view_manager.h" 27 #include "components/view_manager/public/cpp/view_manager.h"
27 #include "components/view_manager/public/cpp/view_property.h" 28 #include "components/view_manager/public/cpp/view_property.h"
28 #include "components/view_manager/public/interfaces/surfaces.mojom.h" 29 #include "components/view_manager/public/interfaces/surfaces.mojom.h"
29 #include "mojo/application/public/cpp/application_impl.h" 30 #include "mojo/application/public/cpp/application_impl.h"
30 #include "mojo/application/public/cpp/connect.h" 31 #include "mojo/application/public/cpp/connect.h"
31 #include "mojo/application/public/interfaces/shell.mojom.h" 32 #include "mojo/application/public/interfaces/shell.mojom.h"
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 241
241 // TODO(yzshen): http://crbug.com/498986 Creating DevToolsAgentImpl instances 242 // TODO(yzshen): http://crbug.com/498986 Creating DevToolsAgentImpl instances
242 // causes html_viewer_apptests flakiness currently. Before we fix that we 243 // causes html_viewer_apptests flakiness currently. Before we fix that we
243 // cannot enable remote debugging (which is required by Telemetry tests) on 244 // cannot enable remote debugging (which is required by Telemetry tests) on
244 // the bots. 245 // the bots.
245 if (EnableRemoteDebugging()) { 246 if (EnableRemoteDebugging()) {
246 devtools_agent_.reset( 247 devtools_agent_.reset(
247 new DevToolsAgentImpl(main_frame, html_document_app_->shell())); 248 new DevToolsAgentImpl(main_frame, html_document_app_->shell()));
248 } 249 }
249 250
251 startup_performance_data_collector_ =
252 StatsCollectionController::Install(main_frame, html_document_app_);
253
250 GURL url(response->url); 254 GURL url(response->url);
251 255
252 WebURLRequestExtraData* extra_data = new WebURLRequestExtraData; 256 WebURLRequestExtraData* extra_data = new WebURLRequestExtraData;
253 extra_data->synthetic_response = response.Pass(); 257 extra_data->synthetic_response = response.Pass();
254 258
255 blink::WebURLRequest web_request; 259 blink::WebURLRequest web_request;
256 web_request.initialize(); 260 web_request.initialize();
257 web_request.setURL(url); 261 web_request.setURL(url);
258 web_request.setExtraData(extra_data); 262 web_request.setExtraData(extra_data);
259 263
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 395
392 void HTMLDocument::didAddMessageToConsole( 396 void HTMLDocument::didAddMessageToConsole(
393 const blink::WebConsoleMessage& message, 397 const blink::WebConsoleMessage& message,
394 const blink::WebString& source_name, 398 const blink::WebString& source_name,
395 unsigned source_line, 399 unsigned source_line,
396 const blink::WebString& stack_trace) { 400 const blink::WebString& stack_trace) {
397 VLOG(1) << "[" << source_name.utf8() << "(" << source_line << ")] " 401 VLOG(1) << "[" << source_name.utf8() << "(" << source_line << ")] "
398 << message.text.utf8(); 402 << message.text.utf8();
399 } 403 }
400 404
405 void HTMLDocument::didHandleOnloadEvents(blink::WebLocalFrame* frame) {
406 if (startup_performance_data_collector_.get()) {
yzshen1 2015/08/17 05:46:38 nit: ".get()" is not necessary for null-check. (I
msw 2015/08/17 21:25:50 Done; thanks for the extra info.
407 startup_performance_data_collector_->SetFirstWebContentsMainFrameLoadTime(
yzshen1 2015/08/17 05:46:38 Do you think we should comment on why we call this
msw 2015/08/17 21:25:50 The mojom explains that only the first time is rec
408 base::Time::Now().ToInternalValue());
409 }
410 }
411
401 void HTMLDocument::didFinishLoad(blink::WebLocalFrame* frame) { 412 void HTMLDocument::didFinishLoad(blink::WebLocalFrame* frame) {
402 // TODO(msw): Notify AxProvider clients of updates on child frame loads. 413 // TODO(msw): Notify AxProvider clients of updates on child frame loads.
403 did_finish_load_ = true; 414 did_finish_load_ = true;
404 // Bind any pending AxProviderImpl interface requests. 415 // Bind any pending AxProviderImpl interface requests.
405 for (auto it : ax_provider_requests_) 416 for (auto it : ax_provider_requests_)
406 ax_providers_.insert(new AxProviderImpl(web_view_, it->Pass())); 417 ax_providers_.insert(new AxProviderImpl(web_view_, it->Pass()));
407 STLDeleteElements(&ax_provider_requests_); 418 STLDeleteElements(&ax_provider_requests_);
408 } 419 }
409 420
410 void HTMLDocument::didNavigateWithinPage( 421 void HTMLDocument::didNavigateWithinPage(
411 blink::WebLocalFrame* frame, 422 blink::WebLocalFrame* frame,
412 const blink::WebHistoryItem& history_item, 423 const blink::WebHistoryItem& history_item,
413 blink::WebHistoryCommitType commit_type) { 424 blink::WebHistoryCommitType commit_type) {
414 if (navigator_host_.get()) 425 if (navigator_host_.get())
415 navigator_host_->DidNavigateLocally(history_item.urlString().utf8()); 426 navigator_host_->DidNavigateLocally(history_item.urlString().utf8());
416 } 427 }
417 428
429 void HTMLDocument::didFirstVisuallyNonEmptyLayout(blink::WebLocalFrame* frame) {
430 if (startup_performance_data_collector_) {
431 startup_performance_data_collector_->SetFirstVisuallyNonEmptyLayoutTime(
432 base::Time::Now().ToInternalValue());
433 }
434 }
435
418 blink::WebEncryptedMediaClient* HTMLDocument::encryptedMediaClient() { 436 blink::WebEncryptedMediaClient* HTMLDocument::encryptedMediaClient() {
419 return global_state_->media_factory()->GetEncryptedMediaClient(); 437 return global_state_->media_factory()->GetEncryptedMediaClient();
420 } 438 }
421 439
422 void HTMLDocument::OnViewBoundsChanged(View* view, 440 void HTMLDocument::OnViewBoundsChanged(View* view,
423 const Rect& old_bounds, 441 const Rect& old_bounds,
424 const Rect& new_bounds) { 442 const Rect& new_bounds) {
425 DCHECK_EQ(view, root_); 443 DCHECK_EQ(view, root_);
426 UpdateWebviewSizeFromViewSize(); 444 UpdateWebviewSizeFromViewSize();
427 } 445 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 486
469 void HTMLDocument::UpdateFocus() { 487 void HTMLDocument::UpdateFocus() {
470 if (!web_view_) 488 if (!web_view_)
471 return; 489 return;
472 bool is_focused = root_ && root_->HasFocus(); 490 bool is_focused = root_ && root_->HasFocus();
473 web_view_->setFocus(is_focused); 491 web_view_->setFocus(is_focused);
474 web_view_->setIsActive(is_focused); 492 web_view_->setIsActive(is_focused);
475 } 493 }
476 494
477 } // namespace html_viewer 495 } // namespace html_viewer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698