Only grant permissions to new extensions from sync if they have the expected version
[chromium-blink-merge.git] / chrome / browser / net / resource_prefetch_predictor_observer.h
blobe2fd480395cb666c22b9ef8eadb7f939f972339d
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.
5 #ifndef CHROME_BROWSER_NET_RESOURCE_PREFETCH_PREDICTOR_OBSERVER_H_
6 #define CHROME_BROWSER_NET_RESOURCE_PREFETCH_PREDICTOR_OBSERVER_H_
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"
13 namespace net {
14 class URLRequest;
17 class GURL;
19 namespace chrome_browser_net {
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();
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);
41 private:
42 // Owned by profile.
43 base::WeakPtr<predictors::ResourcePrefetchPredictor> predictor_;
45 DISALLOW_COPY_AND_ASSIGN(ResourcePrefetchPredictorObserver);
48 } // namespace chrome_browser_net
50 #endif // CHROME_BROWSER_NET_RESOURCE_PREFETCH_PREDICTOR_OBSERVER_H_