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

Side by Side Diff: chrome/browser/net/url_request_mock_util.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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "chrome/browser/net/url_request_mock_util.h" 5 #include "chrome/browser/net/url_request_mock_util.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "chrome/browser/chrome_thread.h" 10 #include "chrome/browser/chrome_thread.h"
11 #include "chrome/browser/net/url_request_failed_dns_job.h" 11 #include "chrome/browser/net/url_request_failed_dns_job.h"
12 #include "chrome/browser/net/url_request_mock_http_job.h" 12 #include "chrome/browser/net/url_request_mock_http_job.h"
13 #include "chrome/browser/net/url_request_mock_link_doctor_job.h"
13 #include "chrome/browser/net/url_request_slow_download_job.h" 14 #include "chrome/browser/net/url_request_slow_download_job.h"
14 #include "chrome/browser/net/url_request_slow_http_job.h" 15 #include "chrome/browser/net/url_request_slow_http_job.h"
15 #include "chrome/common/chrome_paths.h" 16 #include "chrome/common/chrome_paths.h"
16 #include "net/url_request/url_request_filter.h" 17 #include "net/url_request/url_request_filter.h"
17 18
18 namespace chrome_browser_net { 19 namespace chrome_browser_net {
19 20
20 void SetUrlRequestMocksEnabled(bool enabled) { 21 void SetUrlRequestMocksEnabled(bool enabled) {
21 // Since this involves changing the URLRequest ProtocolFactory, we need to 22 // Since this involves changing the URLRequest ProtocolFactory, we need to
22 // run on the IO thread. 23 // run on the IO thread.
23 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); 24 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
24 25
25 if (enabled) { 26 if (enabled) {
26 URLRequestFilter::GetInstance()->ClearHandlers(); 27 URLRequestFilter::GetInstance()->ClearHandlers();
27 28
28 URLRequestFailedDnsJob::AddUrlHandler(); 29 URLRequestFailedDnsJob::AddUrlHandler();
30 URLRequestMockLinkDoctorJob::AddUrlHandler();
29 URLRequestSlowDownloadJob::AddUrlHandler(); 31 URLRequestSlowDownloadJob::AddUrlHandler();
30 32
31 std::wstring root_http; 33 std::wstring root_http;
32 PathService::Get(chrome::DIR_TEST_DATA, &root_http); 34 PathService::Get(chrome::DIR_TEST_DATA, &root_http);
33 URLRequestMockHTTPJob::AddUrlHandler(root_http); 35 URLRequestMockHTTPJob::AddUrlHandler(root_http);
34 URLRequestSlowHTTPJob::AddUrlHandler(root_http); 36 URLRequestSlowHTTPJob::AddUrlHandler(root_http);
35 } else { 37 } else {
36 // Revert to the default handlers. 38 // Revert to the default handlers.
37 URLRequestFilter::GetInstance()->ClearHandlers(); 39 URLRequestFilter::GetInstance()->ClearHandlers();
38 } 40 }
39 } 41 }
40 42
41 } // namespace chrome_browser_net 43 } // namespace chrome_browser_net
OLDNEW
« no previous file with comments | « chrome/browser/net/url_request_mock_link_doctor_job.cc ('k') | chrome/browser/tab_contents/tab_contents.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698