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

Side by Side Diff: ios/web/public/test/response_providers/file_based_response_provider_impl.mm

Issue 2481923002: [WIP] make GURL::path() return a StringPiece (Closed)
Patch Set: thanks asan Created 4 years, 1 month 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
« no previous file with comments | « ios/web/public/test/http_server.mm ('k') | ios/web/webui/crw_web_ui_manager_unittest.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "ios/web/public/test/response_providers/file_based_response_provider_im pl.h" 5 #include "ios/web/public/test/response_providers/file_based_response_provider_im pl.h"
6 6
7 #include "base/files/file_util.h" 7 #include "base/files/file_util.h"
8 #include "ios/web/public/test/response_providers/response_provider.h" 8 #include "ios/web/public/test/response_providers/response_provider.h"
9 #include "url/gurl.h" 9 #include "url/gurl.h"
10 10
11 namespace web { 11 namespace web {
12 12
13 FileBasedResponseProviderImpl::FileBasedResponseProviderImpl( 13 FileBasedResponseProviderImpl::FileBasedResponseProviderImpl(
14 const base::FilePath& path) 14 const base::FilePath& path)
15 : path_(path) {} 15 : path_(path) {}
16 16
17 FileBasedResponseProviderImpl::~FileBasedResponseProviderImpl() {} 17 FileBasedResponseProviderImpl::~FileBasedResponseProviderImpl() {}
18 18
19 bool FileBasedResponseProviderImpl::CanHandleRequest( 19 bool FileBasedResponseProviderImpl::CanHandleRequest(
20 const ResponseProvider::Request& request) { 20 const ResponseProvider::Request& request) {
21 return base::PathExists(BuildTargetPath(request.url)); 21 return base::PathExists(BuildTargetPath(request.url));
22 } 22 }
23 23
24 base::FilePath FileBasedResponseProviderImpl::BuildTargetPath(const GURL& url) { 24 base::FilePath FileBasedResponseProviderImpl::BuildTargetPath(const GURL& url) {
25 base::FilePath result = path_; 25 base::FilePath result = path_;
26 const std::string kLocalhostHost = "localhost"; 26 const std::string kLocalhostHost = "localhost";
27 if (url.host() != kLocalhostHost) { 27 if (url.host() != kLocalhostHost) {
28 result = result.Append(url.host()); 28 result = result.Append(url.host());
29 } 29 }
30 std::string url_path = url.path(); 30 std::string url_path = url.path().as_string();
31 // Remove the leading slash in url path. 31 // Remove the leading slash in url path.
32 if (url_path.length() > 0 && url_path[0] == '/') { 32 if (url_path.length() > 0 && url_path[0] == '/') {
33 url_path.erase(0, 1); 33 url_path.erase(0, 1);
34 } 34 }
35 if (!url_path.empty()) 35 if (!url_path.empty())
36 result = result.Append(url_path); 36 result = result.Append(url_path);
37 return result; 37 return result;
38 } 38 }
39 39
40 } // namespace web 40 } // namespace web
OLDNEW
« no previous file with comments | « ios/web/public/test/http_server.mm ('k') | ios/web/webui/crw_web_ui_manager_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698