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

Side by Side Diff: components/page_load_metrics/browser/metrics_web_contents_observer.cc

Issue 1548203002: Convert Pass()→std::move() in //components/[n-z]* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix bad headers Created 4 years, 12 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 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 "components/page_load_metrics/browser/metrics_web_contents_observer.h" 5 #include "components/page_load_metrics/browser/metrics_web_contents_observer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <utility>
9 10
10 #include "base/location.h" 11 #include "base/location.h"
11 #include "base/logging.h" 12 #include "base/logging.h"
12 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
13 #include "base/metrics/user_metrics.h" 14 #include "base/metrics/user_metrics.h"
14 #include "components/page_load_metrics/browser/page_load_metrics_util.h" 15 #include "components/page_load_metrics/browser/page_load_metrics_util.h"
15 #include "components/page_load_metrics/common/page_load_metrics_messages.h" 16 #include "components/page_load_metrics/common/page_load_metrics_messages.h"
16 #include "components/page_load_metrics/common/page_load_timing.h" 17 #include "components/page_load_metrics/common/page_load_timing.h"
17 #include "components/rappor/rappor_service.h" 18 #include "components/rappor/rappor_service.h"
18 #include "components/rappor/rappor_utils.h" 19 #include "components/rappor/rappor_utils.h"
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 sample->SetStringField( 407 sample->SetStringField(
407 "Domain", rappor::GetDomainAndRegistrySampleFromGURL(committed_url())); 408 "Domain", rappor::GetDomainAndRegistrySampleFromGURL(committed_url()));
408 uint64_t bucket_index = RapporHistogramBucketIndex(first_contentful_paint); 409 uint64_t bucket_index = RapporHistogramBucketIndex(first_contentful_paint);
409 sample->SetFlagsField("Bucket", uint64_t(1) << bucket_index, 410 sample->SetFlagsField("Bucket", uint64_t(1) << bucket_index,
410 kNumRapporHistogramBuckets); 411 kNumRapporHistogramBuckets);
411 // The IsSlow flag is just a one bit boolean if the first contentful paint 412 // The IsSlow flag is just a one bit boolean if the first contentful paint
412 // was > 10s. 413 // was > 10s.
413 sample->SetFlagsField("IsSlow", first_contentful_paint.InSecondsF() >= 10, 414 sample->SetFlagsField("IsSlow", first_contentful_paint.InSecondsF() >= 10,
414 1); 415 1);
415 rappor_service->RecordSampleObj(kRapporMetricsNameCoarseTiming, 416 rappor_service->RecordSampleObj(kRapporMetricsNameCoarseTiming,
416 sample.Pass()); 417 std::move(sample));
417 } 418 }
418 } 419 }
419 420
420 // static 421 // static
421 MetricsWebContentsObserver::MetricsWebContentsObserver( 422 MetricsWebContentsObserver::MetricsWebContentsObserver(
422 content::WebContents* web_contents, 423 content::WebContents* web_contents,
423 scoped_ptr<PageLoadMetricsEmbedderInterface> embedder_interface) 424 scoped_ptr<PageLoadMetricsEmbedderInterface> embedder_interface)
424 : content::WebContentsObserver(web_contents), 425 : content::WebContentsObserver(web_contents),
425 in_foreground_(false), 426 in_foreground_(false),
426 embedder_interface_(embedder_interface.Pass()) {} 427 embedder_interface_(std::move(embedder_interface)) {}
427 428
428 MetricsWebContentsObserver* MetricsWebContentsObserver::CreateForWebContents( 429 MetricsWebContentsObserver* MetricsWebContentsObserver::CreateForWebContents(
429 content::WebContents* web_contents, 430 content::WebContents* web_contents,
430 scoped_ptr<PageLoadMetricsEmbedderInterface> embedder_interface) { 431 scoped_ptr<PageLoadMetricsEmbedderInterface> embedder_interface) {
431 DCHECK(web_contents); 432 DCHECK(web_contents);
432 433
433 MetricsWebContentsObserver* metrics = FromWebContents(web_contents); 434 MetricsWebContentsObserver* metrics = FromWebContents(web_contents);
434 if (!metrics) { 435 if (!metrics) {
435 metrics = 436 metrics = new MetricsWebContentsObserver(web_contents,
436 new MetricsWebContentsObserver(web_contents, embedder_interface.Pass()); 437 std::move(embedder_interface));
437 web_contents->SetUserData(UserDataKey(), metrics); 438 web_contents->SetUserData(UserDataKey(), metrics);
438 } 439 }
439 return metrics; 440 return metrics;
440 } 441 }
441 442
442 MetricsWebContentsObserver::~MetricsWebContentsObserver() { 443 MetricsWebContentsObserver::~MetricsWebContentsObserver() {
443 NotifyAbortAllLoads(ABORT_CLOSE); 444 NotifyAbortAllLoads(ABORT_CLOSE);
444 } 445 }
445 446
446 bool MetricsWebContentsObserver::OnMessageReceived( 447 bool MetricsWebContentsObserver::OnMessageReceived(
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 515
515 // Notify other loads that they may have been aborted by this committed load. 516 // Notify other loads that they may have been aborted by this committed load.
516 // Note that by using the committed navigation start as the abort cause, we 517 // Note that by using the committed navigation start as the abort cause, we
517 // lose data on provisional loads that were aborted by other provisional 518 // lose data on provisional loads that were aborted by other provisional
518 // loads. Those will either be listed as ABORT_OTHER or as being aborted by 519 // loads. Those will either be listed as ABORT_OTHER or as being aborted by
519 // this load. 520 // this load.
520 NotifyAbortAllLoadsWithTimestamp( 521 NotifyAbortAllLoadsWithTimestamp(
521 AbortTypeForPageTransition(navigation_handle->GetPageTransition()), 522 AbortTypeForPageTransition(navigation_handle->GetPageTransition()),
522 navigation_handle->NavigationStart()); 523 navigation_handle->NavigationStart());
523 524
524 committed_load_ = finished_nav.Pass(); 525 committed_load_ = std::move(finished_nav);
525 aborted_provisional_loads_.clear(); 526 aborted_provisional_loads_.clear();
526 527
527 const GURL& browser_url = web_contents()->GetLastCommittedURL(); 528 const GURL& browser_url = web_contents()->GetLastCommittedURL();
528 const std::string& mime_type = web_contents()->GetContentsMimeType(); 529 const std::string& mime_type = web_contents()->GetContentsMimeType();
529 DCHECK(!browser_url.is_empty()); 530 DCHECK(!browser_url.is_empty());
530 DCHECK(!mime_type.empty()); 531 DCHECK(!mime_type.empty());
531 committed_load_->set_renderer_tracked( 532 committed_load_->set_renderer_tracked(
532 IsRelevantNavigation(navigation_handle, browser_url, mime_type)); 533 IsRelevantNavigation(navigation_handle, browser_url, mime_type));
533 534
534 committed_load_->Commit(navigation_handle); 535 committed_load_->Commit(navigation_handle);
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 643
643 if (!committed_load_->UpdateTiming(timing)) { 644 if (!committed_load_->UpdateTiming(timing)) {
644 // If the page load tracker cannot update its timing, something is wrong 645 // If the page load tracker cannot update its timing, something is wrong
645 // with the IPC (it's from another load, or it's invalid in some other way). 646 // with the IPC (it's from another load, or it's invalid in some other way).
646 // We expect this to be a rare occurrence. 647 // We expect this to be a rare occurrence.
647 RecordInternalError(ERR_BAD_TIMING_IPC); 648 RecordInternalError(ERR_BAD_TIMING_IPC);
648 } 649 }
649 } 650 }
650 651
651 } // namespace page_load_metrics 652 } // namespace page_load_metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698