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

Side by Side Diff: net/http/http_transaction_unittest.h

Issue 12701011: [Net] Propagate priority changes from URLRequest to HttpTransaction (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 7 years, 9 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 (c) 2012 The Chromium Authors. All rights reserved. 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 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 NET_HTTP_HTTP_TRANSACTION_UNITTEST_H_ 5 #ifndef NET_HTTP_HTTP_TRANSACTION_UNITTEST_H_
6 #define NET_HTTP_HTTP_TRANSACTION_UNITTEST_H_ 6 #define NET_HTTP_HTTP_TRANSACTION_UNITTEST_H_
7 7
8 #include "net/http/http_transaction.h" 8 #include "net/http/http_transaction.h"
9 9
10 #include <string> 10 #include <string>
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 185
186 virtual const net::HttpResponseInfo* GetResponseInfo() const OVERRIDE; 186 virtual const net::HttpResponseInfo* GetResponseInfo() const OVERRIDE;
187 187
188 virtual net::LoadState GetLoadState() const OVERRIDE; 188 virtual net::LoadState GetLoadState() const OVERRIDE;
189 189
190 virtual net::UploadProgress GetUploadProgress() const OVERRIDE; 190 virtual net::UploadProgress GetUploadProgress() const OVERRIDE;
191 191
192 virtual bool GetLoadTimingInfo( 192 virtual bool GetLoadTimingInfo(
193 net::LoadTimingInfo* load_timing_info) const OVERRIDE; 193 net::LoadTimingInfo* load_timing_info) const OVERRIDE;
194 194
195 virtual void SetPriority(net::RequestPriority priority) OVERRIDE;
196
197 net::RequestPriority priority() const { return priority_; }
198
195 private: 199 private:
196 void CallbackLater(const net::CompletionCallback& callback, int result); 200 void CallbackLater(const net::CompletionCallback& callback, int result);
197 void RunCallback(const net::CompletionCallback& callback, int result); 201 void RunCallback(const net::CompletionCallback& callback, int result);
198 202
199 base::WeakPtrFactory<MockNetworkTransaction> weak_factory_; 203 base::WeakPtrFactory<MockNetworkTransaction> weak_factory_;
200 net::HttpResponseInfo response_; 204 net::HttpResponseInfo response_;
201 std::string data_; 205 std::string data_;
202 int data_cursor_; 206 int data_cursor_;
203 int test_mode_; 207 int test_mode_;
208 net::RequestPriority priority_;
204 base::WeakPtr<MockNetworkLayer> transaction_factory_; 209 base::WeakPtr<MockNetworkLayer> transaction_factory_;
205 }; 210 };
206 211
207 class MockNetworkLayer : public net::HttpTransactionFactory, 212 class MockNetworkLayer : public net::HttpTransactionFactory,
208 public base::SupportsWeakPtr<MockNetworkLayer> { 213 public base::SupportsWeakPtr<MockNetworkLayer> {
209 public: 214 public:
210 MockNetworkLayer(); 215 MockNetworkLayer();
211 virtual ~MockNetworkLayer(); 216 virtual ~MockNetworkLayer();
212 217
213 int transaction_count() const { return transaction_count_; } 218 int transaction_count() const { return transaction_count_; }
214 bool done_reading_called() const { return done_reading_called_; } 219 bool done_reading_called() const { return done_reading_called_; }
215 void TransactionDoneReading(); 220 void TransactionDoneReading();
216 221
222 // Returns the last transaction created by CreateTransaction, or
223 // NULL if one has not been created yet. It is the caller's
224 // responsibility to make sure that that transaction is still valid.
225 MockNetworkTransaction* last_transaction() {
226 return last_transaction_;
227 }
228
229 // Makes last_transaction() return NULL until the next transaction
230 // is created.
231 void ClearLastTransaction() {
232 last_transaction_ = NULL;
233 }
234
217 // net::HttpTransactionFactory: 235 // net::HttpTransactionFactory:
218 virtual int CreateTransaction( 236 virtual int CreateTransaction(
219 net::RequestPriority priority, 237 net::RequestPriority priority,
220 scoped_ptr<net::HttpTransaction>* trans, 238 scoped_ptr<net::HttpTransaction>* trans,
221 net::HttpTransactionDelegate* delegate) OVERRIDE; 239 net::HttpTransactionDelegate* delegate) OVERRIDE;
222 virtual net::HttpCache* GetCache() OVERRIDE; 240 virtual net::HttpCache* GetCache() OVERRIDE;
223 virtual net::HttpNetworkSession* GetSession() OVERRIDE; 241 virtual net::HttpNetworkSession* GetSession() OVERRIDE;
224 242
225 private: 243 private:
226 int transaction_count_; 244 int transaction_count_;
227 bool done_reading_called_; 245 bool done_reading_called_;
246 MockNetworkTransaction* last_transaction_;
228 }; 247 };
229 248
230 //----------------------------------------------------------------------------- 249 //-----------------------------------------------------------------------------
231 // helpers 250 // helpers
232 251
233 // read the transaction completely 252 // read the transaction completely
234 int ReadTransaction(net::HttpTransaction* trans, std::string* result); 253 int ReadTransaction(net::HttpTransaction* trans, std::string* result);
235 254
236 #endif // NET_HTTP_HTTP_TRANSACTION_UNITTEST_H_ 255 #endif // NET_HTTP_HTTP_TRANSACTION_UNITTEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698