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

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

Issue 7569027: net: Notify the http job and cache transaction about a filter (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « net/http/http_transaction_unittest.h ('k') | net/net.gyp » ('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) 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 #include "net/http/http_transaction_unittest.h" 5 #include "net/http/http_transaction_unittest.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 break; 205 break;
206 case READING: 206 case READING:
207 DidRead(result); 207 DidRead(result);
208 break; 208 break;
209 default: 209 default:
210 NOTREACHED(); 210 NOTREACHED();
211 } 211 }
212 } 212 }
213 213
214 214
215 MockNetworkTransaction::MockNetworkTransaction() : 215 MockNetworkTransaction::MockNetworkTransaction(MockNetworkLayer* factory)
216 ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)), data_cursor_(0) { 216 : ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)),
217 data_cursor_(0),
218 transaction_factory_(factory->AsWeakPtr()) {
217 } 219 }
218 220
219 MockNetworkTransaction::~MockNetworkTransaction() {} 221 MockNetworkTransaction::~MockNetworkTransaction() {}
220 222
221 int MockNetworkTransaction::Start(const net::HttpRequestInfo* request, 223 int MockNetworkTransaction::Start(const net::HttpRequestInfo* request,
222 net::CompletionCallback* callback, 224 net::CompletionCallback* callback,
223 const net::BoundNetLog& net_log) { 225 const net::BoundNetLog& net_log) {
224 const MockTransaction* t = FindMockTransaction(request->url); 226 const MockTransaction* t = FindMockTransaction(request->url);
225 if (!t) 227 if (!t)
226 return net::ERR_FAILED; 228 return net::ERR_FAILED;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 } 290 }
289 if (test_mode_ & TEST_MODE_SYNC_NET_READ) 291 if (test_mode_ & TEST_MODE_SYNC_NET_READ)
290 return num; 292 return num;
291 293
292 CallbackLater(callback, num); 294 CallbackLater(callback, num);
293 return net::ERR_IO_PENDING; 295 return net::ERR_IO_PENDING;
294 } 296 }
295 297
296 void MockNetworkTransaction::StopCaching() {} 298 void MockNetworkTransaction::StopCaching() {}
297 299
300 void MockNetworkTransaction::DoneReading() {
301 if (transaction_factory_)
302 transaction_factory_->TransactionDoneReading();
303 }
304
298 const net::HttpResponseInfo* MockNetworkTransaction::GetResponseInfo() const { 305 const net::HttpResponseInfo* MockNetworkTransaction::GetResponseInfo() const {
299 return &response_; 306 return &response_;
300 } 307 }
301 308
302 net::LoadState MockNetworkTransaction::GetLoadState() const { 309 net::LoadState MockNetworkTransaction::GetLoadState() const {
303 if (data_cursor_) 310 if (data_cursor_)
304 return net::LOAD_STATE_READING_RESPONSE; 311 return net::LOAD_STATE_READING_RESPONSE;
305 return net::LOAD_STATE_IDLE; 312 return net::LOAD_STATE_IDLE;
306 } 313 }
307 314
308 uint64 MockNetworkTransaction::GetUploadProgress() const { 315 uint64 MockNetworkTransaction::GetUploadProgress() const {
309 return 0; 316 return 0;
310 } 317 }
311 318
312 void MockNetworkTransaction::CallbackLater(net::CompletionCallback* callback, 319 void MockNetworkTransaction::CallbackLater(net::CompletionCallback* callback,
313 int result) { 320 int result) {
314 MessageLoop::current()->PostTask(FROM_HERE, task_factory_.NewRunnableMethod( 321 MessageLoop::current()->PostTask(FROM_HERE, task_factory_.NewRunnableMethod(
315 &MockNetworkTransaction::RunCallback, callback, result)); 322 &MockNetworkTransaction::RunCallback, callback, result));
316 } 323 }
317 324
318 void MockNetworkTransaction::RunCallback(net::CompletionCallback* callback, 325 void MockNetworkTransaction::RunCallback(net::CompletionCallback* callback,
319 int result) { 326 int result) {
320 callback->Run(result); 327 callback->Run(result);
321 } 328 }
322 329
323 MockNetworkLayer::MockNetworkLayer() : transaction_count_(0) {} 330 MockNetworkLayer::MockNetworkLayer()
331 : transaction_count_(0), done_reading_called_(false) {}
324 332
325 MockNetworkLayer::~MockNetworkLayer() {} 333 MockNetworkLayer::~MockNetworkLayer() {}
326 334
335 void MockNetworkLayer::TransactionDoneReading() {
336 done_reading_called_ = true;
337 }
338
327 int MockNetworkLayer::CreateTransaction( 339 int MockNetworkLayer::CreateTransaction(
328 scoped_ptr<net::HttpTransaction>* trans) { 340 scoped_ptr<net::HttpTransaction>* trans) {
329 transaction_count_++; 341 transaction_count_++;
330 trans->reset(new MockNetworkTransaction()); 342 trans->reset(new MockNetworkTransaction(this));
331 return net::OK; 343 return net::OK;
332 } 344 }
333 345
334 net::HttpCache* MockNetworkLayer::GetCache() { 346 net::HttpCache* MockNetworkLayer::GetCache() {
335 return NULL; 347 return NULL;
336 } 348 }
337 349
338 net::HttpNetworkSession* MockNetworkLayer::GetSession() { 350 net::HttpNetworkSession* MockNetworkLayer::GetSession() {
339 return NULL; 351 return NULL;
340 } 352 }
(...skipping 15 matching lines...) Expand all
356 if (rv > 0) { 368 if (rv > 0) {
357 content.append(buf->data(), rv); 369 content.append(buf->data(), rv);
358 } else if (rv < 0) { 370 } else if (rv < 0) {
359 return rv; 371 return rv;
360 } 372 }
361 } while (rv > 0); 373 } while (rv > 0);
362 374
363 result->swap(content); 375 result->swap(content);
364 return net::OK; 376 return net::OK;
365 } 377 }
OLDNEW
« no previous file with comments | « net/http/http_transaction_unittest.h ('k') | net/net.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698