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

Side by Side Diff: chrome/browser/predictors/resource_prefetcher.h

Issue 648653003: Standardize usage of virtual/override/final in chrome/browser/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months 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_PREDICTORS_RESOURCE_PREFETCHER_H_ 5 #ifndef CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCHER_H_
6 #define CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCHER_H_ 6 #define CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCHER_H_
7 7
8 #include <list> 8 #include <list>
9 #include <map> 9 #include <map>
10 #include <vector> 10 #include <vector>
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 virtual net::URLRequestContext* GetURLRequestContext() = 0; 82 virtual net::URLRequestContext* GetURLRequestContext() = 0;
83 }; 83 };
84 84
85 // |delegate| has to outlive the ResourcePrefetcher. The ResourcePrefetcher 85 // |delegate| has to outlive the ResourcePrefetcher. The ResourcePrefetcher
86 // takes ownership of |requests|. 86 // takes ownership of |requests|.
87 ResourcePrefetcher(Delegate* delegate, 87 ResourcePrefetcher(Delegate* delegate,
88 const ResourcePrefetchPredictorConfig& config, 88 const ResourcePrefetchPredictorConfig& config,
89 const NavigationID& navigation_id, 89 const NavigationID& navigation_id,
90 PrefetchKeyType key_type, 90 PrefetchKeyType key_type,
91 scoped_ptr<RequestVector> requests); 91 scoped_ptr<RequestVector> requests);
92 virtual ~ResourcePrefetcher(); 92 ~ResourcePrefetcher() override;
93 93
94 void Start(); // Kicks off the prefetching. Can only be called once. 94 void Start(); // Kicks off the prefetching. Can only be called once.
95 void Stop(); // No additional prefetches will be queued after this. 95 void Stop(); // No additional prefetches will be queued after this.
96 96
97 const NavigationID& navigation_id() const { return navigation_id_; } 97 const NavigationID& navigation_id() const { return navigation_id_; }
98 PrefetchKeyType key_type() const { return key_type_; } 98 PrefetchKeyType key_type() const { return key_type_; }
99 99
100 private: 100 private:
101 friend class ResourcePrefetcherTest; 101 friend class ResourcePrefetcherTest;
102 friend class TestResourcePrefetcher; 102 friend class TestResourcePrefetcher;
(...skipping 13 matching lines...) Expand all
116 116
117 // Reads the response data from the response - required for the resource to 117 // Reads the response data from the response - required for the resource to
118 // be cached correctly. Stubbed out during testing. 118 // be cached correctly. Stubbed out during testing.
119 virtual void ReadFullResponse(net::URLRequest* request); 119 virtual void ReadFullResponse(net::URLRequest* request);
120 120
121 // Returns true if the request has more data that needs to be read. If it 121 // Returns true if the request has more data that needs to be read. If it
122 // returns false, the request should not be referenced again. 122 // returns false, the request should not be referenced again.
123 bool ShouldContinueReadingRequest(net::URLRequest* request, int bytes_read); 123 bool ShouldContinueReadingRequest(net::URLRequest* request, int bytes_read);
124 124
125 // net::URLRequest::Delegate methods. 125 // net::URLRequest::Delegate methods.
126 virtual void OnReceivedRedirect(net::URLRequest* request, 126 void OnReceivedRedirect(net::URLRequest* request,
127 const net::RedirectInfo& redirect_info, 127 const net::RedirectInfo& redirect_info,
128 bool* defer_redirect) override; 128 bool* defer_redirect) override;
129 virtual void OnAuthRequired(net::URLRequest* request, 129 void OnAuthRequired(net::URLRequest* request,
130 net::AuthChallengeInfo* auth_info) override; 130 net::AuthChallengeInfo* auth_info) override;
131 virtual void OnCertificateRequested( 131 void OnCertificateRequested(
132 net::URLRequest* request, 132 net::URLRequest* request,
133 net::SSLCertRequestInfo* cert_request_info) override; 133 net::SSLCertRequestInfo* cert_request_info) override;
134 virtual void OnSSLCertificateError(net::URLRequest* request, 134 void OnSSLCertificateError(net::URLRequest* request,
135 const net::SSLInfo& ssl_info, 135 const net::SSLInfo& ssl_info,
136 bool fatal) override; 136 bool fatal) override;
137 virtual void OnResponseStarted(net::URLRequest* request) override; 137 void OnResponseStarted(net::URLRequest* request) override;
138 virtual void OnReadCompleted(net::URLRequest* request, 138 void OnReadCompleted(net::URLRequest* request, int bytes_read) override;
139 int bytes_read) override;
140 139
141 enum PrefetcherState { 140 enum PrefetcherState {
142 INITIALIZED = 0, // Prefetching hasn't started. 141 INITIALIZED = 0, // Prefetching hasn't started.
143 RUNNING = 1, // Prefetching started, allowed to add more requests. 142 RUNNING = 1, // Prefetching started, allowed to add more requests.
144 STOPPED = 2, // Prefetching started, not allowed to add more requests. 143 STOPPED = 2, // Prefetching started, not allowed to add more requests.
145 FINISHED = 3 // No more inflight request, new requests not possible. 144 FINISHED = 3 // No more inflight request, new requests not possible.
146 }; 145 };
147 146
148 base::ThreadChecker thread_checker_; 147 base::ThreadChecker thread_checker_;
149 PrefetcherState state_; 148 PrefetcherState state_;
150 Delegate* const delegate_; 149 Delegate* const delegate_;
151 ResourcePrefetchPredictorConfig const config_; 150 ResourcePrefetchPredictorConfig const config_;
152 NavigationID navigation_id_; 151 NavigationID navigation_id_;
153 PrefetchKeyType key_type_; 152 PrefetchKeyType key_type_;
154 scoped_ptr<RequestVector> request_vector_; 153 scoped_ptr<RequestVector> request_vector_;
155 154
156 std::map<net::URLRequest*, Request*> inflight_requests_; 155 std::map<net::URLRequest*, Request*> inflight_requests_;
157 std::list<Request*> request_queue_; 156 std::list<Request*> request_queue_;
158 std::map<std::string, size_t> host_inflight_counts_; 157 std::map<std::string, size_t> host_inflight_counts_;
159 158
160 DISALLOW_COPY_AND_ASSIGN(ResourcePrefetcher); 159 DISALLOW_COPY_AND_ASSIGN(ResourcePrefetcher);
161 }; 160 };
162 161
163 } // namespace predictors 162 } // namespace predictors
164 163
165 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCHER_H_ 164 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698