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

Unified Diff: chrome/browser/net/url_request_mock_link_doctor_job.cc

Issue 174179: Mock the LinkDoctor for tests. Should greatly decrease ErrorPage test flakiness. (Closed)
Patch Set: sync with trunk Created 11 years, 3 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/net/url_request_mock_link_doctor_job.h ('k') | chrome/browser/net/url_request_mock_util.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/net/url_request_mock_link_doctor_job.cc
diff --git a/chrome/browser/net/url_request_mock_link_doctor_job.cc b/chrome/browser/net/url_request_mock_link_doctor_job.cc
new file mode 100644
index 0000000000000000000000000000000000000000..88ef4380fbd6f27cfdc33c6699e337d8755ae6a6
--- /dev/null
+++ b/chrome/browser/net/url_request_mock_link_doctor_job.cc
@@ -0,0 +1,40 @@
+// 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/net/url_request_mock_link_doctor_job.h"
+
+#include "base/path_service.h"
+#include "chrome/browser/google_util.h"
+#include "chrome/common/chrome_paths.h"
+#include "googleurl/src/gurl.h"
+#include "net/url_request/url_request_filter.h"
+
+namespace {
+
+FilePath GetMockFilePath() {
+ FilePath test_dir;
+ bool success = PathService::Get(chrome::DIR_TEST_DATA, &test_dir);
+ DCHECK(success);
+ return test_dir.AppendASCII("mock-link-doctor.html");
+}
+
+} // namespace
+
+/* static */
+URLRequestJob* URLRequestMockLinkDoctorJob::Factory(URLRequest* request,
+ const std::string& scheme) {
+ return new URLRequestMockLinkDoctorJob(request);
+}
+
+/* static */
+void URLRequestMockLinkDoctorJob::AddUrlHandler() {
+ URLRequestFilter* filter = URLRequestFilter::GetInstance();
+ filter->AddHostnameHandler("http",
+ GURL(google_util::kLinkDoctorBaseURL).host(),
+ URLRequestMockLinkDoctorJob::Factory);
+}
+
+URLRequestMockLinkDoctorJob::URLRequestMockLinkDoctorJob(URLRequest* request)
+ : URLRequestMockHTTPJob(request, GetMockFilePath()) {
+}
« no previous file with comments | « chrome/browser/net/url_request_mock_link_doctor_job.h ('k') | chrome/browser/net/url_request_mock_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698