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

Side by Side Diff: chrome/browser/net/resource_prefetch_predictor_observer.h

Issue 2896713003: Create LoadingDataCollector class and have observers rely on it instead of ResourcePrefetchPredictor (Closed)
Patch Set: Move some logic into new class. Created 3 years, 6 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 #ifndef CHROME_BROWSER_NET_RESOURCE_PREFETCH_PREDICTOR_OBSERVER_H_ 5 #ifndef CHROME_BROWSER_NET_RESOURCE_PREFETCH_PREDICTOR_OBSERVER_H_
6 #define CHROME_BROWSER_NET_RESOURCE_PREFETCH_PREDICTOR_OBSERVER_H_ 6 #define CHROME_BROWSER_NET_RESOURCE_PREFETCH_PREDICTOR_OBSERVER_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "chrome/browser/predictors/resource_prefetch_predictor.h" 12 #include "chrome/browser/predictors/loading_data_collector.h"
13 #include "content/public/browser/resource_request_info.h" 13 #include "content/public/browser/resource_request_info.h"
14 #include "content/public/common/resource_type.h" 14 #include "content/public/common/resource_type.h"
15 15
16 namespace net { 16 namespace net {
17 class URLRequest; 17 class URLRequest;
18 } 18 }
19 19
20 class GURL; 20 class GURL;
21 21
22 namespace chrome_browser_net { 22 namespace chrome_browser_net {
23 23
24 // Observes resource requests in the ResourceDispatcherHostDelegate and notifies 24 // Observes resource requests in the ResourceDispatcherHostDelegate and notifies
25 // the ResourcePrefetchPredictor about the ones it is interested in. 25 // the ResourcePrefetchPredictor about the ones it is interested in.
26 // - Has an instance per profile, and is owned by the corresponding 26 // - Has an instance per profile, and is owned by the corresponding
27 // ProfileIOData. 27 // ProfileIOData.
28 // - Needs to be constructed on UI thread. Can be destroyed on UI or IO thread. 28 // - Needs to be constructed on UI thread. Can be destroyed on UI or IO thread.
29 // As for member functions, public members are meant to be called on the IO 29 // As for member functions, public members are meant to be called on the IO
30 // thread and private members from the UI thread. 30 // thread and private members from the UI thread.
31 class ResourcePrefetchPredictorObserver { 31 class ResourcePrefetchPredictorObserver {
Benoit L 2017/05/29 08:55:36 Can you change this name as well, since it no long
trevordixon 2017/06/02 12:10:36 Looks like you did it!
32 public: 32 public:
33 explicit ResourcePrefetchPredictorObserver( 33 explicit ResourcePrefetchPredictorObserver(
34 predictors::ResourcePrefetchPredictor* predictor); 34 predictors::LoadingDataCollector* collector);
35 ~ResourcePrefetchPredictorObserver(); 35 ~ResourcePrefetchPredictorObserver();
36 36
37 // Parts of the ResourceDispatcherHostDelegate that we want to observe. 37 // Parts of the ResourceDispatcherHostDelegate that we want to observe.
38 void OnRequestStarted(net::URLRequest* request, 38 void OnRequestStarted(net::URLRequest* request,
39 content::ResourceType resource_type, 39 content::ResourceType resource_type,
40 const content::ResourceRequestInfo::WebContentsGetter& 40 const content::ResourceRequestInfo::WebContentsGetter&
41 web_contents_getter); 41 web_contents_getter);
42 void OnRequestRedirected( 42 void OnRequestRedirected(
43 net::URLRequest* request, 43 net::URLRequest* request,
44 const GURL& redirect_url, 44 const GURL& redirect_url,
(...skipping 20 matching lines...) Expand all
65 const base::TimeTicks& creation_time) const; 65 const base::TimeTicks& creation_time) const;
66 void OnResponseStartedOnUIThread( 66 void OnResponseStartedOnUIThread(
67 std::unique_ptr<predictors::ResourcePrefetchPredictor::URLRequestSummary> 67 std::unique_ptr<predictors::ResourcePrefetchPredictor::URLRequestSummary>
68 summary, 68 summary,
69 const content::ResourceRequestInfo::WebContentsGetter& 69 const content::ResourceRequestInfo::WebContentsGetter&
70 web_contents_getter, 70 web_contents_getter,
71 const GURL& main_frame_url, 71 const GURL& main_frame_url,
72 const base::TimeTicks& creation_time) const; 72 const base::TimeTicks& creation_time) const;
73 73
74 // Owned by profile. 74 // Owned by profile.
75 base::WeakPtr<predictors::ResourcePrefetchPredictor> predictor_; 75 base::WeakPtr<predictors::LoadingDataCollector> collector_;
76 76
77 DISALLOW_COPY_AND_ASSIGN(ResourcePrefetchPredictorObserver); 77 DISALLOW_COPY_AND_ASSIGN(ResourcePrefetchPredictorObserver);
78 }; 78 };
79 79
80 } // namespace chrome_browser_net 80 } // namespace chrome_browser_net
81 81
82 #endif // CHROME_BROWSER_NET_RESOURCE_PREFETCH_PREDICTOR_OBSERVER_H_ 82 #endif // CHROME_BROWSER_NET_RESOURCE_PREFETCH_PREDICTOR_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698