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

Side by Side Diff: content/browser/net/url_request_abort_on_end_job.cc

Issue 8540011: Fix URLRequestJobAbortOnEndJob::ReadRawData (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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 | « no previous file | no next file » | 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 // This class simulates what wininet does when a dns lookup fails. 4 // This class simulates what wininet does when a dns lookup fails.
5 5
6 #include <algorithm> 6 #include <algorithm>
7 #include <cstring> 7 #include <cstring>
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 MessageLoop::current()->PostTask( 83 MessageLoop::current()->PostTask(
84 FROM_HERE, 84 FROM_HERE,
85 base::Bind(&URLRequestAbortOnEndJob::StartAsync, 85 base::Bind(&URLRequestAbortOnEndJob::StartAsync,
86 weak_factory_.GetWeakPtr())); 86 weak_factory_.GetWeakPtr()));
87 } 87 }
88 88
89 bool URLRequestAbortOnEndJob::ReadRawData(net::IOBuffer* buf, 89 bool URLRequestAbortOnEndJob::ReadRawData(net::IOBuffer* buf,
90 const int max_bytes, 90 const int max_bytes,
91 int* bytes_read) { 91 int* bytes_read) {
92 if (!sent_data_) { 92 if (!sent_data_) {
93 *bytes_read = std::max(size_t(max_bytes), sizeof(kPageContent)); 93 *bytes_read = std::min(size_t(max_bytes), sizeof(kPageContent));
94 std::memcpy(buf->data(), kPageContent, *bytes_read); 94 std::memcpy(buf->data(), kPageContent, *bytes_read);
95 sent_data_ = true; 95 sent_data_ = true;
96 return true; 96 return true;
97 } 97 }
98 98
99 SetStatus(net::URLRequestStatus(net::URLRequestStatus::FAILED, 99 SetStatus(net::URLRequestStatus(net::URLRequestStatus::FAILED,
100 net::ERR_CONNECTION_ABORTED)); 100 net::ERR_CONNECTION_ABORTED));
101 *bytes_read = -1; 101 *bytes_read = -1;
102 return false; 102 return false;
103 } 103 }
104 104
105 105
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698