OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_NET_RESOURCE_PREFETCH_PREDICTOR_OBSERVER_H_ |
| 6 #define CHROME_BROWSER_NET_RESOURCE_PREFETCH_PREDICTOR_OBSERVER_H_ |
| 7 #pragma once |
| 8 |
| 9 #include "base/basictypes.h" |
| 10 #include "base/memory/weak_ptr.h" |
| 11 #include "chrome/browser/predictors/resource_prefetch_predictor.h" |
| 12 #include "webkit/glue/resource_type.h" |
| 13 |
| 14 namespace net { |
| 15 class URLRequest; |
| 16 } |
| 17 |
| 18 namespace chrome_browser_net { |
| 19 |
| 20 // Observes resource requests in the ResourceDispatcherHostDelegate and notifies |
| 21 // the ResourcePrefetchPredictor about the ones it is interested in. |
| 22 // - Has an instance per profile, and is owned by the corresponding |
| 23 // ProfileIOData. |
| 24 // - Needs to be constructed on UI thread. Rest of the functions can only be |
| 25 // called on the IO thread. |
| 26 class ResourcePrefetchPredictorObserver { |
| 27 public: |
| 28 explicit ResourcePrefetchPredictorObserver( |
| 29 predictors::ResourcePrefetchPredictor* predictor); |
| 30 ~ResourcePrefetchPredictorObserver(); |
| 31 |
| 32 // Parts of the ResourceDispatcherHostDelegate that we want to observe. |
| 33 void OnRequestStarted(net::URLRequest* request, |
| 34 ResourceType::Type resource_type, |
| 35 int child_id, |
| 36 int route_id); |
| 37 void OnRequestRedirected(net::URLRequest* request); |
| 38 void OnResponseStarted(net::URLRequest* request); |
| 39 |
| 40 private: |
| 41 // Owned by profile. |
| 42 base::WeakPtr<predictors::ResourcePrefetchPredictor> predictor_; |
| 43 |
| 44 DISALLOW_COPY_AND_ASSIGN(ResourcePrefetchPredictorObserver); |
| 45 }; |
| 46 |
| 47 } // namespace chrome_browser_net |
| 48 |
| 49 #endif // CHROME_BROWSER_NET_RESOURCE_PREFETCH_PREDICTOR_OBSERVER_H_ |
OLD | NEW |