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

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

Issue 12163003: Add FilePath to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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) 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 using webkit_glue::ResourceRequestBody; 86 using webkit_glue::ResourceRequestBody;
87 using webkit_glue::ResourceResponseInfo; 87 using webkit_glue::ResourceResponseInfo;
88 using net::StaticCookiePolicy; 88 using net::StaticCookiePolicy;
89 using net::HttpResponseHeaders; 89 using net::HttpResponseHeaders;
90 using webkit_blob::ShareableFileReference; 90 using webkit_blob::ShareableFileReference;
91 91
92 namespace { 92 namespace {
93 93
94 struct TestShellRequestContextParams { 94 struct TestShellRequestContextParams {
95 TestShellRequestContextParams( 95 TestShellRequestContextParams(
96 const FilePath& in_cache_path, 96 const base::FilePath& in_cache_path,
97 net::HttpCache::Mode in_cache_mode, 97 net::HttpCache::Mode in_cache_mode,
98 bool in_no_proxy) 98 bool in_no_proxy)
99 : cache_path(in_cache_path), 99 : cache_path(in_cache_path),
100 cache_mode(in_cache_mode), 100 cache_mode(in_cache_mode),
101 no_proxy(in_no_proxy) {} 101 no_proxy(in_no_proxy) {}
102 102
103 FilePath cache_path; 103 base::FilePath cache_path;
104 net::HttpCache::Mode cache_mode; 104 net::HttpCache::Mode cache_mode;
105 bool no_proxy; 105 bool no_proxy;
106 }; 106 };
107 107
108 //----------------------------------------------------------------------------- 108 //-----------------------------------------------------------------------------
109 109
110 bool g_accept_all_cookies = false; 110 bool g_accept_all_cookies = false;
111 111
112 class TestShellNetworkDelegate : public net::NetworkDelegate { 112 class TestShellNetworkDelegate : public net::NetworkDelegate {
113 public: 113 public:
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 StaticCookiePolicy::Type policy_type = g_accept_all_cookies ? 170 StaticCookiePolicy::Type policy_type = g_accept_all_cookies ?
171 StaticCookiePolicy::ALLOW_ALL_COOKIES : 171 StaticCookiePolicy::ALLOW_ALL_COOKIES :
172 StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES; 172 StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES;
173 173
174 StaticCookiePolicy policy(policy_type); 174 StaticCookiePolicy policy(policy_type);
175 int rv = policy.CanSetCookie( 175 int rv = policy.CanSetCookie(
176 request.url(), request.first_party_for_cookies()); 176 request.url(), request.first_party_for_cookies());
177 return rv == net::OK; 177 return rv == net::OK;
178 } 178 }
179 virtual bool OnCanAccessFile(const net::URLRequest& request, 179 virtual bool OnCanAccessFile(const net::URLRequest& request,
180 const FilePath& path) const OVERRIDE { 180 const base::FilePath& path) const OVERRIDE {
181 return true; 181 return true;
182 } 182 }
183 virtual bool OnCanThrottleRequest( 183 virtual bool OnCanThrottleRequest(
184 const net::URLRequest& request) const OVERRIDE { 184 const net::URLRequest& request) const OVERRIDE {
185 return false; 185 return false;
186 } 186 }
187 187
188 virtual int OnBeforeSocketStreamConnect( 188 virtual int OnBeforeSocketStreamConnect(
189 net::SocketStream* stream, 189 net::SocketStream* stream,
190 const net::CompletionCallback& callback) OVERRIDE { 190 const net::CompletionCallback& callback) OVERRIDE {
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 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(
481 path, ShareableFileReference::DELETE_ON_FINAL_RELEASE, 481 path, ShareableFileReference::DELETE_ON_FINAL_RELEASE,
482 base::MessageLoopProxy::current()); 482 base::MessageLoopProxy::current());
483 file_stream_.reset(new net::FileStream(NULL)); 483 file_stream_.reset(new net::FileStream(NULL));
484 file_stream_->OpenSync( 484 file_stream_->OpenSync(
485 path, base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_WRITE); 485 path, base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_WRITE);
486 } 486 }
487 } 487 }
488 488
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 const FileOverHTTPParams* redirection_params = 748 const FileOverHTTPParams* redirection_params =
749 g_file_over_http_mappings->ParamsForResponse(original_request); 749 g_file_over_http_mappings->ParamsForResponse(original_request);
750 DCHECK(redirection_params); 750 DCHECK(redirection_params);
751 751
752 std::string http_prefix = redirection_params->http_prefix.spec(); 752 std::string http_prefix = redirection_params->http_prefix.spec();
753 DCHECK(StartsWithASCII(original_request, http_prefix, true)); 753 DCHECK(StartsWithASCII(original_request, http_prefix, true));
754 754
755 // Get the File URL. 755 // Get the File URL.
756 original_request.replace(0, http_prefix.size(), file_url_prefix_); 756 original_request.replace(0, http_prefix.size(), file_url_prefix_);
757 757
758 FilePath file_path; 758 base::FilePath file_path;
759 if (!net::FileURLToFilePath(GURL(original_request), &file_path)) { 759 if (!net::FileURLToFilePath(GURL(original_request), &file_path)) {
760 NOTREACHED(); 760 NOTREACHED();
761 } 761 }
762 762
763 info->mime_type.clear(); 763 info->mime_type.clear();
764 DCHECK(info->headers); 764 DCHECK(info->headers);
765 int status_code = info->headers->response_code(); 765 int status_code = info->headers->response_code();
766 // File protocol does not support response headers. 766 // File protocol does not support response headers.
767 info->headers = NULL; 767 info->headers = NULL;
768 if (200 == status_code) { 768 if (200 == status_code) {
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
1020 base::WaitableEvent event_; 1020 base::WaitableEvent event_;
1021 std::string result_; 1021 std::string result_;
1022 }; 1022 };
1023 1023
1024 } // anonymous namespace 1024 } // anonymous namespace
1025 1025
1026 //----------------------------------------------------------------------------- 1026 //-----------------------------------------------------------------------------
1027 1027
1028 // static 1028 // static
1029 void SimpleResourceLoaderBridge::Init( 1029 void SimpleResourceLoaderBridge::Init(
1030 const FilePath& cache_path, 1030 const base::FilePath& cache_path,
1031 net::HttpCache::Mode cache_mode, 1031 net::HttpCache::Mode cache_mode,
1032 bool no_proxy) { 1032 bool no_proxy) {
1033 // Make sure to stop any existing IO thread since it may be using the 1033 // Make sure to stop any existing IO thread since it may be using the
1034 // current request context. 1034 // current request context.
1035 Shutdown(); 1035 Shutdown();
1036 1036
1037 DCHECK(!g_request_context_params); 1037 DCHECK(!g_request_context_params);
1038 DCHECK(!g_request_context); 1038 DCHECK(!g_request_context);
1039 DCHECK(!g_network_delegate); 1039 DCHECK(!g_network_delegate);
1040 DCHECK(!g_io_thread); 1040 DCHECK(!g_io_thread);
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1153 if (!g_file_over_http_mappings) 1153 if (!g_file_over_http_mappings)
1154 g_file_over_http_mappings = new FileOverHTTPPathMappings(); 1154 g_file_over_http_mappings = new FileOverHTTPPathMappings();
1155 g_file_over_http_mappings->AddMapping(file_path_template, http_prefix); 1155 g_file_over_http_mappings->AddMapping(file_path_template, http_prefix);
1156 } 1156 }
1157 1157
1158 // static 1158 // static
1159 webkit_glue::ResourceLoaderBridge* SimpleResourceLoaderBridge::Create( 1159 webkit_glue::ResourceLoaderBridge* SimpleResourceLoaderBridge::Create(
1160 const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info) { 1160 const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info) {
1161 return new ResourceLoaderBridgeImpl(request_info); 1161 return new ResourceLoaderBridgeImpl(request_info);
1162 } 1162 }
OLDNEW
« no previous file with comments | « webkit/tools/test_shell/simple_resource_loader_bridge.h ('k') | webkit/tools/test_shell/test_shell.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698