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

Side by Side Diff: webkit/glue/weburlloader_impl.cc

Issue 3053009: Pepper stream-to-file plumbing.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 5 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-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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 // An implementation of WebURLLoader in terms of ResourceLoaderBridge. 5 // An implementation of WebURLLoader in terms of ResourceLoaderBridge.
6 6
7 #include "webkit/glue/weburlloader_impl.h" 7 #include "webkit/glue/weburlloader_impl.h"
8 8
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 response->setAppCacheManifestURL(info.appcache_manifest_url); 175 response->setAppCacheManifestURL(info.appcache_manifest_url);
176 response->setWasCached(!info.load_timing.base_time.is_null() && 176 response->setWasCached(!info.load_timing.base_time.is_null() &&
177 info.response_time < info.load_timing.base_time); 177 info.response_time < info.load_timing.base_time);
178 response->setWasFetchedViaSPDY(info.was_fetched_via_spdy); 178 response->setWasFetchedViaSPDY(info.was_fetched_via_spdy);
179 response->setWasNpnNegotiated(info.was_npn_negotiated); 179 response->setWasNpnNegotiated(info.was_npn_negotiated);
180 response->setWasAlternateProtocolAvailable( 180 response->setWasAlternateProtocolAvailable(
181 info.was_alternate_protocol_available); 181 info.was_alternate_protocol_available);
182 response->setWasFetchedViaProxy(info.was_fetched_via_proxy); 182 response->setWasFetchedViaProxy(info.was_fetched_via_proxy);
183 response->setConnectionID(info.connection_id); 183 response->setConnectionID(info.connection_id);
184 response->setConnectionReused(info.connection_reused); 184 response->setConnectionReused(info.connection_reused);
185 response->setDownloadFilePath(FilePathToWebString(info.download_file_path));
185 186
186 WebURLLoadTiming timing; 187 WebURLLoadTiming timing;
187 timing.initialize(); 188 timing.initialize();
188 const ResourceLoaderBridge::LoadTimingInfo& timing_info = info.load_timing; 189 const ResourceLoaderBridge::LoadTimingInfo& timing_info = info.load_timing;
189 timing.setRequestTime(timing_info.base_time.ToDoubleT()); 190 timing.setRequestTime(timing_info.base_time.ToDoubleT());
190 timing.setProxyStart(timing_info.proxy_start); 191 timing.setProxyStart(timing_info.proxy_start);
191 timing.setProxyEnd(timing_info.proxy_end); 192 timing.setProxyEnd(timing_info.proxy_end);
192 timing.setDNSStart(timing_info.dns_start); 193 timing.setDNSStart(timing_info.dns_start);
193 timing.setDNSEnd(timing_info.dns_end); 194 timing.setDNSEnd(timing_info.dns_end);
194 timing.setConnectStart(timing_info.connect_start); 195 timing.setConnectStart(timing_info.connect_start);
(...skipping 11 matching lines...) Expand all
206 207
207 response->setHTTPStatusCode(headers->response_code()); 208 response->setHTTPStatusCode(headers->response_code());
208 response->setHTTPStatusText(WebString::fromUTF8(headers->GetStatusText())); 209 response->setHTTPStatusText(WebString::fromUTF8(headers->GetStatusText()));
209 210
210 // TODO(darin): We should leverage HttpResponseHeaders for this, and this 211 // TODO(darin): We should leverage HttpResponseHeaders for this, and this
211 // should be using the same code as ResourceDispatcherHost. 212 // should be using the same code as ResourceDispatcherHost.
212 // TODO(jungshik): Figure out the actual value of the referrer charset and 213 // TODO(jungshik): Figure out the actual value of the referrer charset and
213 // pass it to GetSuggestedFilename. 214 // pass it to GetSuggestedFilename.
214 std::string value; 215 std::string value;
215 if (headers->EnumerateHeader(NULL, "content-disposition", &value)) { 216 if (headers->EnumerateHeader(NULL, "content-disposition", &value)) {
216 response->setSuggestedFileName(webkit_glue::FilePathToWebString( 217 response->setSuggestedFileName(FilePathToWebString(
217 net::GetSuggestedFilename(url, value, "", FilePath()))); 218 net::GetSuggestedFilename(url, value, "", FilePath())));
218 } 219 }
219 220
220 Time time_val; 221 Time time_val;
221 if (headers->GetLastModifiedValue(&time_val)) 222 if (headers->GetLastModifiedValue(&time_val))
222 response->setLastModifiedDate(time_val.ToDoubleT()); 223 response->setLastModifiedDate(time_val.ToDoubleT());
223 224
224 // Build up the header map. 225 // Build up the header map.
225 void* iter = NULL; 226 void* iter = NULL;
226 std::string name; 227 std::string name;
(...skipping 26 matching lines...) Expand all
253 254
254 // ResourceLoaderBridge::Peer methods: 255 // ResourceLoaderBridge::Peer methods:
255 virtual void OnUploadProgress(uint64 position, uint64 size); 256 virtual void OnUploadProgress(uint64 position, uint64 size);
256 virtual bool OnReceivedRedirect( 257 virtual bool OnReceivedRedirect(
257 const GURL& new_url, 258 const GURL& new_url,
258 const ResourceLoaderBridge::ResponseInfo& info, 259 const ResourceLoaderBridge::ResponseInfo& info,
259 bool* has_new_first_party_for_cookies, 260 bool* has_new_first_party_for_cookies,
260 GURL* new_first_party_for_cookies); 261 GURL* new_first_party_for_cookies);
261 virtual void OnReceivedResponse( 262 virtual void OnReceivedResponse(
262 const ResourceLoaderBridge::ResponseInfo& info, bool content_filtered); 263 const ResourceLoaderBridge::ResponseInfo& info, bool content_filtered);
264 virtual void OnDownloadedData(int len);
263 virtual void OnReceivedData(const char* data, int len); 265 virtual void OnReceivedData(const char* data, int len);
264 virtual void OnReceivedCachedMetadata(const char* data, int len); 266 virtual void OnReceivedCachedMetadata(const char* data, int len);
265 virtual void OnCompletedRequest( 267 virtual void OnCompletedRequest(
266 const URLRequestStatus& status, const std::string& security_info); 268 const URLRequestStatus& status, const std::string& security_info);
267 virtual GURL GetURLForDebugging() const; 269 virtual GURL GetURLForDebugging() const;
268 270
269 private: 271 private:
270 friend class base::RefCounted<Context>; 272 friend class base::RefCounted<Context>;
271 ~Context() {} 273 ~Context() {}
272 274
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 request.visitHTTPHeaderFields(&flattener); 379 request.visitHTTPHeaderFields(&flattener);
378 380
379 // TODO(abarth): These are wrong! I need to figure out how to get the right 381 // TODO(abarth): These are wrong! I need to figure out how to get the right
380 // strings here. See: http://crbug.com/8706 382 // strings here. See: http://crbug.com/8706
381 std::string frame_origin = request.firstPartyForCookies().spec(); 383 std::string frame_origin = request.firstPartyForCookies().spec();
382 std::string main_frame_origin = request.firstPartyForCookies().spec(); 384 std::string main_frame_origin = request.firstPartyForCookies().spec();
383 385
384 // TODO(brettw) this should take parameter encoding into account when 386 // TODO(brettw) this should take parameter encoding into account when
385 // creating the GURLs. 387 // creating the GURLs.
386 388
387 webkit_glue::ResourceLoaderBridge::RequestInfo request_info; 389 ResourceLoaderBridge::RequestInfo request_info;
388 request_info.method = method; 390 request_info.method = method;
389 request_info.url = url; 391 request_info.url = url;
390 request_info.first_party_for_cookies = request.firstPartyForCookies(); 392 request_info.first_party_for_cookies = request.firstPartyForCookies();
391 request_info.referrer = referrer_url; 393 request_info.referrer = referrer_url;
392 request_info.frame_origin = frame_origin; 394 request_info.frame_origin = frame_origin;
393 request_info.main_frame_origin = main_frame_origin; 395 request_info.main_frame_origin = main_frame_origin;
394 request_info.headers = flattener.GetBuffer(); 396 request_info.headers = flattener.GetBuffer();
395 request_info.load_flags = load_flags; 397 request_info.load_flags = load_flags;
396 request_info.requestor_pid = requestor_pid; 398 request_info.requestor_pid = requestor_pid;
397 request_info.request_type = FromTargetType(request.targetType()); 399 request_info.request_type = FromTargetType(request.targetType());
398 request_info.appcache_host_id = request.appCacheHostID(); 400 request_info.appcache_host_id = request.appCacheHostID();
399 request_info.routing_id = request.requestorID(); 401 request_info.routing_id = request.requestorID();
402 request_info.download_to_file = request.downloadToFile();
400 bridge_.reset(ResourceLoaderBridge::Create(request_info)); 403 bridge_.reset(ResourceLoaderBridge::Create(request_info));
401 404
402 if (!request.httpBody().isNull()) { 405 if (!request.httpBody().isNull()) {
403 // GET and HEAD requests shouldn't have http bodies. 406 // GET and HEAD requests shouldn't have http bodies.
404 DCHECK(method != "GET" && method != "HEAD"); 407 DCHECK(method != "GET" && method != "HEAD");
405 const WebHTTPBody& httpBody = request.httpBody(); 408 const WebHTTPBody& httpBody = request.httpBody();
406 size_t i = 0; 409 size_t i = 0;
407 WebHTTPBody::Element element; 410 WebHTTPBody::Element element;
408 while (httpBody.elementAt(i++, element)) { 411 while (httpBody.elementAt(i++, element)) {
409 switch (element.type) { 412 switch (element.type) {
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 } 541 }
539 } else if (info.mime_type == "text/vnd.chromium.ftp-dir" && 542 } else if (info.mime_type == "text/vnd.chromium.ftp-dir" &&
540 !show_raw_listing) { 543 !show_raw_listing) {
541 ftp_listing_delegate_.reset( 544 ftp_listing_delegate_.reset(
542 new FtpDirectoryListingResponseDelegate(client_, loader_, response)); 545 new FtpDirectoryListingResponseDelegate(client_, loader_, response));
543 } 546 }
544 547
545 response_url_ = response.url(); 548 response_url_ = response.url();
546 } 549 }
547 550
551 void WebURLLoaderImpl::Context::OnDownloadedData(int len) {
552 if (client_)
553 client_->didDownloadData(loader_, len);
554 }
555
548 void WebURLLoaderImpl::Context::OnReceivedData(const char* data, int len) { 556 void WebURLLoaderImpl::Context::OnReceivedData(const char* data, int len) {
549 if (!client_) 557 if (!client_)
550 return; 558 return;
551 559
552 // Temporary logging, see site_isolation_metrics.h/cc. 560 // Temporary logging, see site_isolation_metrics.h/cc.
553 SiteIsolationMetrics::SniffCrossOriginHTML(response_url_, data, len); 561 SiteIsolationMetrics::SniffCrossOriginHTML(response_url_, data, len);
554 562
555 if (ftp_listing_delegate_.get()) { 563 if (ftp_listing_delegate_.get()) {
556 // The FTP listing delegate will make the appropriate calls to 564 // The FTP listing delegate will make the appropriate calls to
557 // client_->didReceiveData and client_->didReceiveResponse. 565 // client_->didReceiveData and client_->didReceiveResponse.
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 687
680 void WebURLLoaderImpl::cancel() { 688 void WebURLLoaderImpl::cancel() {
681 context_->Cancel(); 689 context_->Cancel();
682 } 690 }
683 691
684 void WebURLLoaderImpl::setDefersLoading(bool value) { 692 void WebURLLoaderImpl::setDefersLoading(bool value) {
685 context_->SetDefersLoading(value); 693 context_->SetDefersLoading(value);
686 } 694 }
687 695
688 } // namespace webkit_glue 696 } // namespace webkit_glue
OLDNEW
« no previous file with comments | « webkit/glue/resource_loader_bridge.cc ('k') | webkit/tools/test_shell/simple_resource_loader_bridge.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698