Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Side by Side Diff: chrome/browser/net/resource_prefetch_predictor_observer.h

Issue 2545943003: Accessing navigation information via webcontents (Closed)
Patch Set: Post-Review Modifications #3 Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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 <memory>
9
8 #include "base/macros.h" 10 #include "base/macros.h"
9 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
10 #include "chrome/browser/predictors/resource_prefetch_predictor.h" 12 #include "chrome/browser/predictors/resource_prefetch_predictor.h"
13 #include "content/public/browser/resource_request_info.h"
11 #include "content/public/common/resource_type.h" 14 #include "content/public/common/resource_type.h"
12 15
13 namespace net { 16 namespace net {
14 class URLRequest; 17 class URLRequest;
15 } 18 }
16 19
17 class GURL; 20 class GURL;
18 21
19 namespace chrome_browser_net { 22 namespace chrome_browser_net {
20 23
21 // Observes resource requests in the ResourceDispatcherHostDelegate and notifies 24 // Observes resource requests in the ResourceDispatcherHostDelegate and notifies
22 // the ResourcePrefetchPredictor about the ones it is interested in. 25 // the ResourcePrefetchPredictor about the ones it is interested in.
23 // - Has an instance per profile, and is owned by the corresponding 26 // - Has an instance per profile, and is owned by the corresponding
24 // ProfileIOData. 27 // ProfileIOData.
25 // - Needs to be constructed on UI thread. Rest of the functions can only be 28 // - Needs to be constructed on UI thread. Can be destroyed on UI or IO thread.
26 // called on the IO 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 // thread and private members from the UI thread.
27 class ResourcePrefetchPredictorObserver { 31 class ResourcePrefetchPredictorObserver {
28 public: 32 public:
29 explicit ResourcePrefetchPredictorObserver( 33 explicit ResourcePrefetchPredictorObserver(
30 predictors::ResourcePrefetchPredictor* predictor); 34 predictors::ResourcePrefetchPredictor* predictor);
31 ~ResourcePrefetchPredictorObserver(); 35 ~ResourcePrefetchPredictorObserver();
32 36
33 // Parts of the ResourceDispatcherHostDelegate that we want to observe. 37 // Parts of the ResourceDispatcherHostDelegate that we want to observe.
34 void OnRequestStarted(net::URLRequest* request, 38 void OnRequestStarted(net::URLRequest* request,
35 content::ResourceType resource_type, 39 content::ResourceType resource_type,
36 int child_id, 40 const content::ResourceRequestInfo::WebContentsGetter&
37 int frame_id); 41 web_contents_getter);
38 void OnRequestRedirected(const GURL& redirect_url, net::URLRequest* request); 42 void OnRequestRedirected(
39 void OnResponseStarted(net::URLRequest* request); 43 net::URLRequest* request,
44 const GURL& redirect_url,
45 const content::ResourceRequestInfo::WebContentsGetter&
46 web_contents_getter);
47 void OnResponseStarted(net::URLRequest* request,
48 const content::ResourceRequestInfo::WebContentsGetter&
49 web_contents_getter);
40 50
41 private: 51 private:
52 void OnRequestStartedOnUIThread(
53 std::unique_ptr<predictors::ResourcePrefetchPredictor::URLRequestSummary>
54 summary,
55 const content::ResourceRequestInfo::WebContentsGetter&
56 web_contents_getter,
57 const GURL& main_frame_url,
58 const base::TimeTicks& creation_time) const;
59 void OnRequestRedirectedOnUIThread(
60 std::unique_ptr<predictors::ResourcePrefetchPredictor::URLRequestSummary>
61 summary,
62 const content::ResourceRequestInfo::WebContentsGetter&
63 web_contents_getter,
64 const GURL& main_frame_url,
65 const base::TimeTicks& creation_time) const;
66 void OnResponseStartedOnUIThread(
67 std::unique_ptr<predictors::ResourcePrefetchPredictor::URLRequestSummary>
68 summary,
69 const content::ResourceRequestInfo::WebContentsGetter&
70 web_contents_getter,
71 const GURL& main_frame_url,
72 const base::TimeTicks& creation_time) const;
73
42 // Owned by profile. 74 // Owned by profile.
43 base::WeakPtr<predictors::ResourcePrefetchPredictor> predictor_; 75 base::WeakPtr<predictors::ResourcePrefetchPredictor> predictor_;
44 76
45 DISALLOW_COPY_AND_ASSIGN(ResourcePrefetchPredictorObserver); 77 DISALLOW_COPY_AND_ASSIGN(ResourcePrefetchPredictorObserver);
46 }; 78 };
47 79
48 } // namespace chrome_browser_net 80 } // namespace chrome_browser_net
49 81
50 #endif // CHROME_BROWSER_NET_RESOURCE_PREFETCH_PREDICTOR_OBSERVER_H_ 82 #endif // CHROME_BROWSER_NET_RESOURCE_PREFETCH_PREDICTOR_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698