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

Side by Side Diff: webkit/tools/test_shell/simple_resource_loader_bridge.cc

Issue 16155009: Update webkit/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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 // This file contains an implementation of the ResourceLoaderBridge class. 5 // This file contains an implementation of the ResourceLoaderBridge class.
6 // The class is implemented using net::URLRequest, meaning it is a "simple" 6 // The class is implemented using net::URLRequest, meaning it is a "simple"
7 // version that directly issues requests. The more complicated one used in the 7 // version that directly issues requests. The more complicated one used in the
8 // browser uses IPC. 8 // browser uses IPC.
9 // 9 //
10 // Because net::URLRequest only provides an asynchronous resource loading API, 10 // Because net::URLRequest only provides an asynchronous resource loading API,
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 request_.reset(g_request_context->CreateRequest(params->url, this)); 454 request_.reset(g_request_context->CreateRequest(params->url, this));
455 request_->set_method(params->method); 455 request_->set_method(params->method);
456 request_->set_first_party_for_cookies(params->first_party_for_cookies); 456 request_->set_first_party_for_cookies(params->first_party_for_cookies);
457 request_->SetReferrer(params->referrer.spec()); 457 request_->SetReferrer(params->referrer.spec());
458 webkit_glue::ConfigureURLRequestForReferrerPolicy( 458 webkit_glue::ConfigureURLRequestForReferrerPolicy(
459 request_.get(), params->referrer_policy); 459 request_.get(), params->referrer_policy);
460 net::HttpRequestHeaders headers; 460 net::HttpRequestHeaders headers;
461 headers.AddHeadersFromString(params->headers); 461 headers.AddHeadersFromString(params->headers);
462 request_->SetExtraRequestHeaders(headers); 462 request_->SetExtraRequestHeaders(headers);
463 request_->set_load_flags(params->load_flags); 463 request_->set_load_flags(params->load_flags);
464 if (params->request_body) { 464 if (params->request_body.get()) {
465 request_->set_upload(make_scoped_ptr( 465 request_->set_upload(make_scoped_ptr(
466 params->request_body->ResolveElementsAndCreateUploadDataStream( 466 params->request_body->ResolveElementsAndCreateUploadDataStream(
467 static_cast<TestShellRequestContext*>(g_request_context)-> 467 static_cast<TestShellRequestContext*>(g_request_context)
468 blob_storage_controller(), 468 ->blob_storage_controller(),
469 static_cast<TestShellRequestContext*>(g_request_context)-> 469 static_cast<TestShellRequestContext*>(g_request_context)
470 file_system_context(), 470 ->file_system_context(),
471 base::MessageLoopProxy::current()))); 471 base::MessageLoopProxy::current())));
472 } 472 }
473 SimpleAppCacheSystem::SetExtraRequestInfo( 473 SimpleAppCacheSystem::SetExtraRequestInfo(
474 request_.get(), params->appcache_host_id, params->request_type); 474 request_.get(), params->appcache_host_id, params->request_type);
475 475
476 download_to_file_ = params->download_to_file; 476 download_to_file_ = params->download_to_file;
477 if (download_to_file_) { 477 if (download_to_file_) {
478 base::FilePath path; 478 base::FilePath path;
479 if (file_util::CreateTemporaryFile(&path)) { 479 if (file_util::CreateTemporaryFile(&path)) {
480 downloaded_file_ = ShareableFileReference::GetOrCreate( 480 downloaded_file_ = ShareableFileReference::GetOrCreate(
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 request_->FollowDeferredRedirect(); 518 request_->FollowDeferredRedirect();
519 } 519 }
520 520
521 void AsyncReadData() { 521 void AsyncReadData() {
522 // This can be null in cases where the request is already done. 522 // This can be null in cases where the request is already done.
523 if (!request_) 523 if (!request_)
524 return; 524 return;
525 525
526 if (request_->status().is_success()) { 526 if (request_->status().is_success()) {
527 int bytes_read; 527 int bytes_read;
528 if (request_->Read(buf_, kDataSize, &bytes_read) && bytes_read) { 528 if (request_->Read(buf_.get(), kDataSize, &bytes_read) && bytes_read) {
529 OnReceivedData(bytes_read); 529 OnReceivedData(bytes_read);
530 } else if (!request_->status().is_io_pending()) { 530 } else if (!request_->status().is_io_pending()) {
531 Done(); 531 Done();
532 } // else wait for OnReadCompleted 532 } // else wait for OnReadCompleted
533 } else { 533 } else {
534 Done(); 534 Done();
535 } 535 }
536 } 536 }
537 537
538 // -------------------------------------------------------------------------- 538 // --------------------------------------------------------------------------
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 void PopulateResponseInfo(net::URLRequest* request, 687 void PopulateResponseInfo(net::URLRequest* request,
688 ResourceResponseInfo* info) const { 688 ResourceResponseInfo* info) const {
689 if (request->load_flags() & net::LOAD_ENABLE_LOAD_TIMING) 689 if (request->load_flags() & net::LOAD_ENABLE_LOAD_TIMING)
690 request->GetLoadTimingInfo(&info->load_timing); 690 request->GetLoadTimingInfo(&info->load_timing);
691 info->request_time = request->request_time(); 691 info->request_time = request->request_time();
692 info->response_time = request->response_time(); 692 info->response_time = request->response_time();
693 info->headers = request->response_headers(); 693 info->headers = request->response_headers();
694 request->GetMimeType(&info->mime_type); 694 request->GetMimeType(&info->mime_type);
695 request->GetCharset(&info->charset); 695 request->GetCharset(&info->charset);
696 info->content_length = request->GetExpectedContentSize(); 696 info->content_length = request->GetExpectedContentSize();
697 if (downloaded_file_) 697 if (downloaded_file_.get())
698 info->download_file_path = downloaded_file_->path(); 698 info->download_file_path = downloaded_file_->path();
699 SimpleAppCacheSystem::GetExtraResponseInfo( 699 SimpleAppCacheSystem::GetExtraResponseInfo(
700 request, 700 request,
701 &info->appcache_id, 701 &info->appcache_id,
702 &info->appcache_manifest_url); 702 &info->appcache_manifest_url);
703 } 703 }
704 704
705 // Called on owner thread 705 // Called on owner thread
706 void ConvertRequestParamsForFileOverHTTPIfNeeded(RequestParams* params) { 706 void ConvertRequestParamsForFileOverHTTPIfNeeded(RequestParams* params) {
707 // Reset the status. 707 // Reset the status.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 756
757 // Get the File URL. 757 // Get the File URL.
758 original_request.replace(0, http_prefix.size(), file_url_prefix_); 758 original_request.replace(0, http_prefix.size(), file_url_prefix_);
759 759
760 base::FilePath file_path; 760 base::FilePath file_path;
761 if (!net::FileURLToFilePath(GURL(original_request), &file_path)) { 761 if (!net::FileURLToFilePath(GURL(original_request), &file_path)) {
762 NOTREACHED(); 762 NOTREACHED();
763 } 763 }
764 764
765 info->mime_type.clear(); 765 info->mime_type.clear();
766 DCHECK(info->headers); 766 DCHECK(info->headers.get());
767 int status_code = info->headers->response_code(); 767 int status_code = info->headers->response_code();
768 // File protocol does not support response headers. 768 // File protocol does not support response headers.
769 info->headers = NULL; 769 info->headers = NULL;
770 if (200 == status_code) { 770 if (200 == status_code) {
771 // Don't use the MIME type from HTTP server, use net::GetMimeTypeFromFile 771 // Don't use the MIME type from HTTP server, use net::GetMimeTypeFromFile
772 // instead. 772 // instead.
773 net::GetMimeTypeFromFile(file_path, &info->mime_type); 773 net::GetMimeTypeFromFile(file_path, &info->mime_type);
774 } else { 774 } else {
775 // If the file does not exist, immediately call OnCompletedRequest with 775 // If the file does not exist, immediately call OnCompletedRequest with
776 // setting URLRequestStatus to FAILED. 776 // setting URLRequestStatus to FAILED.
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 // Let the proxy die on the IO thread 918 // Let the proxy die on the IO thread
919 g_io_thread->message_loop()->ReleaseSoon(FROM_HERE, proxy_); 919 g_io_thread->message_loop()->ReleaseSoon(FROM_HERE, proxy_);
920 } 920 }
921 } 921 }
922 922
923 // -------------------------------------------------------------------------- 923 // --------------------------------------------------------------------------
924 // ResourceLoaderBridge implementation: 924 // ResourceLoaderBridge implementation:
925 925
926 virtual void SetRequestBody(ResourceRequestBody* request_body) OVERRIDE { 926 virtual void SetRequestBody(ResourceRequestBody* request_body) OVERRIDE {
927 DCHECK(params_.get()); 927 DCHECK(params_.get());
928 DCHECK(!params_->request_body); 928 DCHECK(!params_->request_body.get());
929 params_->request_body = request_body; 929 params_->request_body = request_body;
930 } 930 }
931 931
932 virtual bool Start(Peer* peer) OVERRIDE { 932 virtual bool Start(Peer* peer) OVERRIDE {
933 DCHECK(!proxy_); 933 DCHECK(!proxy_);
934 934
935 if (!SimpleResourceLoaderBridge::EnsureIOThread()) 935 if (!SimpleResourceLoaderBridge::EnsureIOThread())
936 return false; 936 return false;
937 937
938 proxy_ = new RequestProxy(); 938 proxy_ = new RequestProxy();
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1159 if (!g_file_over_http_mappings) 1159 if (!g_file_over_http_mappings)
1160 g_file_over_http_mappings = new FileOverHTTPPathMappings(); 1160 g_file_over_http_mappings = new FileOverHTTPPathMappings();
1161 g_file_over_http_mappings->AddMapping(file_path_template, http_prefix); 1161 g_file_over_http_mappings->AddMapping(file_path_template, http_prefix);
1162 } 1162 }
1163 1163
1164 // static 1164 // static
1165 webkit_glue::ResourceLoaderBridge* SimpleResourceLoaderBridge::Create( 1165 webkit_glue::ResourceLoaderBridge* SimpleResourceLoaderBridge::Create(
1166 const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info) { 1166 const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info) {
1167 return new ResourceLoaderBridgeImpl(request_info); 1167 return new ResourceLoaderBridgeImpl(request_info);
1168 } 1168 }
OLDNEW
« no previous file with comments | « webkit/tools/test_shell/simple_file_system.cc ('k') | webkit/tools/test_shell/simple_socket_stream_bridge.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698