Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "chrome/browser/predictors/resource_prefetch_predictor.h" | 10 #include "chrome/browser/predictors/resource_prefetch_predictor.h" |
| 11 #include "content/public/browser/resource_request_info.h" | |
| 11 #include "content/public/common/resource_type.h" | 12 #include "content/public/common/resource_type.h" |
| 12 | 13 |
| 13 namespace net { | 14 namespace net { |
| 14 class URLRequest; | 15 class URLRequest; |
| 15 } | 16 } |
| 16 | 17 |
| 17 class GURL; | 18 class GURL; |
| 18 | 19 |
| 19 namespace chrome_browser_net { | 20 namespace chrome_browser_net { |
| 20 | 21 |
| 21 // Observes resource requests in the ResourceDispatcherHostDelegate and notifies | 22 // Observes resource requests in the ResourceDispatcherHostDelegate and notifies |
| 22 // the ResourcePrefetchPredictor about the ones it is interested in. | 23 // the ResourcePrefetchPredictor about the ones it is interested in. |
| 23 // - Has an instance per profile, and is owned by the corresponding | 24 // - Has an instance per profile, and is owned by the corresponding |
| 24 // ProfileIOData. | 25 // ProfileIOData. |
| 25 // - Needs to be constructed on UI thread. Rest of the functions can only be | 26 // - Needs to be constructed on UI thread. Rest of the functions can only be |
| 26 // called on the IO thread. Can be destroyed on UI or IO thread. | 27 // called on the IO thread. Can be destroyed on UI or IO thread. |
|
alexilin
2016/12/05 13:20:00
Probably we should update this comment. I'm not su
| |
| 27 class ResourcePrefetchPredictorObserver { | 28 class ResourcePrefetchPredictorObserver { |
| 29 | |
|
ahemery
2016/12/05 09:38:45
Not sure this is okay in a header file, even if in
alexilin
2016/12/05 13:20:00
We generally avoid the use of using declaration in
| |
| 30 using URLRequestSummary = | |
|
ahemery
2016/12/06 14:31:11
Removed and full names used in header file
| |
| 31 predictors::ResourcePrefetchPredictor::URLRequestSummary; | |
| 32 | |
| 28 public: | 33 public: |
| 29 explicit ResourcePrefetchPredictorObserver( | 34 explicit ResourcePrefetchPredictorObserver( |
| 30 predictors::ResourcePrefetchPredictor* predictor); | 35 predictors::ResourcePrefetchPredictor* predictor); |
| 31 ~ResourcePrefetchPredictorObserver(); | 36 ~ResourcePrefetchPredictorObserver(); |
| 32 | 37 |
| 33 // Parts of the ResourceDispatcherHostDelegate that we want to observe. | 38 // Parts of the ResourceDispatcherHostDelegate that we want to observe. |
| 34 void OnRequestStarted(net::URLRequest* request, | 39 void OnRequestStarted( |
| 35 content::ResourceType resource_type, | 40 net::URLRequest* request, |
| 36 int child_id, | 41 content::ResourceType resource_type, |
| 37 int frame_id); | 42 const content::ResourceRequestInfo::WebContentsGetter& |
| 38 void OnRequestRedirected(const GURL& redirect_url, net::URLRequest* request); | 43 web_contents_getter); |
| 39 void OnResponseStarted(net::URLRequest* request); | 44 void OnRequestRedirected( |
| 45 net::URLRequest* request, | |
| 46 const GURL& redirect_url, | |
| 47 const content::ResourceRequestInfo::WebContentsGetter& | |
| 48 web_contents_getter); | |
| 49 void OnResponseStarted( | |
| 50 net::URLRequest* request, | |
| 51 const content::ResourceRequestInfo::WebContentsGetter& | |
| 52 web_contents_getter); | |
| 40 | 53 |
| 41 private: | 54 private: |
| 55 void OnRequestStartedOnUIThread( | |
| 56 std::unique_ptr<URLRequestSummary> summary, | |
| 57 const content::ResourceRequestInfo::WebContentsGetter& | |
| 58 web_contents_getter) const; | |
| 59 void OnRequestRedirectedOnUIThread( | |
| 60 std::unique_ptr<URLRequestSummary> summary, | |
| 61 const content::ResourceRequestInfo::WebContentsGetter& | |
| 62 web_contents_getter) const; | |
| 63 void OnResponseStartedOnUIThread( | |
| 64 std::unique_ptr<URLRequestSummary> summary, | |
| 65 const content::ResourceRequestInfo::WebContentsGetter& | |
| 66 web_contents_getter) const; | |
| 67 | |
| 68 void RetrieveNavigationID( | |
| 69 predictors::NavigationID& navigation_id, | |
| 70 const content::ResourceRequestInfo::WebContentsGetter& | |
| 71 web_contents_getter) const; | |
| 72 | |
| 42 // Owned by profile. | 73 // Owned by profile. |
| 43 base::WeakPtr<predictors::ResourcePrefetchPredictor> predictor_; | 74 base::WeakPtr<predictors::ResourcePrefetchPredictor> predictor_; |
| 44 | 75 |
| 45 DISALLOW_COPY_AND_ASSIGN(ResourcePrefetchPredictorObserver); | 76 DISALLOW_COPY_AND_ASSIGN(ResourcePrefetchPredictorObserver); |
| 46 }; | 77 }; |
| 47 | 78 |
| 48 } // namespace chrome_browser_net | 79 } // namespace chrome_browser_net |
| 49 | 80 |
| 50 #endif // CHROME_BROWSER_NET_RESOURCE_PREFETCH_PREDICTOR_OBSERVER_H_ | 81 #endif // CHROME_BROWSER_NET_RESOURCE_PREFETCH_PREDICTOR_OBSERVER_H_ |
| OLD | NEW |