| OLD | NEW |
| (Empty) |
| 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 | |
| 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 | |
| 8 #include "base/basictypes.h" | |
| 9 #include "base/memory/weak_ptr.h" | |
| 10 #include "chrome/browser/predictors/resource_prefetch_predictor.h" | |
| 11 #include "content/public/common/resource_type.h" | |
| 12 | |
| 13 namespace net { | |
| 14 class URLRequest; | |
| 15 } | |
| 16 | |
| 17 class GURL; | |
| 18 | |
| 19 namespace chrome_browser_net { | |
| 20 | |
| 21 // Observes resource requests in the ResourceDispatcherHostDelegate and notifies | |
| 22 // the ResourcePrefetchPredictor about the ones it is interested in. | |
| 23 // - Has an instance per profile, and is owned by the corresponding | |
| 24 // ProfileIOData. | |
| 25 // - 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 class ResourcePrefetchPredictorObserver { | |
| 28 public: | |
| 29 explicit ResourcePrefetchPredictorObserver( | |
| 30 predictors::ResourcePrefetchPredictor* predictor); | |
| 31 ~ResourcePrefetchPredictorObserver(); | |
| 32 | |
| 33 // Parts of the ResourceDispatcherHostDelegate that we want to observe. | |
| 34 void OnRequestStarted(net::URLRequest* request, | |
| 35 content::ResourceType resource_type, | |
| 36 int child_id, | |
| 37 int frame_id); | |
| 38 void OnRequestRedirected(const GURL& redirect_url, net::URLRequest* request); | |
| 39 void OnResponseStarted(net::URLRequest* request); | |
| 40 | |
| 41 private: | |
| 42 // Owned by profile. | |
| 43 base::WeakPtr<predictors::ResourcePrefetchPredictor> predictor_; | |
| 44 | |
| 45 DISALLOW_COPY_AND_ASSIGN(ResourcePrefetchPredictorObserver); | |
| 46 }; | |
| 47 | |
| 48 } // namespace chrome_browser_net | |
| 49 | |
| 50 #endif // CHROME_BROWSER_NET_RESOURCE_PREFETCH_PREDICTOR_OBSERVER_H_ | |
| OLD | NEW |