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

Unified Diff: chrome/browser/automation/url_request_slow_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
« no previous file with comments | « chrome/browser/automation/url_request_slow_http_job.h ('k') | chrome/chrome.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/automation/url_request_slow_http_job.cc
diff --git a/chrome/browser/automation/url_request_slow_http_job.cc b/chrome/browser/automation/url_request_slow_http_job.cc
new file mode 100644
index 0000000000000000000000000000000000000000..30d9dfa944b38fe8d9b131a4182e1e8af2108d67
--- /dev/null
+++ b/chrome/browser/automation/url_request_slow_http_job.cc
@@ -0,0 +1,58 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/automation/url_request_slow_http_job.h"
+
+#include "base/platform_thread.h"
+#include "base/string_util.h"
+#include "base/time.h"
+#include "net/url_request/url_request_filter.h"
+
+static const char kMockHostname[] = "mock.slow.http";
+
+std::wstring URLRequestSlowHTTPJob::base_path_ = L"";
+
+// static
+const int URLRequestSlowHTTPJob::kDelayMs = 1000;
+
+using base::TimeDelta;
+
+/* static */
+URLRequestJob* URLRequestSlowHTTPJob::Factory(URLRequest* request,
+ const std::string& scheme) {
+ return new URLRequestSlowHTTPJob(request,
+ GetOnDiskPath(base_path_, request, scheme));
+}
+
+/* static */
+void URLRequestSlowHTTPJob::AddUITestUrls(const std::wstring& base_path) {
+ base_path_ = base_path;
+
+ // Add kMockHostname to URLRequestFilter.
+ URLRequestFilter* filter = URLRequestFilter::GetInstance();
+ filter->AddHostnameHandler("http", kMockHostname,
+ URLRequestSlowHTTPJob::Factory);
+}
+
+/* static */
+GURL URLRequestSlowHTTPJob::GetMockUrl(const std::wstring& path) {
+ std::string url = "http://";
+ url.append(kMockHostname);
+ url.append("/");
+ url.append(WideToUTF8(path));
+ return GURL(url);
+}
+
+URLRequestSlowHTTPJob::URLRequestSlowHTTPJob(URLRequest* request,
+ const FilePath& file_path)
+ : URLRequestMockHTTPJob(request, file_path) { }
+
+void URLRequestSlowHTTPJob::Start() {
+ delay_timer_.Start(TimeDelta::FromMilliseconds(kDelayMs), this,
+ &URLRequestSlowHTTPJob::RealStart);
+}
+
+void URLRequestSlowHTTPJob::RealStart() {
+ URLRequestMockHTTPJob::Start();
+}
« no previous file with comments | « chrome/browser/automation/url_request_slow_http_job.h ('k') | chrome/chrome.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698