Commit 5b84a64e authored by mattm's avatar mattm Committed by Commit bot

Add std::string versions of URLRequestMockHTTPJob::GetMockUrl and GetMockHttpsUrl.

BUG=496936

Review URL: https://codereview.chromium.org/1143053006

Cr-Commit-Position: refs/heads/master@{#333071}
parent 9162b5fa
......@@ -91,13 +91,8 @@ std::string DoFileIO(const base::FilePath& file_path) {
// For a given file |path| and |scheme|, return the URL served by the
// URlRequestMockHTTPJob.
GURL GetMockUrlForScheme(const base::FilePath& path,
const std::string& scheme) {
std::string url = scheme + "://" + kMockHostname + "/";
std::string path_str = path.MaybeAsASCII();
DCHECK(!path_str.empty()); // We only expect ASCII paths in tests.
url.append(path_str);
return GURL(url);
GURL GetMockUrlForScheme(const std::string& path, const std::string& scheme) {
return GURL(scheme + "://" + kMockHostname + "/" + path);
}
} // namespace
......@@ -115,15 +110,29 @@ void URLRequestMockHTTPJob::AddUrlHandlers(
}
// static
GURL URLRequestMockHTTPJob::GetMockUrl(const base::FilePath& path) {
GURL URLRequestMockHTTPJob::GetMockUrl(const std::string& path) {
return GetMockUrlForScheme(path, "http");
}
// static
GURL URLRequestMockHTTPJob::GetMockHttpsUrl(const base::FilePath& path) {
GURL URLRequestMockHTTPJob::GetMockHttpsUrl(const std::string& path) {
return GetMockUrlForScheme(path, "https");
}
// static
GURL URLRequestMockHTTPJob::GetMockUrl(const base::FilePath& path) {
std::string path_str = path.MaybeAsASCII();
DCHECK(!path_str.empty()); // We only expect ASCII paths in tests.
return GetMockUrlForScheme(path_str, "http");
}
// static
GURL URLRequestMockHTTPJob::GetMockHttpsUrl(const base::FilePath& path) {
std::string path_str = path.MaybeAsASCII();
DCHECK(!path_str.empty()); // We only expect ASCII paths in tests.
return GetMockUrlForScheme(path_str, "https");
}
// static
scoped_ptr<URLRequestInterceptor> URLRequestMockHTTPJob::CreateInterceptor(
const base::FilePath& base_path,
......
......@@ -48,6 +48,11 @@ class URLRequestMockHTTPJob : public URLRequestFileJob {
// Given the path to a file relative to the path passed to AddUrlHandler(),
// construct a mock URL.
static GURL GetMockUrl(const std::string& path);
static GURL GetMockHttpsUrl(const std::string& path);
// Like above, but takes a FilePath. These methods are deprecated. Prefer the
// std::string versions. See http://crbug.com/496936.
static GURL GetMockUrl(const base::FilePath& path);
static GURL GetMockHttpsUrl(const base::FilePath& path);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment