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

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

Issue 8990001: base::Bind: Convert most of net/http. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Clang. Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #pragma once 7 #pragma once
8 8
9 #include "net/http/http_transaction.h" 9 #include "net/http/http_transaction.h"
10 10
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 // This transaction class inspects the available set of mock transactions to 152 // This transaction class inspects the available set of mock transactions to
153 // find data for the request URL. It supports IO operations that complete 153 // find data for the request URL. It supports IO operations that complete
154 // synchronously or asynchronously to help exercise different code paths in the 154 // synchronously or asynchronously to help exercise different code paths in the
155 // HttpCache implementation. 155 // HttpCache implementation.
156 class MockNetworkTransaction : public net::HttpTransaction { 156 class MockNetworkTransaction : public net::HttpTransaction {
157 public: 157 public:
158 explicit MockNetworkTransaction(MockNetworkLayer* factory); 158 explicit MockNetworkTransaction(MockNetworkLayer* factory);
159 virtual ~MockNetworkTransaction(); 159 virtual ~MockNetworkTransaction();
160 160
161 virtual int Start(const net::HttpRequestInfo* request, 161 virtual int Start(const net::HttpRequestInfo* request,
162 net::OldCompletionCallback* callback, 162 const net::CompletionCallback& callback,
163 const net::BoundNetLog& net_log) OVERRIDE; 163 const net::BoundNetLog& net_log) OVERRIDE;
164 164
165 virtual int RestartIgnoringLastError( 165 virtual int RestartIgnoringLastError(
166 net::OldCompletionCallback* callback) OVERRIDE; 166 const net::CompletionCallback& callback) OVERRIDE;
167 167
168 virtual int RestartWithCertificate( 168 virtual int RestartWithCertificate(
169 net::X509Certificate* client_cert, 169 net::X509Certificate* client_cert,
170 net::OldCompletionCallback* callback) OVERRIDE; 170 const net::CompletionCallback& callback) OVERRIDE;
171 171
172 virtual int RestartWithAuth( 172 virtual int RestartWithAuth(
173 const net::AuthCredentials& credentials, 173 const net::AuthCredentials& credentials,
174 net::OldCompletionCallback* callback) OVERRIDE; 174 const net::CompletionCallback& callback) OVERRIDE;
175 175
176 virtual bool IsReadyToRestartForAuth() OVERRIDE; 176 virtual bool IsReadyToRestartForAuth() OVERRIDE;
177 177
178 virtual int Read(net::IOBuffer* buf, int buf_len, 178 virtual int Read(net::IOBuffer* buf, int buf_len,
179 net::OldCompletionCallback* callback) OVERRIDE; 179 const net::CompletionCallback& callback) OVERRIDE;
180 180
181 virtual void StopCaching() OVERRIDE; 181 virtual void StopCaching() OVERRIDE;
182 182
183 virtual void DoneReading() OVERRIDE; 183 virtual void DoneReading() OVERRIDE;
184 184
185 virtual const net::HttpResponseInfo* GetResponseInfo() const OVERRIDE; 185 virtual const net::HttpResponseInfo* GetResponseInfo() const OVERRIDE;
186 186
187 virtual net::LoadState GetLoadState() const OVERRIDE; 187 virtual net::LoadState GetLoadState() const OVERRIDE;
188 188
189 virtual uint64 GetUploadProgress() const OVERRIDE; 189 virtual uint64 GetUploadProgress() const OVERRIDE;
190 190
191 private: 191 private:
192 void CallbackLater(net::OldCompletionCallback* callback, int result); 192 void CallbackLater(const net::CompletionCallback& callback, int result);
193 void RunCallback(net::OldCompletionCallback* callback, int result); 193 void RunCallback(const net::CompletionCallback& callback, int result);
194 194
195 base::WeakPtrFactory<MockNetworkTransaction> ptr_factory_; 195 base::WeakPtrFactory<MockNetworkTransaction> weak_factory_;
196 net::HttpResponseInfo response_; 196 net::HttpResponseInfo response_;
197 std::string data_; 197 std::string data_;
198 int data_cursor_; 198 int data_cursor_;
199 int test_mode_; 199 int test_mode_;
200 base::WeakPtr<MockNetworkLayer> transaction_factory_; 200 base::WeakPtr<MockNetworkLayer> transaction_factory_;
201 }; 201 };
202 202
203 class MockNetworkLayer : public net::HttpTransactionFactory, 203 class MockNetworkLayer : public net::HttpTransactionFactory,
204 public base::SupportsWeakPtr<MockNetworkLayer> { 204 public base::SupportsWeakPtr<MockNetworkLayer> {
205 public: 205 public:
(...skipping 15 matching lines...) Expand all
221 bool done_reading_called_; 221 bool done_reading_called_;
222 }; 222 };
223 223
224 //----------------------------------------------------------------------------- 224 //-----------------------------------------------------------------------------
225 // helpers 225 // helpers
226 226
227 // read the transaction completely 227 // read the transaction completely
228 int ReadTransaction(net::HttpTransaction* trans, std::string* result); 228 int ReadTransaction(net::HttpTransaction* trans, std::string* result);
229 229
230 #endif // NET_HTTP_HTTP_TRANSACTION_UNITTEST_H_ 230 #endif // NET_HTTP_HTTP_TRANSACTION_UNITTEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698