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

Side by Side Diff: content/test/net/url_request_slow_download_job.cc

Issue 10392111: Use ByteStream in downloads system to decouple source and sink. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Results of self code review. Created 8 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
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 "content/test/net/url_request_slow_download_job.h" 5 #include "content/test/net/url_request_slow_download_job.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 } 178 }
179 179
180 void URLRequestSlowDownloadJob::CheckDoneStatus() { 180 void URLRequestSlowDownloadJob::CheckDoneStatus() {
181 if (should_finish_download_) { 181 if (should_finish_download_) {
182 VLOG(10) << __FUNCTION__ << " called w/ should_finish_download_ set."; 182 VLOG(10) << __FUNCTION__ << " called w/ should_finish_download_ set.";
183 DCHECK(NULL != buffer_); 183 DCHECK(NULL != buffer_);
184 int bytes_written = 0; 184 int bytes_written = 0;
185 ReadStatus status = FillBufferHelper(buffer_, buffer_size_, &bytes_written); 185 ReadStatus status = FillBufferHelper(buffer_, buffer_size_, &bytes_written);
186 DCHECK_EQ(BUFFER_FILLED, status); 186 DCHECK_EQ(BUFFER_FILLED, status);
187 SetStatus(net::URLRequestStatus()); 187 SetStatus(net::URLRequestStatus());
188 // Release reference
189 buffer_ = NULL;
Randy Smith (Not in Mondays) 2012/05/19 15:29:57 This has already landed, and will disappear from t
Randy Smith (Not in Mondays) 2012/05/23 03:33:15 Done.
188 NotifyReadComplete(bytes_written); 190 NotifyReadComplete(bytes_written);
189 } else { 191 } else {
190 MessageLoop::current()->PostDelayedTask( 192 MessageLoop::current()->PostDelayedTask(
191 FROM_HERE, 193 FROM_HERE,
192 base::Bind(&URLRequestSlowDownloadJob::CheckDoneStatus, 194 base::Bind(&URLRequestSlowDownloadJob::CheckDoneStatus,
193 weak_factory_.GetWeakPtr()), 195 weak_factory_.GetWeakPtr()),
194 base::TimeDelta::FromMilliseconds(100)); 196 base::TimeDelta::FromMilliseconds(100));
195 } 197 }
196 } 198 }
197 199
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 // ParseRawHeaders expects \0 to end each header line. 234 // ParseRawHeaders expects \0 to end each header line.
233 ReplaceSubstringsAfterOffset(&raw_headers, 0, "\n", std::string("\0", 1)); 235 ReplaceSubstringsAfterOffset(&raw_headers, 0, "\n", std::string("\0", 1));
234 info->headers = new net::HttpResponseHeaders(raw_headers); 236 info->headers = new net::HttpResponseHeaders(raw_headers);
235 } 237 }
236 238
237 bool URLRequestSlowDownloadJob::GetMimeType(std::string* mime_type) const { 239 bool URLRequestSlowDownloadJob::GetMimeType(std::string* mime_type) const {
238 net::HttpResponseInfo info; 240 net::HttpResponseInfo info;
239 GetResponseInfoConst(&info); 241 GetResponseInfoConst(&info);
240 return info.headers && info.headers->GetMimeType(mime_type); 242 return info.headers && info.headers->GetMimeType(mime_type);
241 } 243 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698