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

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

Issue 267793002: net: Avoid recursion in URLRequestJob::ReadFilteredData. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 6 years, 7 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/url_request/url_request_job.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) 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 #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/bind.h" 9 #include "base/bind.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 return false; 278 return false;
279 279
280 // Only mock auth when the test asks for it. 280 // Only mock auth when the test asks for it.
281 return request_->extra_headers.HasHeader("X-Require-Mock-Auth"); 281 return request_->extra_headers.HasHeader("X-Require-Mock-Auth");
282 } 282 }
283 283
284 int MockNetworkTransaction::Read(net::IOBuffer* buf, int buf_len, 284 int MockNetworkTransaction::Read(net::IOBuffer* buf, int buf_len,
285 const net::CompletionCallback& callback) { 285 const net::CompletionCallback& callback) {
286 int data_len = static_cast<int>(data_.size()); 286 int data_len = static_cast<int>(data_.size());
287 int num = std::min(buf_len, data_len - data_cursor_); 287 int num = std::min(buf_len, data_len - data_cursor_);
288 if (test_mode_ & TEST_MODE_SLOW_READ)
289 num = std::min(num, 1);
288 if (num) { 290 if (num) {
289 memcpy(buf->data(), data_.data() + data_cursor_, num); 291 memcpy(buf->data(), data_.data() + data_cursor_, num);
290 data_cursor_ += num; 292 data_cursor_ += num;
291 } 293 }
292 if (test_mode_ & TEST_MODE_SYNC_NET_READ) 294 if (test_mode_ & TEST_MODE_SYNC_NET_READ)
293 return num; 295 return num;
294 296
295 CallbackLater(callback, num); 297 CallbackLater(callback, num);
296 return net::ERR_IO_PENDING; 298 return net::ERR_IO_PENDING;
297 } 299 }
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 494
493 if (rv > 0) 495 if (rv > 0)
494 content.append(buf->data(), rv); 496 content.append(buf->data(), rv);
495 else if (rv < 0) 497 else if (rv < 0)
496 return rv; 498 return rv;
497 } while (rv > 0); 499 } while (rv > 0);
498 500
499 result->swap(content); 501 result->swap(content);
500 return net::OK; 502 return net::OK;
501 } 503 }
OLDNEW
« no previous file with comments | « net/http/http_transaction_unittest.h ('k') | net/url_request/url_request_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698