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

Side by Side Diff: chrome/browser/data_use_measurement/data_use_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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/data_use_measurement/data_use_web_contents_observer.h" 5 #include "chrome/browser/data_use_measurement/data_use_web_contents_observer.h"
6 6
7 #include "base/memory/ptr_util.h"
7 #include "chrome/browser/data_use_measurement/chrome_data_use_ascriber_service.h " 8 #include "chrome/browser/data_use_measurement/chrome_data_use_ascriber_service.h "
8 #include "chrome/browser/data_use_measurement/chrome_data_use_ascriber_service_f actory.h" 9 #include "chrome/browser/data_use_measurement/chrome_data_use_ascriber_service_f actory.h"
9 #include "content/public/browser/navigation_handle.h" 10 #include "content/public/browser/navigation_handle.h"
10 #include "content/public/browser/render_frame_host.h" 11 #include "content/public/browser/render_frame_host.h"
11 12
12 DEFINE_WEB_CONTENTS_USER_DATA_KEY( 13 DEFINE_WEB_CONTENTS_USER_DATA_KEY(
13 data_use_measurement::DataUseWebContentsObserver); 14 data_use_measurement::DataUseWebContentsObserver);
14 15
15 namespace data_use_measurement { 16 namespace data_use_measurement {
16 17
(...skipping 10 matching lines...) Expand all
27 // exists. 28 // exists.
28 if (!service || FromWebContents(web_contents)) 29 if (!service || FromWebContents(web_contents))
29 return; 30 return;
30 31
31 // |DataUseWebContentsObserver| is a |WebContentsUserData| so its lifetime 32 // |DataUseWebContentsObserver| is a |WebContentsUserData| so its lifetime
32 // is scoped to |web_contents|. 33 // is scoped to |web_contents|.
33 // |ChromeDataUseAscriberService| is a |KeyedService| and its lifetime is 34 // |ChromeDataUseAscriberService| is a |KeyedService| and its lifetime is
34 // tied to a profile. Since profiles outlive |WebContents|, |service| will 35 // tied to a profile. Since profiles outlive |WebContents|, |service| will
35 // outlive |DataUseWebContentsObserver|. 36 // outlive |DataUseWebContentsObserver|.
36 web_contents->SetUserData( 37 web_contents->SetUserData(
37 UserDataKey(), new DataUseWebContentsObserver(web_contents, service)); 38 UserDataKey(),
39 base::WrapUnique(new DataUseWebContentsObserver(web_contents, service)));
38 } 40 }
39 41
40 DataUseWebContentsObserver::DataUseWebContentsObserver( 42 DataUseWebContentsObserver::DataUseWebContentsObserver(
41 content::WebContents* web_contents, 43 content::WebContents* web_contents,
42 ChromeDataUseAscriberService* service) 44 ChromeDataUseAscriberService* service)
43 : content::WebContentsObserver(web_contents), service_(service) { 45 : content::WebContentsObserver(web_contents), service_(service) {
44 // Call RenderFrameCreated for live frames so that |service_| knows about 46 // Call RenderFrameCreated for live frames so that |service_| knows about
45 // all the RenderFrameHosts. 47 // all the RenderFrameHosts.
46 for (content::RenderFrameHost* frame : web_contents->GetAllFrames()) { 48 for (content::RenderFrameHost* frame : web_contents->GetAllFrames()) {
47 if (frame->IsRenderFrameLive()) { 49 if (frame->IsRenderFrameLive()) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 content::RenderFrameHost* new_host) { 87 content::RenderFrameHost* new_host) {
86 service_->RenderFrameHostChanged(old_host, new_host); 88 service_->RenderFrameHostChanged(old_host, new_host);
87 } 89 }
88 90
89 void DataUseWebContentsObserver::DidFinishNavigation( 91 void DataUseWebContentsObserver::DidFinishNavigation(
90 content::NavigationHandle* navigation_handle) { 92 content::NavigationHandle* navigation_handle) {
91 service_->DidFinishNavigation(navigation_handle); 93 service_->DidFinishNavigation(navigation_handle);
92 } 94 }
93 95
94 } // namespace data_use_measurement 96 } // namespace data_use_measurement
OLDNEW
« no previous file with comments | « chrome/browser/data_use_measurement/chrome_data_use_ascriber.cc ('k') | chrome/browser/font_family_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698