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

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

Issue 4037: Some platform cleanup to net/ (Closed)
Patch Set: Created 12 years, 3 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
« no previous file with comments | « src/net/http/http_cache_unittest.cc ('k') | src/net/http/http_transaction_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 <windows.h>
11
12 #include <string> 10 #include <string>
13 11
12 #include "base/compiler_specific.h"
14 #include "base/message_loop.h" 13 #include "base/message_loop.h"
15 #include "base/string_util.h" 14 #include "base/string_util.h"
16 #include "net/base/net_errors.h" 15 #include "net/base/net_errors.h"
17 #include "net/base/load_flags.h" 16 #include "net/base/load_flags.h"
18 #include "net/base/test_completion_callback.h" 17 #include "net/base/test_completion_callback.h"
19 #include "net/disk_cache/disk_cache.h" 18 #include "net/disk_cache/disk_cache.h"
20 #include "net/http/http_cache.h" 19 #include "net/http/http_cache.h"
21 #include "net/http/http_request_info.h" 20 #include "net/http/http_request_info.h"
22 #include "net/http/http_response_info.h" 21 #include "net/http/http_response_info.h"
23 22
24 #pragma warning(disable: 4355)
25
26 //----------------------------------------------------------------------------- 23 //-----------------------------------------------------------------------------
27 // mock transaction data 24 // mock transaction data
28 25
29 // these flags may be combined to form the test_mode field 26 // these flags may be combined to form the test_mode field
30 enum { 27 enum {
31 TEST_MODE_NORMAL = 0, 28 TEST_MODE_NORMAL = 0,
32 TEST_MODE_SYNC_NET_START = 1 << 0, 29 TEST_MODE_SYNC_NET_START = 1 << 0,
33 TEST_MODE_SYNC_NET_READ = 1 << 1, 30 TEST_MODE_SYNC_NET_READ = 1 << 1,
34 TEST_MODE_SYNC_CACHE_START = 1 << 2, 31 TEST_MODE_SYNC_CACHE_START = 1 << 2,
35 TEST_MODE_SYNC_CACHE_READ = 1 << 3, 32 TEST_MODE_SYNC_CACHE_READ = 1 << 3,
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 load_flags = t.load_flags; 89 load_flags = t.load_flags;
93 } 90 }
94 }; 91 };
95 92
96 //----------------------------------------------------------------------------- 93 //-----------------------------------------------------------------------------
97 // use this class to test completely consuming a transaction 94 // use this class to test completely consuming a transaction
98 95
99 class TestTransactionConsumer : public CallbackRunner< Tuple1<int> > { 96 class TestTransactionConsumer : public CallbackRunner< Tuple1<int> > {
100 public: 97 public:
101 explicit TestTransactionConsumer(net::HttpTransactionFactory* factory) 98 explicit TestTransactionConsumer(net::HttpTransactionFactory* factory)
102 : trans_(factory->CreateTransaction()), 99 : state_(IDLE),
103 state_(IDLE), 100 trans_(factory->CreateTransaction()),
104 error_(net::OK) { 101 error_(net::OK) {
105 ++quit_counter_; 102 ++quit_counter_;
106 } 103 }
107 104
108 ~TestTransactionConsumer() { 105 ~TestTransactionConsumer() {
109 trans_->Destroy(); 106 trans_->Destroy();
110 } 107 }
111 108
112 void Start(const net::HttpRequestInfo* request) { 109 void Start(const net::HttpRequestInfo* request) {
113 state_ = STARTING; 110 state_ = STARTING;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 185
189 //----------------------------------------------------------------------------- 186 //-----------------------------------------------------------------------------
190 // mock network layer 187 // mock network layer
191 188
192 // This transaction class inspects the available set of mock transactions to 189 // This transaction class inspects the available set of mock transactions to
193 // find data for the request URL. It supports IO operations that complete 190 // find data for the request URL. It supports IO operations that complete
194 // synchronously or asynchronously to help exercise different code paths in the 191 // synchronously or asynchronously to help exercise different code paths in the
195 // HttpCache implementation. 192 // HttpCache implementation.
196 class MockNetworkTransaction : public net::HttpTransaction { 193 class MockNetworkTransaction : public net::HttpTransaction {
197 public: 194 public:
198 MockNetworkTransaction() : task_factory_(this), data_cursor_(0) { 195 MockNetworkTransaction() :
196 ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)), data_cursor_(0) {
199 } 197 }
200 198
201 virtual void Destroy() { 199 virtual void Destroy() {
202 delete this; 200 delete this;
203 } 201 }
204 202
205 virtual int Start(const net::HttpRequestInfo* request, 203 virtual int Start(const net::HttpRequestInfo* request,
206 net::CompletionCallback* callback) { 204 net::CompletionCallback* callback) {
207 const MockTransaction* t = FindMockTransaction(request->url); 205 const MockTransaction* t = FindMockTransaction(request->url);
208 if (!t) 206 if (!t)
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 }; 310 };
313 311
314 312
315 //----------------------------------------------------------------------------- 313 //-----------------------------------------------------------------------------
316 // helpers 314 // helpers
317 315
318 // read the transaction completely 316 // read the transaction completely
319 int ReadTransaction(net::HttpTransaction* trans, std::string* result); 317 int ReadTransaction(net::HttpTransaction* trans, std::string* result);
320 318
321 #endif // NET_HTTP_HTTP_TRANSACTION_UNITTEST_H_ 319 #endif // NET_HTTP_HTTP_TRANSACTION_UNITTEST_H_
OLDNEW
« no previous file with comments | « src/net/http/http_cache_unittest.cc ('k') | src/net/http/http_transaction_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698