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

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: 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 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/glowplug_collector.h"
12 #include "chrome/browser/predictors/resource_prefetch_predictor.h" 13 #include "chrome/browser/predictors/resource_prefetch_predictor.h"
alexilin 2017/05/22 13:20:36 nit: Do we need this include?
trevordixon 2017/05/22 21:29:01 Gone.
13 #include "content/public/browser/resource_request_info.h" 14 #include "content/public/browser/resource_request_info.h"
14 #include "content/public/common/resource_type.h" 15 #include "content/public/common/resource_type.h"
15 16
16 namespace net { 17 namespace net {
17 class URLRequest; 18 class URLRequest;
18 } 19 }
19 20
20 class GURL; 21 class GURL;
21 22
22 namespace chrome_browser_net { 23 namespace chrome_browser_net {
23 24
24 // Observes resource requests in the ResourceDispatcherHostDelegate and notifies 25 // Observes resource requests in the ResourceDispatcherHostDelegate and notifies
25 // the ResourcePrefetchPredictor about the ones it is interested in. 26 // the ResourcePrefetchPredictor about the ones it is interested in.
26 // - Has an instance per profile, and is owned by the corresponding 27 // - Has an instance per profile, and is owned by the corresponding
27 // ProfileIOData. 28 // ProfileIOData.
28 // - Needs to be constructed on UI thread. Can be destroyed on UI or IO thread. 29 // - 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 30 // As for member functions, public members are meant to be called on the IO
30 // thread and private members from the UI thread. 31 // thread and private members from the UI thread.
31 class ResourcePrefetchPredictorObserver { 32 class ResourcePrefetchPredictorObserver {
32 public: 33 public:
33 explicit ResourcePrefetchPredictorObserver( 34 explicit ResourcePrefetchPredictorObserver(
34 predictors::ResourcePrefetchPredictor* predictor); 35 predictors::GlowplugCollector* collector);
35 ~ResourcePrefetchPredictorObserver(); 36 ~ResourcePrefetchPredictorObserver();
36 37
37 // Parts of the ResourceDispatcherHostDelegate that we want to observe. 38 // Parts of the ResourceDispatcherHostDelegate that we want to observe.
38 void OnRequestStarted(net::URLRequest* request, 39 void OnRequestStarted(net::URLRequest* request,
39 content::ResourceType resource_type, 40 content::ResourceType resource_type,
40 const content::ResourceRequestInfo::WebContentsGetter& 41 const content::ResourceRequestInfo::WebContentsGetter&
41 web_contents_getter); 42 web_contents_getter);
42 void OnRequestRedirected( 43 void OnRequestRedirected(
43 net::URLRequest* request, 44 net::URLRequest* request,
44 const GURL& redirect_url, 45 const GURL& redirect_url,
(...skipping 20 matching lines...) Expand all
65 const base::TimeTicks& creation_time) const; 66 const base::TimeTicks& creation_time) const;
66 void OnResponseStartedOnUIThread( 67 void OnResponseStartedOnUIThread(
67 std::unique_ptr<predictors::ResourcePrefetchPredictor::URLRequestSummary> 68 std::unique_ptr<predictors::ResourcePrefetchPredictor::URLRequestSummary>
68 summary, 69 summary,
69 const content::ResourceRequestInfo::WebContentsGetter& 70 const content::ResourceRequestInfo::WebContentsGetter&
70 web_contents_getter, 71 web_contents_getter,
71 const GURL& main_frame_url, 72 const GURL& main_frame_url,
72 const base::TimeTicks& creation_time) const; 73 const base::TimeTicks& creation_time) const;
73 74
74 // Owned by profile. 75 // Owned by profile.
75 base::WeakPtr<predictors::ResourcePrefetchPredictor> predictor_; 76 base::WeakPtr<predictors::GlowplugCollector> collector_;
76 77
77 DISALLOW_COPY_AND_ASSIGN(ResourcePrefetchPredictorObserver); 78 DISALLOW_COPY_AND_ASSIGN(ResourcePrefetchPredictorObserver);
78 }; 79 };
79 80
80 } // namespace chrome_browser_net 81 } // namespace chrome_browser_net
81 82
82 #endif // CHROME_BROWSER_NET_RESOURCE_PREFETCH_PREDICTOR_OBSERVER_H_ 83 #endif // CHROME_BROWSER_NET_RESOURCE_PREFETCH_PREDICTOR_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698