| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chrome/browser/page_load_metrics/observers/core_page_load_metrics_obse
rver.h" | 5 #include "chrome/browser/page_load_metrics/observers/core_page_load_metrics_obse
rver.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 if (headers) { | 276 if (headers) { |
| 277 was_no_store_main_resource_ = | 277 was_no_store_main_resource_ = |
| 278 headers->HasHeaderValue("cache-control", "no-store"); | 278 headers->HasHeaderValue("cache-control", "no-store"); |
| 279 } | 279 } |
| 280 UMA_HISTOGRAM_COUNTS_100("PageLoad.Navigation.RedirectChainLength", | 280 UMA_HISTOGRAM_COUNTS_100("PageLoad.Navigation.RedirectChainLength", |
| 281 redirect_chain_size_); | 281 redirect_chain_size_); |
| 282 return CONTINUE_OBSERVING; | 282 return CONTINUE_OBSERVING; |
| 283 } | 283 } |
| 284 | 284 |
| 285 void CorePageLoadMetricsObserver::OnDomContentLoadedEventStart( | 285 void CorePageLoadMetricsObserver::OnDomContentLoadedEventStart( |
| 286 const page_load_metrics::PageLoadTiming& timing, | 286 const page_load_metrics::mojom::PageLoadTiming& timing, |
| 287 const page_load_metrics::PageLoadExtraInfo& info) { | 287 const page_load_metrics::PageLoadExtraInfo& info) { |
| 288 if (WasStartedInForegroundOptionalEventInForeground( | 288 if (WasStartedInForegroundOptionalEventInForeground( |
| 289 timing.document_timing.dom_content_loaded_event_start, info)) { | 289 timing.document_timing->dom_content_loaded_event_start, info)) { |
| 290 PAGE_LOAD_HISTOGRAM( | 290 PAGE_LOAD_HISTOGRAM( |
| 291 internal::kHistogramDomContentLoaded, | 291 internal::kHistogramDomContentLoaded, |
| 292 timing.document_timing.dom_content_loaded_event_start.value()); | 292 timing.document_timing->dom_content_loaded_event_start.value()); |
| 293 } else { | 293 } else { |
| 294 PAGE_LOAD_HISTOGRAM( | 294 PAGE_LOAD_HISTOGRAM( |
| 295 internal::kBackgroundHistogramDomContentLoaded, | 295 internal::kBackgroundHistogramDomContentLoaded, |
| 296 timing.document_timing.dom_content_loaded_event_start.value()); | 296 timing.document_timing->dom_content_loaded_event_start.value()); |
| 297 } | 297 } |
| 298 } | 298 } |
| 299 | 299 |
| 300 void CorePageLoadMetricsObserver::OnLoadEventStart( | 300 void CorePageLoadMetricsObserver::OnLoadEventStart( |
| 301 const page_load_metrics::PageLoadTiming& timing, | 301 const page_load_metrics::mojom::PageLoadTiming& timing, |
| 302 const page_load_metrics::PageLoadExtraInfo& info) { | 302 const page_load_metrics::PageLoadExtraInfo& info) { |
| 303 if (WasStartedInForegroundOptionalEventInForeground( | 303 if (WasStartedInForegroundOptionalEventInForeground( |
| 304 timing.document_timing.load_event_start, info)) { | 304 timing.document_timing->load_event_start, info)) { |
| 305 PAGE_LOAD_HISTOGRAM(internal::kHistogramLoad, | 305 PAGE_LOAD_HISTOGRAM(internal::kHistogramLoad, |
| 306 timing.document_timing.load_event_start.value()); | 306 timing.document_timing->load_event_start.value()); |
| 307 } else { | 307 } else { |
| 308 PAGE_LOAD_HISTOGRAM(internal::kBackgroundHistogramLoad, | 308 PAGE_LOAD_HISTOGRAM(internal::kBackgroundHistogramLoad, |
| 309 timing.document_timing.load_event_start.value()); | 309 timing.document_timing->load_event_start.value()); |
| 310 } | 310 } |
| 311 } | 311 } |
| 312 | 312 |
| 313 void CorePageLoadMetricsObserver::OnFirstLayout( | 313 void CorePageLoadMetricsObserver::OnFirstLayout( |
| 314 const page_load_metrics::PageLoadTiming& timing, | 314 const page_load_metrics::mojom::PageLoadTiming& timing, |
| 315 const page_load_metrics::PageLoadExtraInfo& info) { | 315 const page_load_metrics::PageLoadExtraInfo& info) { |
| 316 if (WasStartedInForegroundOptionalEventInForeground( | 316 if (WasStartedInForegroundOptionalEventInForeground( |
| 317 timing.document_timing.first_layout, info)) { | 317 timing.document_timing->first_layout, info)) { |
| 318 PAGE_LOAD_HISTOGRAM(internal::kHistogramFirstLayout, | 318 PAGE_LOAD_HISTOGRAM(internal::kHistogramFirstLayout, |
| 319 timing.document_timing.first_layout.value()); | 319 timing.document_timing->first_layout.value()); |
| 320 } else { | 320 } else { |
| 321 PAGE_LOAD_HISTOGRAM(internal::kBackgroundHistogramFirstLayout, | 321 PAGE_LOAD_HISTOGRAM(internal::kBackgroundHistogramFirstLayout, |
| 322 timing.document_timing.first_layout.value()); | 322 timing.document_timing->first_layout.value()); |
| 323 } | 323 } |
| 324 } | 324 } |
| 325 | 325 |
| 326 void CorePageLoadMetricsObserver::OnFirstPaintInPage( | 326 void CorePageLoadMetricsObserver::OnFirstPaintInPage( |
| 327 const page_load_metrics::PageLoadTiming& timing, | 327 const page_load_metrics::mojom::PageLoadTiming& timing, |
| 328 const page_load_metrics::PageLoadExtraInfo& info) { | 328 const page_load_metrics::PageLoadExtraInfo& info) { |
| 329 first_paint_ = | 329 first_paint_ = |
| 330 info.navigation_start + timing.paint_timing.first_paint.value(); | 330 info.navigation_start + timing.paint_timing->first_paint.value(); |
| 331 if (WasStartedInForegroundOptionalEventInForeground( | 331 if (WasStartedInForegroundOptionalEventInForeground( |
| 332 timing.paint_timing.first_paint, info)) { | 332 timing.paint_timing->first_paint, info)) { |
| 333 PAGE_LOAD_HISTOGRAM(internal::kHistogramFirstPaint, | 333 PAGE_LOAD_HISTOGRAM(internal::kHistogramFirstPaint, |
| 334 timing.paint_timing.first_paint.value()); | 334 timing.paint_timing->first_paint.value()); |
| 335 } else { | 335 } else { |
| 336 PAGE_LOAD_HISTOGRAM(internal::kBackgroundHistogramFirstPaint, | 336 PAGE_LOAD_HISTOGRAM(internal::kBackgroundHistogramFirstPaint, |
| 337 timing.paint_timing.first_paint.value()); | 337 timing.paint_timing->first_paint.value()); |
| 338 } | 338 } |
| 339 | 339 |
| 340 // Record the time to first paint for pages which were: | 340 // Record the time to first paint for pages which were: |
| 341 // - Opened in the background. | 341 // - Opened in the background. |
| 342 // - Moved to the foreground prior to the first paint. | 342 // - Moved to the foreground prior to the first paint. |
| 343 // - Not moved back to the background prior to the first paint. | 343 // - Not moved back to the background prior to the first paint. |
| 344 if (!info.started_in_foreground && info.first_foreground_time && | 344 if (!info.started_in_foreground && info.first_foreground_time && |
| 345 info.first_foreground_time.value() <= | 345 info.first_foreground_time.value() <= |
| 346 timing.paint_timing.first_paint.value() && | 346 timing.paint_timing->first_paint.value() && |
| 347 (!info.first_background_time || timing.paint_timing.first_paint.value() <= | 347 (!info.first_background_time || |
| 348 info.first_background_time.value())) { | 348 timing.paint_timing->first_paint.value() <= |
| 349 info.first_background_time.value())) { |
| 349 PAGE_LOAD_HISTOGRAM(internal::kHistogramForegroundToFirstPaint, | 350 PAGE_LOAD_HISTOGRAM(internal::kHistogramForegroundToFirstPaint, |
| 350 timing.paint_timing.first_paint.value() - | 351 timing.paint_timing->first_paint.value() - |
| 351 info.first_foreground_time.value()); | 352 info.first_foreground_time.value()); |
| 352 } | 353 } |
| 353 } | 354 } |
| 354 | 355 |
| 355 void CorePageLoadMetricsObserver::OnFirstTextPaintInPage( | 356 void CorePageLoadMetricsObserver::OnFirstTextPaintInPage( |
| 356 const page_load_metrics::PageLoadTiming& timing, | 357 const page_load_metrics::mojom::PageLoadTiming& timing, |
| 357 const page_load_metrics::PageLoadExtraInfo& info) { | 358 const page_load_metrics::PageLoadExtraInfo& info) { |
| 358 if (WasStartedInForegroundOptionalEventInForeground( | 359 if (WasStartedInForegroundOptionalEventInForeground( |
| 359 timing.paint_timing.first_text_paint, info)) { | 360 timing.paint_timing->first_text_paint, info)) { |
| 360 PAGE_LOAD_HISTOGRAM(internal::kHistogramFirstTextPaint, | 361 PAGE_LOAD_HISTOGRAM(internal::kHistogramFirstTextPaint, |
| 361 timing.paint_timing.first_text_paint.value()); | 362 timing.paint_timing->first_text_paint.value()); |
| 362 } else { | 363 } else { |
| 363 PAGE_LOAD_HISTOGRAM(internal::kBackgroundHistogramFirstTextPaint, | 364 PAGE_LOAD_HISTOGRAM(internal::kBackgroundHistogramFirstTextPaint, |
| 364 timing.paint_timing.first_text_paint.value()); | 365 timing.paint_timing->first_text_paint.value()); |
| 365 } | 366 } |
| 366 } | 367 } |
| 367 | 368 |
| 368 void CorePageLoadMetricsObserver::OnFirstImagePaintInPage( | 369 void CorePageLoadMetricsObserver::OnFirstImagePaintInPage( |
| 369 const page_load_metrics::PageLoadTiming& timing, | 370 const page_load_metrics::mojom::PageLoadTiming& timing, |
| 370 const page_load_metrics::PageLoadExtraInfo& info) { | 371 const page_load_metrics::PageLoadExtraInfo& info) { |
| 371 if (WasStartedInForegroundOptionalEventInForeground( | 372 if (WasStartedInForegroundOptionalEventInForeground( |
| 372 timing.paint_timing.first_image_paint, info)) { | 373 timing.paint_timing->first_image_paint, info)) { |
| 373 PAGE_LOAD_HISTOGRAM(internal::kHistogramFirstImagePaint, | 374 PAGE_LOAD_HISTOGRAM(internal::kHistogramFirstImagePaint, |
| 374 timing.paint_timing.first_image_paint.value()); | 375 timing.paint_timing->first_image_paint.value()); |
| 375 } else { | 376 } else { |
| 376 PAGE_LOAD_HISTOGRAM(internal::kBackgroundHistogramFirstImagePaint, | 377 PAGE_LOAD_HISTOGRAM(internal::kBackgroundHistogramFirstImagePaint, |
| 377 timing.paint_timing.first_image_paint.value()); | 378 timing.paint_timing->first_image_paint.value()); |
| 378 } | 379 } |
| 379 } | 380 } |
| 380 | 381 |
| 381 void CorePageLoadMetricsObserver::OnFirstContentfulPaintInPage( | 382 void CorePageLoadMetricsObserver::OnFirstContentfulPaintInPage( |
| 382 const page_load_metrics::PageLoadTiming& timing, | 383 const page_load_metrics::mojom::PageLoadTiming& timing, |
| 383 const page_load_metrics::PageLoadExtraInfo& info) { | 384 const page_load_metrics::PageLoadExtraInfo& info) { |
| 384 if (WasStartedInForegroundOptionalEventInForeground( | 385 if (WasStartedInForegroundOptionalEventInForeground( |
| 385 timing.paint_timing.first_contentful_paint, info)) { | 386 timing.paint_timing->first_contentful_paint, info)) { |
| 386 PAGE_LOAD_HISTOGRAM(internal::kHistogramFirstContentfulPaint, | 387 PAGE_LOAD_HISTOGRAM(internal::kHistogramFirstContentfulPaint, |
| 387 timing.paint_timing.first_contentful_paint.value()); | 388 timing.paint_timing->first_contentful_paint.value()); |
| 388 PAGE_LOAD_HISTOGRAM(internal::kHistogramParseStartToFirstContentfulPaint, | 389 PAGE_LOAD_HISTOGRAM(internal::kHistogramParseStartToFirstContentfulPaint, |
| 389 timing.paint_timing.first_contentful_paint.value() - | 390 timing.paint_timing->first_contentful_paint.value() - |
| 390 timing.parse_timing.parse_start.value()); | 391 timing.parse_timing->parse_start.value()); |
| 391 | 392 |
| 392 if (was_no_store_main_resource_) { | 393 if (was_no_store_main_resource_) { |
| 393 PAGE_LOAD_HISTOGRAM(internal::kHistogramFirstContentfulPaintNoStore, | 394 PAGE_LOAD_HISTOGRAM(internal::kHistogramFirstContentfulPaintNoStore, |
| 394 timing.paint_timing.first_contentful_paint.value()); | 395 timing.paint_timing->first_contentful_paint.value()); |
| 395 } | 396 } |
| 396 | 397 |
| 397 // TODO(bmcquade): consider adding a histogram that uses | 398 // TODO(bmcquade): consider adding a histogram that uses |
| 398 // UserInputInfo.user_input_event. | 399 // UserInputInfo.user_input_event. |
| 399 if (info.user_initiated_info.browser_initiated || | 400 if (info.user_initiated_info.browser_initiated || |
| 400 info.user_initiated_info.user_gesture) { | 401 info.user_initiated_info.user_gesture) { |
| 401 PAGE_LOAD_HISTOGRAM(internal::kHistogramFirstContentfulPaintUserInitiated, | 402 PAGE_LOAD_HISTOGRAM(internal::kHistogramFirstContentfulPaintUserInitiated, |
| 402 timing.paint_timing.first_contentful_paint.value()); | 403 timing.paint_timing->first_contentful_paint.value()); |
| 403 } | 404 } |
| 404 | 405 |
| 405 if (timing.style_sheet_timing | 406 if (timing.style_sheet_timing |
| 406 .author_style_sheet_parse_duration_before_fcp) { | 407 ->author_style_sheet_parse_duration_before_fcp) { |
| 407 PAGE_LOAD_HISTOGRAM( | 408 PAGE_LOAD_HISTOGRAM( |
| 408 "PageLoad.CSSTiming.Parse.BeforeFirstContentfulPaint", | 409 "PageLoad.CSSTiming.Parse.BeforeFirstContentfulPaint", |
| 409 timing.style_sheet_timing.author_style_sheet_parse_duration_before_fcp | 410 timing.style_sheet_timing |
| 410 .value()); | 411 ->author_style_sheet_parse_duration_before_fcp.value()); |
| 411 } | 412 } |
| 412 if (timing.style_sheet_timing.update_style_duration_before_fcp) { | 413 if (timing.style_sheet_timing->update_style_duration_before_fcp) { |
| 413 PAGE_LOAD_HISTOGRAM( | 414 PAGE_LOAD_HISTOGRAM( |
| 414 "PageLoad.CSSTiming.Update.BeforeFirstContentfulPaint", | 415 "PageLoad.CSSTiming.Update.BeforeFirstContentfulPaint", |
| 415 timing.style_sheet_timing.update_style_duration_before_fcp.value()); | 416 timing.style_sheet_timing->update_style_duration_before_fcp.value()); |
| 416 } | 417 } |
| 417 if (timing.style_sheet_timing | 418 if (timing.style_sheet_timing |
| 418 .author_style_sheet_parse_duration_before_fcp || | 419 ->author_style_sheet_parse_duration_before_fcp || |
| 419 timing.style_sheet_timing.update_style_duration_before_fcp) { | 420 timing.style_sheet_timing->update_style_duration_before_fcp) { |
| 420 PAGE_LOAD_HISTOGRAM( | 421 PAGE_LOAD_HISTOGRAM( |
| 421 "PageLoad.CSSTiming.ParseAndUpdate.BeforeFirstContentfulPaint", | 422 "PageLoad.CSSTiming.ParseAndUpdate.BeforeFirstContentfulPaint", |
| 422 timing.style_sheet_timing.author_style_sheet_parse_duration_before_fcp | 423 timing.style_sheet_timing |
| 423 .value_or(base::TimeDelta()) + | 424 ->author_style_sheet_parse_duration_before_fcp.value_or( |
| 424 timing.style_sheet_timing.update_style_duration_before_fcp | 425 base::TimeDelta()) + |
| 426 timing.style_sheet_timing->update_style_duration_before_fcp |
| 425 .value_or(base::TimeDelta())); | 427 .value_or(base::TimeDelta())); |
| 426 } | 428 } |
| 427 | 429 |
| 428 switch (GetPageLoadType(transition_)) { | 430 switch (GetPageLoadType(transition_)) { |
| 429 case LOAD_TYPE_RELOAD: | 431 case LOAD_TYPE_RELOAD: |
| 430 PAGE_LOAD_HISTOGRAM( | 432 PAGE_LOAD_HISTOGRAM( |
| 431 internal::kHistogramLoadTypeFirstContentfulPaintReload, | 433 internal::kHistogramLoadTypeFirstContentfulPaintReload, |
| 432 timing.paint_timing.first_contentful_paint.value()); | 434 timing.paint_timing->first_contentful_paint.value()); |
| 433 // TODO(bmcquade): consider adding a histogram that uses | 435 // TODO(bmcquade): consider adding a histogram that uses |
| 434 // UserInputInfo.user_input_event. | 436 // UserInputInfo.user_input_event. |
| 435 if (info.user_initiated_info.browser_initiated || | 437 if (info.user_initiated_info.browser_initiated || |
| 436 info.user_initiated_info.user_gesture) { | 438 info.user_initiated_info.user_gesture) { |
| 437 PAGE_LOAD_HISTOGRAM( | 439 PAGE_LOAD_HISTOGRAM( |
| 438 internal::kHistogramLoadTypeFirstContentfulPaintReloadByGesture, | 440 internal::kHistogramLoadTypeFirstContentfulPaintReloadByGesture, |
| 439 timing.paint_timing.first_contentful_paint.value()); | 441 timing.paint_timing->first_contentful_paint.value()); |
| 440 } | 442 } |
| 441 break; | 443 break; |
| 442 case LOAD_TYPE_FORWARD_BACK: | 444 case LOAD_TYPE_FORWARD_BACK: |
| 443 PAGE_LOAD_HISTOGRAM( | 445 PAGE_LOAD_HISTOGRAM( |
| 444 internal::kHistogramLoadTypeFirstContentfulPaintForwardBack, | 446 internal::kHistogramLoadTypeFirstContentfulPaintForwardBack, |
| 445 timing.paint_timing.first_contentful_paint.value()); | 447 timing.paint_timing->first_contentful_paint.value()); |
| 446 if (was_no_store_main_resource_) { | 448 if (was_no_store_main_resource_) { |
| 447 PAGE_LOAD_HISTOGRAM( | 449 PAGE_LOAD_HISTOGRAM( |
| 448 internal:: | 450 internal:: |
| 449 kHistogramLoadTypeFirstContentfulPaintForwardBackNoStore, | 451 kHistogramLoadTypeFirstContentfulPaintForwardBackNoStore, |
| 450 timing.paint_timing.first_contentful_paint.value()); | 452 timing.paint_timing->first_contentful_paint.value()); |
| 451 } | 453 } |
| 452 break; | 454 break; |
| 453 case LOAD_TYPE_NEW_NAVIGATION: | 455 case LOAD_TYPE_NEW_NAVIGATION: |
| 454 PAGE_LOAD_HISTOGRAM( | 456 PAGE_LOAD_HISTOGRAM( |
| 455 internal::kHistogramLoadTypeFirstContentfulPaintNewNavigation, | 457 internal::kHistogramLoadTypeFirstContentfulPaintNewNavigation, |
| 456 timing.paint_timing.first_contentful_paint.value()); | 458 timing.paint_timing->first_contentful_paint.value()); |
| 457 break; | 459 break; |
| 458 case LOAD_TYPE_NONE: | 460 case LOAD_TYPE_NONE: |
| 459 NOTREACHED(); | 461 NOTREACHED(); |
| 460 break; | 462 break; |
| 461 } | 463 } |
| 462 } else { | 464 } else { |
| 463 PAGE_LOAD_HISTOGRAM(internal::kBackgroundHistogramFirstContentfulPaint, | 465 PAGE_LOAD_HISTOGRAM(internal::kBackgroundHistogramFirstContentfulPaint, |
| 464 timing.paint_timing.first_contentful_paint.value()); | 466 timing.paint_timing->first_contentful_paint.value()); |
| 465 PAGE_LOAD_HISTOGRAM( | 467 PAGE_LOAD_HISTOGRAM( |
| 466 internal::kBackgroundHistogramParseStartToFirstContentfulPaint, | 468 internal::kBackgroundHistogramParseStartToFirstContentfulPaint, |
| 467 timing.paint_timing.first_contentful_paint.value() - | 469 timing.paint_timing->first_contentful_paint.value() - |
| 468 timing.parse_timing.parse_start.value()); | 470 timing.parse_timing->parse_start.value()); |
| 469 } | 471 } |
| 470 } | 472 } |
| 471 | 473 |
| 472 void CorePageLoadMetricsObserver::OnFirstMeaningfulPaintInMainFrameDocument( | 474 void CorePageLoadMetricsObserver::OnFirstMeaningfulPaintInMainFrameDocument( |
| 473 const page_load_metrics::PageLoadTiming& timing, | 475 const page_load_metrics::mojom::PageLoadTiming& timing, |
| 474 const page_load_metrics::PageLoadExtraInfo& info) { | 476 const page_load_metrics::PageLoadExtraInfo& info) { |
| 475 base::TimeTicks paint = info.navigation_start + | 477 base::TimeTicks paint = info.navigation_start + |
| 476 timing.paint_timing.first_meaningful_paint.value(); | 478 timing.paint_timing->first_meaningful_paint.value(); |
| 477 if (first_user_interaction_after_first_paint_.is_null() || | 479 if (first_user_interaction_after_first_paint_.is_null() || |
| 478 paint < first_user_interaction_after_first_paint_) { | 480 paint < first_user_interaction_after_first_paint_) { |
| 479 if (WasStartedInForegroundOptionalEventInForeground( | 481 if (WasStartedInForegroundOptionalEventInForeground( |
| 480 timing.paint_timing.first_meaningful_paint, info)) { | 482 timing.paint_timing->first_meaningful_paint, info)) { |
| 481 PAGE_LOAD_HISTOGRAM(internal::kHistogramFirstMeaningfulPaint, | 483 PAGE_LOAD_HISTOGRAM(internal::kHistogramFirstMeaningfulPaint, |
| 482 timing.paint_timing.first_meaningful_paint.value()); | 484 timing.paint_timing->first_meaningful_paint.value()); |
| 483 PAGE_LOAD_HISTOGRAM(internal::kHistogramParseStartToFirstMeaningfulPaint, | 485 PAGE_LOAD_HISTOGRAM(internal::kHistogramParseStartToFirstMeaningfulPaint, |
| 484 timing.paint_timing.first_meaningful_paint.value() - | 486 timing.paint_timing->first_meaningful_paint.value() - |
| 485 timing.parse_timing.parse_start.value()); | 487 timing.parse_timing->parse_start.value()); |
| 486 PAGE_LOAD_HISTOGRAM( | 488 PAGE_LOAD_HISTOGRAM( |
| 487 internal::kHistogramFirstMeaningfulPaintToNetworkStable, | 489 internal::kHistogramFirstMeaningfulPaintToNetworkStable, |
| 488 base::TimeTicks::Now() - paint); | 490 base::TimeTicks::Now() - paint); |
| 489 RecordFirstMeaningfulPaintStatus( | 491 RecordFirstMeaningfulPaintStatus( |
| 490 internal::FIRST_MEANINGFUL_PAINT_RECORDED); | 492 internal::FIRST_MEANINGFUL_PAINT_RECORDED); |
| 491 } else { | 493 } else { |
| 492 RecordFirstMeaningfulPaintStatus( | 494 RecordFirstMeaningfulPaintStatus( |
| 493 internal::FIRST_MEANINGFUL_PAINT_BACKGROUNDED); | 495 internal::FIRST_MEANINGFUL_PAINT_BACKGROUNDED); |
| 494 } | 496 } |
| 495 } else { | 497 } else { |
| 496 RecordFirstMeaningfulPaintStatus( | 498 RecordFirstMeaningfulPaintStatus( |
| 497 internal::FIRST_MEANINGFUL_PAINT_USER_INTERACTION_BEFORE_FMP); | 499 internal::FIRST_MEANINGFUL_PAINT_USER_INTERACTION_BEFORE_FMP); |
| 498 } | 500 } |
| 499 } | 501 } |
| 500 | 502 |
| 501 void CorePageLoadMetricsObserver::OnParseStart( | 503 void CorePageLoadMetricsObserver::OnParseStart( |
| 502 const page_load_metrics::PageLoadTiming& timing, | 504 const page_load_metrics::mojom::PageLoadTiming& timing, |
| 503 const page_load_metrics::PageLoadExtraInfo& info) { | 505 const page_load_metrics::PageLoadExtraInfo& info) { |
| 504 if (WasStartedInForegroundOptionalEventInForeground( | 506 if (WasStartedInForegroundOptionalEventInForeground( |
| 505 timing.parse_timing.parse_start, info)) { | 507 timing.parse_timing->parse_start, info)) { |
| 506 PAGE_LOAD_HISTOGRAM(internal::kHistogramParseStart, | 508 PAGE_LOAD_HISTOGRAM(internal::kHistogramParseStart, |
| 507 timing.parse_timing.parse_start.value()); | 509 timing.parse_timing->parse_start.value()); |
| 508 | 510 |
| 509 switch (GetPageLoadType(transition_)) { | 511 switch (GetPageLoadType(transition_)) { |
| 510 case LOAD_TYPE_RELOAD: | 512 case LOAD_TYPE_RELOAD: |
| 511 PAGE_LOAD_HISTOGRAM(internal::kHistogramLoadTypeParseStartReload, | 513 PAGE_LOAD_HISTOGRAM(internal::kHistogramLoadTypeParseStartReload, |
| 512 timing.parse_timing.parse_start.value()); | 514 timing.parse_timing->parse_start.value()); |
| 513 break; | 515 break; |
| 514 case LOAD_TYPE_FORWARD_BACK: | 516 case LOAD_TYPE_FORWARD_BACK: |
| 515 PAGE_LOAD_HISTOGRAM(internal::kHistogramLoadTypeParseStartForwardBack, | 517 PAGE_LOAD_HISTOGRAM(internal::kHistogramLoadTypeParseStartForwardBack, |
| 516 timing.parse_timing.parse_start.value()); | 518 timing.parse_timing->parse_start.value()); |
| 517 if (was_no_store_main_resource_) { | 519 if (was_no_store_main_resource_) { |
| 518 PAGE_LOAD_HISTOGRAM( | 520 PAGE_LOAD_HISTOGRAM( |
| 519 internal::kHistogramLoadTypeParseStartForwardBackNoStore, | 521 internal::kHistogramLoadTypeParseStartForwardBackNoStore, |
| 520 timing.parse_timing.parse_start.value()); | 522 timing.parse_timing->parse_start.value()); |
| 521 } | 523 } |
| 522 break; | 524 break; |
| 523 case LOAD_TYPE_NEW_NAVIGATION: | 525 case LOAD_TYPE_NEW_NAVIGATION: |
| 524 PAGE_LOAD_HISTOGRAM(internal::kHistogramLoadTypeParseStartNewNavigation, | 526 PAGE_LOAD_HISTOGRAM(internal::kHistogramLoadTypeParseStartNewNavigation, |
| 525 timing.parse_timing.parse_start.value()); | 527 timing.parse_timing->parse_start.value()); |
| 526 break; | 528 break; |
| 527 case LOAD_TYPE_NONE: | 529 case LOAD_TYPE_NONE: |
| 528 NOTREACHED(); | 530 NOTREACHED(); |
| 529 break; | 531 break; |
| 530 } | 532 } |
| 531 } else { | 533 } else { |
| 532 PAGE_LOAD_HISTOGRAM(internal::kBackgroundHistogramParseStart, | 534 PAGE_LOAD_HISTOGRAM(internal::kBackgroundHistogramParseStart, |
| 533 timing.parse_timing.parse_start.value()); | 535 timing.parse_timing->parse_start.value()); |
| 534 } | 536 } |
| 535 } | 537 } |
| 536 | 538 |
| 537 void CorePageLoadMetricsObserver::OnParseStop( | 539 void CorePageLoadMetricsObserver::OnParseStop( |
| 538 const page_load_metrics::PageLoadTiming& timing, | 540 const page_load_metrics::mojom::PageLoadTiming& timing, |
| 539 const page_load_metrics::PageLoadExtraInfo& info) { | 541 const page_load_metrics::PageLoadExtraInfo& info) { |
| 540 base::TimeDelta parse_duration = timing.parse_timing.parse_stop.value() - | 542 base::TimeDelta parse_duration = timing.parse_timing->parse_stop.value() - |
| 541 timing.parse_timing.parse_start.value(); | 543 timing.parse_timing->parse_start.value(); |
| 542 if (WasStartedInForegroundOptionalEventInForeground( | 544 if (WasStartedInForegroundOptionalEventInForeground( |
| 543 timing.parse_timing.parse_stop, info)) { | 545 timing.parse_timing->parse_stop, info)) { |
| 544 PAGE_LOAD_HISTOGRAM(internal::kHistogramParseDuration, parse_duration); | 546 PAGE_LOAD_HISTOGRAM(internal::kHistogramParseDuration, parse_duration); |
| 545 PAGE_LOAD_HISTOGRAM( | 547 PAGE_LOAD_HISTOGRAM( |
| 546 internal::kHistogramParseBlockedOnScriptLoad, | 548 internal::kHistogramParseBlockedOnScriptLoad, |
| 547 timing.parse_timing.parse_blocked_on_script_load_duration.value()); | 549 timing.parse_timing->parse_blocked_on_script_load_duration.value()); |
| 548 PAGE_LOAD_HISTOGRAM( | 550 PAGE_LOAD_HISTOGRAM( |
| 549 internal::kHistogramParseBlockedOnScriptLoadDocumentWrite, | 551 internal::kHistogramParseBlockedOnScriptLoadDocumentWrite, |
| 550 timing.parse_timing | 552 timing.parse_timing |
| 551 .parse_blocked_on_script_load_from_document_write_duration.value()); | 553 ->parse_blocked_on_script_load_from_document_write_duration |
| 554 .value()); |
| 552 PAGE_LOAD_HISTOGRAM( | 555 PAGE_LOAD_HISTOGRAM( |
| 553 internal::kHistogramParseBlockedOnScriptExecution, | 556 internal::kHistogramParseBlockedOnScriptExecution, |
| 554 timing.parse_timing.parse_blocked_on_script_execution_duration.value()); | 557 timing.parse_timing->parse_blocked_on_script_execution_duration |
| 558 .value()); |
| 555 PAGE_LOAD_HISTOGRAM( | 559 PAGE_LOAD_HISTOGRAM( |
| 556 internal::kHistogramParseBlockedOnScriptExecutionDocumentWrite, | 560 internal::kHistogramParseBlockedOnScriptExecutionDocumentWrite, |
| 557 timing.parse_timing | 561 timing.parse_timing |
| 558 .parse_blocked_on_script_execution_from_document_write_duration | 562 ->parse_blocked_on_script_execution_from_document_write_duration |
| 559 .value()); | 563 .value()); |
| 560 | 564 |
| 561 int total_resources = num_cache_resources_ + num_network_resources_; | 565 int total_resources = num_cache_resources_ + num_network_resources_; |
| 562 if (total_resources) { | 566 if (total_resources) { |
| 563 int percent_cached = (100 * num_cache_resources_) / total_resources; | 567 int percent_cached = (100 * num_cache_resources_) / total_resources; |
| 564 UMA_HISTOGRAM_PERCENTAGE(internal::kHistogramCacheRequestPercentParseStop, | 568 UMA_HISTOGRAM_PERCENTAGE(internal::kHistogramCacheRequestPercentParseStop, |
| 565 percent_cached); | 569 percent_cached); |
| 566 UMA_HISTOGRAM_COUNTS(internal::kHistogramCacheTotalRequestsParseStop, | 570 UMA_HISTOGRAM_COUNTS(internal::kHistogramCacheTotalRequestsParseStop, |
| 567 num_cache_resources_); | 571 num_cache_resources_); |
| 568 UMA_HISTOGRAM_COUNTS(internal::kHistogramTotalRequestsParseStop, | 572 UMA_HISTOGRAM_COUNTS(internal::kHistogramTotalRequestsParseStop, |
| 569 num_cache_resources_ + num_network_resources_); | 573 num_cache_resources_ + num_network_resources_); |
| 570 | 574 |
| 571 // Separate out parse duration based on cache percent. | 575 // Separate out parse duration based on cache percent. |
| 572 if (percent_cached <= 50) { | 576 if (percent_cached <= 50) { |
| 573 PAGE_LOAD_HISTOGRAM( | 577 PAGE_LOAD_HISTOGRAM( |
| 574 "PageLoad.Experimental.ParseDuration.CachedPercent.0-50", | 578 "PageLoad.Experimental.ParseDuration.CachedPercent.0-50", |
| 575 parse_duration); | 579 parse_duration); |
| 576 } else { | 580 } else { |
| 577 PAGE_LOAD_HISTOGRAM( | 581 PAGE_LOAD_HISTOGRAM( |
| 578 "PageLoad.Experimental.ParseDuration.CachedPercent.51-100", | 582 "PageLoad.Experimental.ParseDuration.CachedPercent.51-100", |
| 579 parse_duration); | 583 parse_duration); |
| 580 } | 584 } |
| 581 } | 585 } |
| 582 } else { | 586 } else { |
| 583 PAGE_LOAD_HISTOGRAM(internal::kBackgroundHistogramParseDuration, | 587 PAGE_LOAD_HISTOGRAM(internal::kBackgroundHistogramParseDuration, |
| 584 parse_duration); | 588 parse_duration); |
| 585 PAGE_LOAD_HISTOGRAM( | 589 PAGE_LOAD_HISTOGRAM( |
| 586 internal::kBackgroundHistogramParseBlockedOnScriptLoad, | 590 internal::kBackgroundHistogramParseBlockedOnScriptLoad, |
| 587 timing.parse_timing.parse_blocked_on_script_load_duration.value()); | 591 timing.parse_timing->parse_blocked_on_script_load_duration.value()); |
| 588 PAGE_LOAD_HISTOGRAM( | 592 PAGE_LOAD_HISTOGRAM( |
| 589 internal::kBackgroundHistogramParseBlockedOnScriptLoadDocumentWrite, | 593 internal::kBackgroundHistogramParseBlockedOnScriptLoadDocumentWrite, |
| 590 timing.parse_timing | 594 timing.parse_timing |
| 591 .parse_blocked_on_script_load_from_document_write_duration.value()); | 595 ->parse_blocked_on_script_load_from_document_write_duration |
| 596 .value()); |
| 592 } | 597 } |
| 593 } | 598 } |
| 594 | 599 |
| 595 void CorePageLoadMetricsObserver::OnComplete( | 600 void CorePageLoadMetricsObserver::OnComplete( |
| 596 const page_load_metrics::PageLoadTiming& timing, | 601 const page_load_metrics::mojom::PageLoadTiming& timing, |
| 597 const page_load_metrics::PageLoadExtraInfo& info) { | 602 const page_load_metrics::PageLoadExtraInfo& info) { |
| 598 RecordTimingHistograms(timing, info); | 603 RecordTimingHistograms(timing, info); |
| 599 RecordByteAndResourceHistograms(timing, info); | 604 RecordByteAndResourceHistograms(timing, info); |
| 600 RecordRappor(timing, info); | 605 RecordRappor(timing, info); |
| 601 RecordForegroundDurationHistograms(timing, info, base::TimeTicks()); | 606 RecordForegroundDurationHistograms(timing, info, base::TimeTicks()); |
| 602 } | 607 } |
| 603 | 608 |
| 604 page_load_metrics::PageLoadMetricsObserver::ObservePolicy | 609 page_load_metrics::PageLoadMetricsObserver::ObservePolicy |
| 605 CorePageLoadMetricsObserver::FlushMetricsOnAppEnterBackground( | 610 CorePageLoadMetricsObserver::FlushMetricsOnAppEnterBackground( |
| 606 const page_load_metrics::PageLoadTiming& timing, | 611 const page_load_metrics::mojom::PageLoadTiming& timing, |
| 607 const page_load_metrics::PageLoadExtraInfo& info) { | 612 const page_load_metrics::PageLoadExtraInfo& info) { |
| 608 // FlushMetricsOnAppEnterBackground is invoked on Android in cases where the | 613 // FlushMetricsOnAppEnterBackground is invoked on Android in cases where the |
| 609 // app is about to be backgrounded, as part of the Activity.onPause() | 614 // app is about to be backgrounded, as part of the Activity.onPause() |
| 610 // flow. After this method is invoked, Chrome may be killed without further | 615 // flow. After this method is invoked, Chrome may be killed without further |
| 611 // notification, so we record final metrics collected up to this point. | 616 // notification, so we record final metrics collected up to this point. |
| 612 if (info.did_commit) { | 617 if (info.did_commit) { |
| 613 RecordTimingHistograms(timing, info); | 618 RecordTimingHistograms(timing, info); |
| 614 RecordByteAndResourceHistograms(timing, info); | 619 RecordByteAndResourceHistograms(timing, info); |
| 615 } | 620 } |
| 616 RecordForegroundDurationHistograms(timing, info, base::TimeTicks::Now()); | 621 RecordForegroundDurationHistograms(timing, info, base::TimeTicks::Now()); |
| 617 return STOP_OBSERVING; | 622 return STOP_OBSERVING; |
| 618 } | 623 } |
| 619 | 624 |
| 620 void CorePageLoadMetricsObserver::OnFailedProvisionalLoad( | 625 void CorePageLoadMetricsObserver::OnFailedProvisionalLoad( |
| 621 const page_load_metrics::FailedProvisionalLoadInfo& failed_load_info, | 626 const page_load_metrics::FailedProvisionalLoadInfo& failed_load_info, |
| 622 const page_load_metrics::PageLoadExtraInfo& extra_info) { | 627 const page_load_metrics::PageLoadExtraInfo& extra_info) { |
| 623 // Only handle actual failures; provisional loads that failed due to another | 628 // Only handle actual failures; provisional loads that failed due to another |
| 624 // committed load or due to user action are recorded in | 629 // committed load or due to user action are recorded in |
| 625 // AbortsPageLoadMetricsObserver. | 630 // AbortsPageLoadMetricsObserver. |
| 626 if (failed_load_info.error != net::OK && | 631 if (failed_load_info.error != net::OK && |
| 627 failed_load_info.error != net::ERR_ABORTED) { | 632 failed_load_info.error != net::ERR_ABORTED) { |
| 628 if (WasStartedInForegroundOptionalEventInForeground( | 633 if (WasStartedInForegroundOptionalEventInForeground( |
| 629 failed_load_info.time_to_failed_provisional_load, extra_info)) { | 634 failed_load_info.time_to_failed_provisional_load, extra_info)) { |
| 630 PAGE_LOAD_HISTOGRAM(internal::kHistogramFailedProvisionalLoad, | 635 PAGE_LOAD_HISTOGRAM(internal::kHistogramFailedProvisionalLoad, |
| 631 failed_load_info.time_to_failed_provisional_load); | 636 failed_load_info.time_to_failed_provisional_load); |
| 632 } | 637 } |
| 633 } | 638 } |
| 634 // Provide an empty PageLoadTiming, since we don't have any timing metrics | 639 // Provide an empty PageLoadTiming, since we don't have any timing metrics |
| 635 // for failed provisional loads. | 640 // for failed provisional loads. |
| 636 RecordForegroundDurationHistograms(page_load_metrics::PageLoadTiming(), | 641 RecordForegroundDurationHistograms(page_load_metrics::mojom::PageLoadTiming(), |
| 637 extra_info, base::TimeTicks()); | 642 extra_info, base::TimeTicks()); |
| 638 } | 643 } |
| 639 | 644 |
| 640 void CorePageLoadMetricsObserver::OnUserInput( | 645 void CorePageLoadMetricsObserver::OnUserInput( |
| 641 const blink::WebInputEvent& event) { | 646 const blink::WebInputEvent& event) { |
| 642 base::TimeTicks now; | 647 base::TimeTicks now; |
| 643 if (!first_paint_.is_null() && | 648 if (!first_paint_.is_null() && |
| 644 first_user_interaction_after_first_paint_.is_null() && | 649 first_user_interaction_after_first_paint_.is_null() && |
| 645 event.GetType() != blink::WebInputEvent::kMouseMove) { | 650 event.GetType() != blink::WebInputEvent::kMouseMove) { |
| 646 if (now.is_null()) | 651 if (now.is_null()) |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 678 if (extra_request_complete_info.was_cached) { | 683 if (extra_request_complete_info.was_cached) { |
| 679 ++num_cache_resources_; | 684 ++num_cache_resources_; |
| 680 cache_bytes_ += extra_request_complete_info.raw_body_bytes; | 685 cache_bytes_ += extra_request_complete_info.raw_body_bytes; |
| 681 } else { | 686 } else { |
| 682 ++num_network_resources_; | 687 ++num_network_resources_; |
| 683 network_bytes_ += extra_request_complete_info.raw_body_bytes; | 688 network_bytes_ += extra_request_complete_info.raw_body_bytes; |
| 684 } | 689 } |
| 685 } | 690 } |
| 686 | 691 |
| 687 void CorePageLoadMetricsObserver::RecordTimingHistograms( | 692 void CorePageLoadMetricsObserver::RecordTimingHistograms( |
| 688 const page_load_metrics::PageLoadTiming& timing, | 693 const page_load_metrics::mojom::PageLoadTiming& timing, |
| 689 const page_load_metrics::PageLoadExtraInfo& info) { | 694 const page_load_metrics::PageLoadExtraInfo& info) { |
| 690 // Log time to first foreground / time to first background. Log counts that we | 695 // Log time to first foreground / time to first background. Log counts that we |
| 691 // started a relevant page load in the foreground / background. | 696 // started a relevant page load in the foreground / background. |
| 692 if (!info.started_in_foreground && info.first_foreground_time) { | 697 if (!info.started_in_foreground && info.first_foreground_time) { |
| 693 PAGE_LOAD_HISTOGRAM(internal::kHistogramFirstForeground, | 698 PAGE_LOAD_HISTOGRAM(internal::kHistogramFirstForeground, |
| 694 info.first_foreground_time.value()); | 699 info.first_foreground_time.value()); |
| 695 } | 700 } |
| 696 | 701 |
| 697 if (timing.paint_timing.first_paint && | 702 if (timing.paint_timing->first_paint && |
| 698 !timing.paint_timing.first_meaningful_paint) { | 703 !timing.paint_timing->first_meaningful_paint) { |
| 699 RecordFirstMeaningfulPaintStatus( | 704 RecordFirstMeaningfulPaintStatus( |
| 700 timing.paint_timing.first_contentful_paint | 705 timing.paint_timing->first_contentful_paint |
| 701 ? internal::FIRST_MEANINGFUL_PAINT_DID_NOT_REACH_NETWORK_STABLE | 706 ? internal::FIRST_MEANINGFUL_PAINT_DID_NOT_REACH_NETWORK_STABLE |
| 702 : internal:: | 707 : internal:: |
| 703 FIRST_MEANINGFUL_PAINT_DID_NOT_REACH_FIRST_CONTENTFUL_PAINT); | 708 FIRST_MEANINGFUL_PAINT_DID_NOT_REACH_FIRST_CONTENTFUL_PAINT); |
| 704 } | 709 } |
| 705 | 710 |
| 706 if (timing.paint_timing.first_paint) { | 711 if (timing.paint_timing->first_paint) { |
| 707 enum FirstMeaningfulPaintSignalStatus { | 712 enum FirstMeaningfulPaintSignalStatus { |
| 708 HAD_USER_INPUT = 1 << 0, | 713 HAD_USER_INPUT = 1 << 0, |
| 709 NETWORK_STABLE = 1 << 1, | 714 NETWORK_STABLE = 1 << 1, |
| 710 FIRST_MEANINGFUL_PAINT_SIGNAL_STATUS_LAST_ENTRY = 1 << 2 | 715 FIRST_MEANINGFUL_PAINT_SIGNAL_STATUS_LAST_ENTRY = 1 << 2 |
| 711 }; | 716 }; |
| 712 int signal_status = | 717 int signal_status = |
| 713 (first_user_interaction_after_first_paint_.is_null() ? 0 | 718 (first_user_interaction_after_first_paint_.is_null() ? 0 |
| 714 : HAD_USER_INPUT) + | 719 : HAD_USER_INPUT) + |
| 715 (timing.paint_timing.first_meaningful_paint ? NETWORK_STABLE : 0); | 720 (timing.paint_timing->first_meaningful_paint ? NETWORK_STABLE : 0); |
| 716 UMA_HISTOGRAM_ENUMERATION( | 721 UMA_HISTOGRAM_ENUMERATION( |
| 717 internal::kHistogramFirstMeaningfulPaintSignalStatus2, | 722 internal::kHistogramFirstMeaningfulPaintSignalStatus2, |
| 718 signal_status, FIRST_MEANINGFUL_PAINT_SIGNAL_STATUS_LAST_ENTRY); | 723 signal_status, FIRST_MEANINGFUL_PAINT_SIGNAL_STATUS_LAST_ENTRY); |
| 719 } | 724 } |
| 720 if (timing.paint_timing.first_meaningful_paint) { | 725 if (timing.paint_timing->first_meaningful_paint) { |
| 721 if (first_user_interaction_after_first_paint_.is_null()) { | 726 if (first_user_interaction_after_first_paint_.is_null()) { |
| 722 PAGE_LOAD_HISTOGRAM(internal::kHistogramFirstMeaningfulPaintNoUserInput, | 727 PAGE_LOAD_HISTOGRAM(internal::kHistogramFirstMeaningfulPaintNoUserInput, |
| 723 timing.paint_timing.first_meaningful_paint.value()); | 728 timing.paint_timing->first_meaningful_paint.value()); |
| 724 } else { | 729 } else { |
| 725 PAGE_LOAD_HISTOGRAM(internal::kHistogramFirstMeaningfulPaintHadUserInput, | 730 PAGE_LOAD_HISTOGRAM(internal::kHistogramFirstMeaningfulPaintHadUserInput, |
| 726 timing.paint_timing.first_meaningful_paint.value()); | 731 timing.paint_timing->first_meaningful_paint.value()); |
| 727 } | 732 } |
| 728 } | 733 } |
| 729 } | 734 } |
| 730 | 735 |
| 731 void CorePageLoadMetricsObserver::RecordForegroundDurationHistograms( | 736 void CorePageLoadMetricsObserver::RecordForegroundDurationHistograms( |
| 732 const page_load_metrics::PageLoadTiming& timing, | 737 const page_load_metrics::mojom::PageLoadTiming& timing, |
| 733 const page_load_metrics::PageLoadExtraInfo& info, | 738 const page_load_metrics::PageLoadExtraInfo& info, |
| 734 base::TimeTicks app_background_time) { | 739 base::TimeTicks app_background_time) { |
| 735 base::Optional<base::TimeDelta> foreground_duration = | 740 base::Optional<base::TimeDelta> foreground_duration = |
| 736 GetInitialForegroundDuration(info, app_background_time); | 741 GetInitialForegroundDuration(info, app_background_time); |
| 737 if (!foreground_duration) | 742 if (!foreground_duration) |
| 738 return; | 743 return; |
| 739 | 744 |
| 740 if (info.did_commit) { | 745 if (info.did_commit) { |
| 741 PAGE_LOAD_LONG_HISTOGRAM(internal::kHistogramPageTimingForegroundDuration, | 746 PAGE_LOAD_LONG_HISTOGRAM(internal::kHistogramPageTimingForegroundDuration, |
| 742 foreground_duration.value()); | 747 foreground_duration.value()); |
| 743 if (timing.paint_timing.first_paint && | 748 if (timing.paint_timing->first_paint && |
| 744 timing.paint_timing.first_paint < foreground_duration) { | 749 timing.paint_timing->first_paint < foreground_duration) { |
| 745 PAGE_LOAD_LONG_HISTOGRAM( | 750 PAGE_LOAD_LONG_HISTOGRAM( |
| 746 internal::kHistogramPageTimingForegroundDurationAfterPaint, | 751 internal::kHistogramPageTimingForegroundDurationAfterPaint, |
| 747 foreground_duration.value() - | 752 foreground_duration.value() - |
| 748 timing.paint_timing.first_paint.value()); | 753 timing.paint_timing->first_paint.value()); |
| 749 PAGE_LOAD_LONG_HISTOGRAM( | 754 PAGE_LOAD_LONG_HISTOGRAM( |
| 750 internal::kHistogramPageTimingForegroundDurationWithPaint, | 755 internal::kHistogramPageTimingForegroundDurationWithPaint, |
| 751 foreground_duration.value()); | 756 foreground_duration.value()); |
| 752 } else { | 757 } else { |
| 753 PAGE_LOAD_LONG_HISTOGRAM( | 758 PAGE_LOAD_LONG_HISTOGRAM( |
| 754 internal::kHistogramPageTimingForegroundDurationWithoutPaint, | 759 internal::kHistogramPageTimingForegroundDurationWithoutPaint, |
| 755 foreground_duration.value()); | 760 foreground_duration.value()); |
| 756 } | 761 } |
| 757 } else { | 762 } else { |
| 758 PAGE_LOAD_LONG_HISTOGRAM( | 763 PAGE_LOAD_LONG_HISTOGRAM( |
| 759 internal::kHistogramPageTimingForegroundDurationNoCommit, | 764 internal::kHistogramPageTimingForegroundDurationNoCommit, |
| 760 foreground_duration.value()); | 765 foreground_duration.value()); |
| 761 } | 766 } |
| 762 } | 767 } |
| 763 | 768 |
| 764 void CorePageLoadMetricsObserver::RecordByteAndResourceHistograms( | 769 void CorePageLoadMetricsObserver::RecordByteAndResourceHistograms( |
| 765 const page_load_metrics::PageLoadTiming& timing, | 770 const page_load_metrics::mojom::PageLoadTiming& timing, |
| 766 const page_load_metrics::PageLoadExtraInfo& info) { | 771 const page_load_metrics::PageLoadExtraInfo& info) { |
| 767 DCHECK_GE(network_bytes_, 0); | 772 DCHECK_GE(network_bytes_, 0); |
| 768 DCHECK_GE(cache_bytes_, 0); | 773 DCHECK_GE(cache_bytes_, 0); |
| 769 int64_t total_bytes = network_bytes_ + cache_bytes_; | 774 int64_t total_bytes = network_bytes_ + cache_bytes_; |
| 770 | 775 |
| 771 PAGE_BYTES_HISTOGRAM(internal::kHistogramNetworkBytes, network_bytes_); | 776 PAGE_BYTES_HISTOGRAM(internal::kHistogramNetworkBytes, network_bytes_); |
| 772 PAGE_BYTES_HISTOGRAM(internal::kHistogramCacheBytes, cache_bytes_); | 777 PAGE_BYTES_HISTOGRAM(internal::kHistogramCacheBytes, cache_bytes_); |
| 773 PAGE_BYTES_HISTOGRAM(internal::kHistogramTotalBytes, total_bytes); | 778 PAGE_BYTES_HISTOGRAM(internal::kHistogramTotalBytes, total_bytes); |
| 774 | 779 |
| 775 switch (GetPageLoadType(transition_)) { | 780 switch (GetPageLoadType(transition_)) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 805 | 810 |
| 806 PAGE_RESOURCE_COUNT_HISTOGRAM(internal::kHistogramNetworkCompletedResources, | 811 PAGE_RESOURCE_COUNT_HISTOGRAM(internal::kHistogramNetworkCompletedResources, |
| 807 num_network_resources_); | 812 num_network_resources_); |
| 808 PAGE_RESOURCE_COUNT_HISTOGRAM(internal::kHistogramCacheCompletedResources, | 813 PAGE_RESOURCE_COUNT_HISTOGRAM(internal::kHistogramCacheCompletedResources, |
| 809 num_cache_resources_); | 814 num_cache_resources_); |
| 810 PAGE_RESOURCE_COUNT_HISTOGRAM(internal::kHistogramTotalCompletedResources, | 815 PAGE_RESOURCE_COUNT_HISTOGRAM(internal::kHistogramTotalCompletedResources, |
| 811 num_cache_resources_ + num_network_resources_); | 816 num_cache_resources_ + num_network_resources_); |
| 812 } | 817 } |
| 813 | 818 |
| 814 void CorePageLoadMetricsObserver::RecordRappor( | 819 void CorePageLoadMetricsObserver::RecordRappor( |
| 815 const page_load_metrics::PageLoadTiming& timing, | 820 const page_load_metrics::mojom::PageLoadTiming& timing, |
| 816 const page_load_metrics::PageLoadExtraInfo& info) { | 821 const page_load_metrics::PageLoadExtraInfo& info) { |
| 817 // During the browser process shutdown path, calling | 822 // During the browser process shutdown path, calling |
| 818 // BrowserProcess::rappor_service() can reinitialize multiple destroyed | 823 // BrowserProcess::rappor_service() can reinitialize multiple destroyed |
| 819 // objects. This alters shutdown ordering, so we avoid it by testing | 824 // objects. This alters shutdown ordering, so we avoid it by testing |
| 820 // IsShuttingDown() first. | 825 // IsShuttingDown() first. |
| 821 if (g_browser_process->IsShuttingDown()) | 826 if (g_browser_process->IsShuttingDown()) |
| 822 return; | 827 return; |
| 823 rappor::RapporServiceImpl* rappor_service = | 828 rappor::RapporServiceImpl* rappor_service = |
| 824 g_browser_process->rappor_service(); | 829 g_browser_process->rappor_service(); |
| 825 if (!rappor_service) | 830 if (!rappor_service) |
| 826 return; | 831 return; |
| 827 if (!info.did_commit) | 832 if (!info.did_commit) |
| 828 return; | 833 return; |
| 829 | 834 |
| 830 // Log the eTLD+1 of sites that show poor loading performance. | 835 // Log the eTLD+1 of sites that show poor loading performance. |
| 831 if (WasStartedInForegroundOptionalEventInForeground( | 836 if (WasStartedInForegroundOptionalEventInForeground( |
| 832 timing.paint_timing.first_contentful_paint, info)) { | 837 timing.paint_timing->first_contentful_paint, info)) { |
| 833 std::unique_ptr<rappor::Sample> sample = | 838 std::unique_ptr<rappor::Sample> sample = |
| 834 rappor_service->CreateSample(rappor::UMA_RAPPOR_TYPE); | 839 rappor_service->CreateSample(rappor::UMA_RAPPOR_TYPE); |
| 835 sample->SetStringField( | 840 sample->SetStringField( |
| 836 "Domain", rappor::GetDomainAndRegistrySampleFromGURL(info.url)); | 841 "Domain", rappor::GetDomainAndRegistrySampleFromGURL(info.url)); |
| 837 uint64_t bucket_index = RapporHistogramBucketIndex( | 842 uint64_t bucket_index = RapporHistogramBucketIndex( |
| 838 timing.paint_timing.first_contentful_paint.value()); | 843 timing.paint_timing->first_contentful_paint.value()); |
| 839 sample->SetFlagsField("Bucket", uint64_t(1) << bucket_index, | 844 sample->SetFlagsField("Bucket", uint64_t(1) << bucket_index, |
| 840 kNumRapporHistogramBuckets); | 845 kNumRapporHistogramBuckets); |
| 841 // The IsSlow flag is just a one bit boolean if the first contentful paint | 846 // The IsSlow flag is just a one bit boolean if the first contentful paint |
| 842 // was > 10s. | 847 // was > 10s. |
| 843 sample->SetFlagsField( | 848 sample->SetFlagsField( |
| 844 "IsSlow", | 849 "IsSlow", |
| 845 timing.paint_timing.first_contentful_paint.value().InSecondsF() >= 10, | 850 timing.paint_timing->first_contentful_paint.value().InSecondsF() >= 10, |
| 846 1); | 851 1); |
| 847 rappor_service->RecordSample(internal::kRapporMetricsNameCoarseTiming, | 852 rappor_service->RecordSample(internal::kRapporMetricsNameCoarseTiming, |
| 848 std::move(sample)); | 853 std::move(sample)); |
| 849 } | 854 } |
| 850 | 855 |
| 851 // Log the eTLD+1 of sites that did not report first meaningful paint. | 856 // Log the eTLD+1 of sites that did not report first meaningful paint. |
| 852 if (timing.paint_timing.first_paint && | 857 if (timing.paint_timing->first_paint && |
| 853 !timing.paint_timing.first_meaningful_paint) { | 858 !timing.paint_timing->first_meaningful_paint) { |
| 854 rappor::SampleDomainAndRegistryFromGURL( | 859 rappor::SampleDomainAndRegistryFromGURL( |
| 855 rappor_service, | 860 rappor_service, |
| 856 internal::kRapporMetricsNameFirstMeaningfulPaintNotRecorded, info.url); | 861 internal::kRapporMetricsNameFirstMeaningfulPaintNotRecorded, info.url); |
| 857 } | 862 } |
| 858 } | 863 } |
| OLD | NEW |