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

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

Issue 40138: Use FilterContext to allow filters to access URLRequestJob data... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 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/http/http_response_headers.h" 10 #include "net/http/http_response_headers.h"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 should_send_second_chunk_ = true; 124 should_send_second_chunk_ = true;
125 SetStatus(URLRequestStatus()); 125 SetStatus(URLRequestStatus());
126 NotifyReadComplete(kSecondDownloadSize); 126 NotifyReadComplete(kSecondDownloadSize);
127 Release(); 127 Release();
128 } else { 128 } else {
129 MessageLoop::current()->PostDelayedTask(FROM_HERE, NewRunnableMethod( 129 MessageLoop::current()->PostDelayedTask(FROM_HERE, NewRunnableMethod(
130 this, &URLRequestSlowDownloadJob::CheckDoneStatus), 100); 130 this, &URLRequestSlowDownloadJob::CheckDoneStatus), 100);
131 } 131 }
132 } 132 }
133 133
134 // Public virtual version.
134 void URLRequestSlowDownloadJob::GetResponseInfo(net::HttpResponseInfo* info) { 135 void URLRequestSlowDownloadJob::GetResponseInfo(net::HttpResponseInfo* info) {
136 // Forward to private const version.
137 GetResponseInfoConst(info);
138 }
139
140 // Private const version.
141 void URLRequestSlowDownloadJob::GetResponseInfoConst(net::HttpResponseInfo* info ) const {
huanr 2009/03/09 17:50:44 80 characters.
jar (doing other things) 2009/03/09 19:00:41 Done.
135 // Send back mock headers. 142 // Send back mock headers.
136 std::string raw_headers; 143 std::string raw_headers;
137 if (LowerCaseEqualsASCII(kFinishDownloadUrl, 144 if (LowerCaseEqualsASCII(kFinishDownloadUrl,
138 request_->url().spec().c_str())) { 145 request_->url().spec().c_str())) {
139 raw_headers.append( 146 raw_headers.append(
140 "HTTP/1.1 200 OK\n" 147 "HTTP/1.1 200 OK\n"
141 "Content-type: text/plain\n"); 148 "Content-type: text/plain\n");
142 } else { 149 } else {
143 raw_headers.append( 150 raw_headers.append(
144 "HTTP/1.1 200 OK\n" 151 "HTTP/1.1 200 OK\n"
145 "Content-type: application/octet-stream\n" 152 "Content-type: application/octet-stream\n"
146 "Cache-Control: max-age=0\n"); 153 "Cache-Control: max-age=0\n");
147 154
148 if (LowerCaseEqualsASCII(kKnownSizeUrl, request_->url().spec().c_str())) { 155 if (LowerCaseEqualsASCII(kKnownSizeUrl, request_->url().spec().c_str())) {
149 raw_headers.append(StringPrintf("Content-Length: %d\n", 156 raw_headers.append(StringPrintf("Content-Length: %d\n",
150 kFirstDownloadSize + kSecondDownloadSize)); 157 kFirstDownloadSize + kSecondDownloadSize));
151 } 158 }
152 } 159 }
153 160
154 // ParseRawHeaders expects \0 to end each header line. 161 // ParseRawHeaders expects \0 to end each header line.
155 ReplaceSubstringsAfterOffset(&raw_headers, 0, "\n", std::string("\0", 1)); 162 ReplaceSubstringsAfterOffset(&raw_headers, 0, "\n", std::string("\0", 1));
156 info->headers = new net::HttpResponseHeaders(raw_headers); 163 info->headers = new net::HttpResponseHeaders(raw_headers);
157 } 164 }
158 165
159 bool URLRequestSlowDownloadJob::GetMimeType(std::string* mime_type) { 166 bool URLRequestSlowDownloadJob::GetMimeType(std::string* mime_type) const {
160 net::HttpResponseInfo info; 167 net::HttpResponseInfo info;
161 GetResponseInfo(&info); 168 GetResponseInfoConst(&info);
162 return info.headers && info.headers->GetMimeType(mime_type); 169 return info.headers && info.headers->GetMimeType(mime_type);
163 } 170 }
164 171
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698