| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_LOADING_PREDICTOR_OBSERVER_H_ |
| 6 #define CHROME_BROWSER_NET_RESOURCE_PREFETCH_PREDICTOR_OBSERVER_H_ | 6 #define CHROME_BROWSER_NET_LOADING_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/loading_predictor.h" |
| 12 #include "chrome/browser/predictors/resource_prefetch_predictor.h" | 13 #include "chrome/browser/predictors/resource_prefetch_predictor.h" |
| 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 LoadingPredictor 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 LoadingPredictorObserver { |
| 32 public: | 33 public: |
| 33 explicit ResourcePrefetchPredictorObserver( | 34 explicit LoadingPredictorObserver(predictors::LoadingPredictor* predictor); |
| 34 predictors::ResourcePrefetchPredictor* predictor); | 35 ~LoadingPredictorObserver(); |
| 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, |
| 45 const content::ResourceRequestInfo::WebContentsGetter& | 45 const content::ResourceRequestInfo::WebContentsGetter& |
| (...skipping 19 matching lines...) Expand all Loading... |
| 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::LoadingPredictor> predictor_; |
| 76 | 76 |
| 77 DISALLOW_COPY_AND_ASSIGN(ResourcePrefetchPredictorObserver); | 77 DISALLOW_COPY_AND_ASSIGN(LoadingPredictorObserver); |
| 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_LOADING_PREDICTOR_OBSERVER_H_ |
| OLD | NEW |