| OLD | NEW |
| 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 net::OldCompletionCallback* callback, |
| 163 const net::BoundNetLog& net_log); | 163 const net::BoundNetLog& net_log) OVERRIDE; |
| 164 | 164 |
| 165 virtual int RestartIgnoringLastError(net::OldCompletionCallback* callback); | 165 virtual int RestartIgnoringLastError( |
| 166 net::OldCompletionCallback* callback) OVERRIDE; |
| 166 | 167 |
| 167 virtual int RestartWithCertificate(net::X509Certificate* client_cert, | 168 virtual int RestartWithCertificate( |
| 168 net::OldCompletionCallback* callback); | 169 net::X509Certificate* client_cert, |
| 170 net::OldCompletionCallback* callback) OVERRIDE; |
| 169 | 171 |
| 170 virtual int RestartWithAuth(const string16& username, | 172 virtual int RestartWithAuth( |
| 171 const string16& password, | 173 const net::AuthCredentials& credentials, |
| 172 net::OldCompletionCallback* callback); | 174 net::OldCompletionCallback* callback) OVERRIDE; |
| 173 | 175 |
| 174 virtual bool IsReadyToRestartForAuth(); | 176 virtual bool IsReadyToRestartForAuth() OVERRIDE; |
| 175 | 177 |
| 176 virtual int Read(net::IOBuffer* buf, int buf_len, | 178 virtual int Read(net::IOBuffer* buf, int buf_len, |
| 177 net::OldCompletionCallback* callback); | 179 net::OldCompletionCallback* callback) OVERRIDE; |
| 178 | 180 |
| 179 virtual void StopCaching(); | 181 virtual void StopCaching() OVERRIDE; |
| 180 | 182 |
| 181 virtual void DoneReading(); | 183 virtual void DoneReading() OVERRIDE; |
| 182 | 184 |
| 183 virtual const net::HttpResponseInfo* GetResponseInfo() const; | 185 virtual const net::HttpResponseInfo* GetResponseInfo() const OVERRIDE; |
| 184 | 186 |
| 185 virtual net::LoadState GetLoadState() const; | 187 virtual net::LoadState GetLoadState() const OVERRIDE; |
| 186 | 188 |
| 187 virtual uint64 GetUploadProgress() const; | 189 virtual uint64 GetUploadProgress() const OVERRIDE; |
| 188 | 190 |
| 189 private: | 191 private: |
| 190 void CallbackLater(net::OldCompletionCallback* callback, int result); | 192 void CallbackLater(net::OldCompletionCallback* callback, int result); |
| 191 void RunCallback(net::OldCompletionCallback* callback, int result); | 193 void RunCallback(net::OldCompletionCallback* callback, int result); |
| 192 | 194 |
| 193 base::WeakPtrFactory<MockNetworkTransaction> ptr_factory_; | 195 base::WeakPtrFactory<MockNetworkTransaction> ptr_factory_; |
| 194 net::HttpResponseInfo response_; | 196 net::HttpResponseInfo response_; |
| 195 std::string data_; | 197 std::string data_; |
| 196 int data_cursor_; | 198 int data_cursor_; |
| 197 int test_mode_; | 199 int test_mode_; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 218 bool done_reading_called_; | 220 bool done_reading_called_; |
| 219 }; | 221 }; |
| 220 | 222 |
| 221 //----------------------------------------------------------------------------- | 223 //----------------------------------------------------------------------------- |
| 222 // helpers | 224 // helpers |
| 223 | 225 |
| 224 // read the transaction completely | 226 // read the transaction completely |
| 225 int ReadTransaction(net::HttpTransaction* trans, std::string* result); | 227 int ReadTransaction(net::HttpTransaction* trans, std::string* result); |
| 226 | 228 |
| 227 #endif // NET_HTTP_HTTP_TRANSACTION_UNITTEST_H_ | 229 #endif // NET_HTTP_HTTP_TRANSACTION_UNITTEST_H_ |
| OLD | NEW |