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

Unified Diff: chrome/browser/automation/url_request_mock_http_job.cc

Issue 155941: Make AutomationProxyTest.NavigateToURLWithTimeout* tests not-flaky. (Closed)
Patch Set: maintainability fixes Created 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/automation/url_request_mock_http_job.cc
diff --git a/chrome/browser/automation/url_request_mock_http_job.cc b/chrome/browser/automation/url_request_mock_http_job.cc
index 4bb191ac3eac5bb5bc503f162c91fc1d652a352a..4d212a530f946fccf1b55429dc5fa3e6d5a3fdb5 100644
--- a/chrome/browser/automation/url_request_mock_http_job.cc
+++ b/chrome/browser/automation/url_request_mock_http_job.cc
@@ -19,22 +19,8 @@ std::wstring URLRequestMockHTTPJob::base_path_ = L"";
/* static */
URLRequestJob* URLRequestMockHTTPJob::Factory(URLRequest* request,
const std::string& scheme) {
- std::wstring file_url(L"file:///");
- file_url += base_path_;
- const std::string& url = request->url().spec();
- // Fix up the url to be the file url we're loading from disk.
- std::string host_prefix("http://");
- host_prefix.append(kMockHostname);
- size_t host_prefix_len = host_prefix.length();
- if (url.compare(0, host_prefix_len, host_prefix.data(),
- host_prefix_len) == 0) {
- file_url += UTF8ToWide(url.substr(host_prefix_len));
- }
-
- // Convert the file:/// URL to a path on disk.
- FilePath file_path;
- net::FileURLToFilePath(GURL(WideToUTF8(file_url)), &file_path);
- return new URLRequestMockHTTPJob(request, file_path);
+ return new URLRequestMockHTTPJob(request,
+ GetOnDiskPath(base_path_, request, scheme));
}
/* static */
@@ -56,6 +42,28 @@ GURL URLRequestMockHTTPJob::GetMockUrl(const std::wstring& path) {
return GURL(url);
}
+/* static */
+FilePath URLRequestMockHTTPJob::GetOnDiskPath(const std::wstring& base_path,
+ URLRequest* request,
+ const std::string& scheme) {
+ std::wstring file_url(L"file:///");
+ file_url += base_path;
+ const std::string& url = request->url().spec();
+ // Fix up the url to be the file url we're loading from disk.
+ std::string host_prefix("http://");
+ host_prefix.append(kMockHostname);
+ size_t host_prefix_len = host_prefix.length();
+ if (url.compare(0, host_prefix_len, host_prefix.data(),
+ host_prefix_len) == 0) {
+ file_url += UTF8ToWide(url.substr(host_prefix_len));
+ }
+
+ // Convert the file:/// URL to a path on disk.
+ FilePath file_path;
+ net::FileURLToFilePath(GURL(WideToUTF8(file_url)), &file_path);
+ return file_path;
+}
+
URLRequestMockHTTPJob::URLRequestMockHTTPJob(URLRequest* request,
const FilePath& file_path)
: URLRequestFileJob(request, file_path) { }
« no previous file with comments | « chrome/browser/automation/url_request_mock_http_job.h ('k') | chrome/browser/automation/url_request_slow_http_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698