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

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

Issue 2842833003: Update SupportsUserData uses with unique_ptr. (Closed)
Patch Set: rebase Created 3 years, 7 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 "chrome/browser/page_load_metrics/metrics_web_contents_observer.h" 5 #include "chrome/browser/page_load_metrics/metrics_web_contents_observer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <ostream> 8 #include <ostream>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 // static 77 // static
78 MetricsWebContentsObserver* MetricsWebContentsObserver::CreateForWebContents( 78 MetricsWebContentsObserver* MetricsWebContentsObserver::CreateForWebContents(
79 content::WebContents* web_contents, 79 content::WebContents* web_contents,
80 std::unique_ptr<PageLoadMetricsEmbedderInterface> embedder_interface) { 80 std::unique_ptr<PageLoadMetricsEmbedderInterface> embedder_interface) {
81 DCHECK(web_contents); 81 DCHECK(web_contents);
82 82
83 MetricsWebContentsObserver* metrics = FromWebContents(web_contents); 83 MetricsWebContentsObserver* metrics = FromWebContents(web_contents);
84 if (!metrics) { 84 if (!metrics) {
85 metrics = new MetricsWebContentsObserver(web_contents, 85 metrics = new MetricsWebContentsObserver(web_contents,
86 std::move(embedder_interface)); 86 std::move(embedder_interface));
87 web_contents->SetUserData(UserDataKey(), metrics); 87 web_contents->SetUserData(UserDataKey(), base::WrapUnique(metrics));
88 } 88 }
89 return metrics; 89 return metrics;
90 } 90 }
91 91
92 MetricsWebContentsObserver::~MetricsWebContentsObserver() { 92 MetricsWebContentsObserver::~MetricsWebContentsObserver() {
93 // TODO(csharrison): Use a more user-initiated signal for CLOSE. 93 // TODO(csharrison): Use a more user-initiated signal for CLOSE.
94 NotifyPageEndAllLoads(END_CLOSE, UserInitiatedInfo::NotUserInitiated()); 94 NotifyPageEndAllLoads(END_CLOSE, UserInitiatedInfo::NotUserInitiated());
95 95
96 for (auto& observer : testing_observers_) 96 for (auto& observer : testing_observers_)
97 observer.OnGoingAway(); 97 observer.OnGoingAway();
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 observer_->RemoveTestingObserver(this); 637 observer_->RemoveTestingObserver(this);
638 observer_ = nullptr; 638 observer_ = nullptr;
639 } 639 }
640 } 640 }
641 641
642 void MetricsWebContentsObserver::TestingObserver::OnGoingAway() { 642 void MetricsWebContentsObserver::TestingObserver::OnGoingAway() {
643 observer_ = nullptr; 643 observer_ = nullptr;
644 } 644 }
645 645
646 } // namespace page_load_metrics 646 } // namespace page_load_metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698