| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/basictypes.h" | 8 #include "base/basictypes.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 "webkit/glue/resource_type.h" | 11 #include "webkit/glue/resource_type.h" |
| 12 | 12 |
| 13 namespace net { | 13 namespace net { |
| 14 class URLRequest; | 14 class URLRequest; |
| 15 } | 15 } |
| 16 | 16 |
| 17 class GURL; |
| 18 |
| 17 namespace chrome_browser_net { | 19 namespace chrome_browser_net { |
| 18 | 20 |
| 19 // Observes resource requests in the ResourceDispatcherHostDelegate and notifies | 21 // Observes resource requests in the ResourceDispatcherHostDelegate and notifies |
| 20 // the ResourcePrefetchPredictor about the ones it is interested in. | 22 // the ResourcePrefetchPredictor about the ones it is interested in. |
| 21 // - Has an instance per profile, and is owned by the corresponding | 23 // - Has an instance per profile, and is owned by the corresponding |
| 22 // ProfileIOData. | 24 // ProfileIOData. |
| 23 // - Needs to be constructed on UI thread. Rest of the functions can only be | 25 // - Needs to be constructed on UI thread. Rest of the functions can only be |
| 24 // called on the IO thread. Can be destroyed on UI or IO thread. | 26 // called on the IO thread. Can be destroyed on UI or IO thread. |
| 25 class ResourcePrefetchPredictorObserver { | 27 class ResourcePrefetchPredictorObserver { |
| 26 public: | 28 public: |
| 27 explicit ResourcePrefetchPredictorObserver( | 29 explicit ResourcePrefetchPredictorObserver( |
| 28 predictors::ResourcePrefetchPredictor* predictor); | 30 predictors::ResourcePrefetchPredictor* predictor); |
| 29 ~ResourcePrefetchPredictorObserver(); | 31 ~ResourcePrefetchPredictorObserver(); |
| 30 | 32 |
| 31 // Parts of the ResourceDispatcherHostDelegate that we want to observe. | 33 // Parts of the ResourceDispatcherHostDelegate that we want to observe. |
| 32 void OnRequestStarted(net::URLRequest* request, | 34 void OnRequestStarted(net::URLRequest* request, |
| 33 ResourceType::Type resource_type, | 35 ResourceType::Type resource_type, |
| 34 int child_id, | 36 int child_id, |
| 35 int route_id); | 37 int route_id); |
| 36 void OnRequestRedirected(net::URLRequest* request); | 38 void OnRequestRedirected(const GURL& redirect_url, net::URLRequest* request); |
| 37 void OnResponseStarted(net::URLRequest* request); | 39 void OnResponseStarted(net::URLRequest* request); |
| 38 | 40 |
| 39 private: | 41 private: |
| 40 // Owned by profile. | 42 // Owned by profile. |
| 41 base::WeakPtr<predictors::ResourcePrefetchPredictor> predictor_; | 43 base::WeakPtr<predictors::ResourcePrefetchPredictor> predictor_; |
| 42 | 44 |
| 43 DISALLOW_COPY_AND_ASSIGN(ResourcePrefetchPredictorObserver); | 45 DISALLOW_COPY_AND_ASSIGN(ResourcePrefetchPredictorObserver); |
| 44 }; | 46 }; |
| 45 | 47 |
| 46 } // namespace chrome_browser_net | 48 } // namespace chrome_browser_net |
| 47 | 49 |
| 48 #endif // CHROME_BROWSER_NET_RESOURCE_PREFETCH_PREDICTOR_OBSERVER_H_ | 50 #endif // CHROME_BROWSER_NET_RESOURCE_PREFETCH_PREDICTOR_OBSERVER_H_ |
| OLD | NEW |