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

Side by Side Diff: chrome/browser/automation/url_request_slow_download_job.cc

Issue 19004: Change URLRequest to use a ref-counted buffer for actual IO.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "chrome/browser/automation/url_request_slow_download_job.h" 5 #include "chrome/browser/automation/url_request_slow_download_job.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "googleurl/src/gurl.h" 9 #include "googleurl/src/gurl.h"
10 #include "net/url_request/url_request.h" 10 #include "net/url_request/url_request.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 should_send_second_chunk_(false) { 65 should_send_second_chunk_(false) {
66 } 66 }
67 67
68 void URLRequestSlowDownloadJob::StartAsync() { 68 void URLRequestSlowDownloadJob::StartAsync() {
69 if (LowerCaseEqualsASCII(kFinishDownloadUrl, request_->url().spec().c_str())) 69 if (LowerCaseEqualsASCII(kFinishDownloadUrl, request_->url().spec().c_str()))
70 URLRequestSlowDownloadJob::FinishPendingRequests(); 70 URLRequestSlowDownloadJob::FinishPendingRequests();
71 71
72 NotifyHeadersComplete(); 72 NotifyHeadersComplete();
73 } 73 }
74 74
75 bool URLRequestSlowDownloadJob::ReadRawData(char* buf, int buf_size, 75 bool URLRequestSlowDownloadJob::ReadRawData(net::IOBuffer* buf, int buf_size,
76 int *bytes_read) { 76 int *bytes_read) {
77 if (LowerCaseEqualsASCII(kFinishDownloadUrl, 77 if (LowerCaseEqualsASCII(kFinishDownloadUrl,
78 request_->url().spec().c_str())) { 78 request_->url().spec().c_str())) {
79 *bytes_read = 0; 79 *bytes_read = 0;
80 return true; 80 return true;
81 } 81 }
82 82
83 if (should_send_second_chunk_) { 83 if (should_send_second_chunk_) {
84 DCHECK(buf_size > kSecondDownloadSize); 84 DCHECK(buf_size > kSecondDownloadSize);
85 for (int i = 0; i < kSecondDownloadSize; ++i) { 85 for (int i = 0; i < kSecondDownloadSize; ++i) {
86 buf[i] = '*'; 86 buf->data()[i] = '*';
87 } 87 }
88 *bytes_read = kSecondDownloadSize; 88 *bytes_read = kSecondDownloadSize;
89 should_send_second_chunk_ = false; 89 should_send_second_chunk_ = false;
90 return true; 90 return true;
91 } 91 }
92 92
93 if (first_download_size_remaining_ > 0) { 93 if (first_download_size_remaining_ > 0) {
94 int send_size = std::min(first_download_size_remaining_, buf_size); 94 int send_size = std::min(first_download_size_remaining_, buf_size);
95 for (int i = 0; i < send_size; ++i) { 95 for (int i = 0; i < send_size; ++i) {
96 buf[i] = '*'; 96 buf->data()[i] = '*';
97 } 97 }
98 *bytes_read = send_size; 98 *bytes_read = send_size;
99 first_download_size_remaining_ -= send_size; 99 first_download_size_remaining_ -= send_size;
100 100
101 SetStatus(URLRequestStatus(URLRequestStatus::IO_PENDING, 0)); 101 SetStatus(URLRequestStatus(URLRequestStatus::IO_PENDING, 0));
102 DCHECK(!is_done()); 102 DCHECK(!is_done());
103 return true; 103 return true;
104 } 104 }
105 105
106 if (should_finish_download_) { 106 if (should_finish_download_) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 ReplaceSubstringsAfterOffset(&raw_headers, 0, "\n", std::string("\0", 1)); 154 ReplaceSubstringsAfterOffset(&raw_headers, 0, "\n", std::string("\0", 1));
155 info->headers = new net::HttpResponseHeaders(raw_headers); 155 info->headers = new net::HttpResponseHeaders(raw_headers);
156 } 156 }
157 157
158 bool URLRequestSlowDownloadJob::GetMimeType(std::string* mime_type) { 158 bool URLRequestSlowDownloadJob::GetMimeType(std::string* mime_type) {
159 net::HttpResponseInfo info; 159 net::HttpResponseInfo info;
160 GetResponseInfo(&info); 160 GetResponseInfo(&info);
161 return info.headers && info.headers->GetMimeType(mime_type); 161 return info.headers && info.headers->GetMimeType(mime_type);
162 } 162 }
163 163
OLDNEW
« no previous file with comments | « chrome/browser/automation/url_request_slow_download_job.h ('k') | chrome/browser/chrome_plugin_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698