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

Side by Side Diff: chrome/browser/net/url_request_mock_util.cc

Issue 541743002: Move url_request_mock_http_job to net/test/url_request/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 6 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/threading/thread_restrictions.h" 10 #include "base/threading/thread_restrictions.h"
11 #include "chrome/common/chrome_paths.h" 11 #include "chrome/common/chrome_paths.h"
12 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
13 #include "content/test/net/url_request_failed_job.h" 13 #include "content/test/net/url_request_failed_job.h"
14 #include "content/test/net/url_request_mock_http_job.h"
15 #include "content/test/net/url_request_slow_download_job.h" 14 #include "content/test/net/url_request_slow_download_job.h"
15 #include "net/test/url_request/url_request_mock_http_job.h"
16 #include "net/url_request/url_request_filter.h" 16 #include "net/url_request/url_request_filter.h"
17 17
18 using content::BrowserThread; 18 using content::BrowserThread;
19 19
20 namespace chrome_browser_net { 20 namespace chrome_browser_net {
21 21
22 void SetUrlRequestMocksEnabled(bool enabled) { 22 void SetUrlRequestMocksEnabled(bool enabled) {
23 // Since this involves changing the net::URLRequest ProtocolFactory, we need 23 // Since this involves changing the net::URLRequest ProtocolFactory, we need
24 // to run on the IO thread. 24 // to run on the IO thread.
25 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 25 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
26 26
27 if (enabled) { 27 if (enabled) {
28 // We have to look around for our helper files, but we only use 28 // We have to look around for our helper files, but we only use
29 // this from tests, so allow these IO operations to happen 29 // this from tests, so allow these IO operations to happen
30 // anywhere. 30 // anywhere.
31 base::ThreadRestrictions::ScopedAllowIO allow_io; 31 base::ThreadRestrictions::ScopedAllowIO allow_io;
32 32
33 net::URLRequestFilter::GetInstance()->ClearHandlers(); 33 net::URLRequestFilter::GetInstance()->ClearHandlers();
34 34
35 content::URLRequestFailedJob::AddUrlHandler(); 35 content::URLRequestFailedJob::AddUrlHandler();
36 content::URLRequestSlowDownloadJob::AddUrlHandler(); 36 content::URLRequestSlowDownloadJob::AddUrlHandler();
37 37
38 base::FilePath root_http; 38 base::FilePath root_http;
39 PathService::Get(chrome::DIR_TEST_DATA, &root_http); 39 PathService::Get(chrome::DIR_TEST_DATA, &root_http);
40 content::URLRequestMockHTTPJob::AddUrlHandler(root_http); 40 net::URLRequestMockHTTPJob::AddUrlHandler(root_http,
41 BrowserThread::GetBlockingPool());
41 } else { 42 } else {
42 // Revert to the default handlers. 43 // Revert to the default handlers.
43 net::URLRequestFilter::GetInstance()->ClearHandlers(); 44 net::URLRequestFilter::GetInstance()->ClearHandlers();
44 } 45 }
45 } 46 }
46 47
47 } // namespace chrome_browser_net 48 } // namespace chrome_browser_net
OLDNEW
« no previous file with comments | « chrome/browser/net/dns_probe_browsertest.cc ('k') | chrome/browser/plugins/npapi_infobar_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698