This source file includes following definitions.
- SetUrlRequestMocksEnabled
#include "chrome/browser/net/url_request_mock_util.h"
#include <string>
#include "base/path_service.h"
#include "base/threading/thread_restrictions.h"
#include "chrome/browser/google/google_util.h"
#include "chrome/common/chrome_paths.h"
#include "content/public/browser/browser_thread.h"
#include "content/test/net/url_request_failed_job.h"
#include "content/test/net/url_request_mock_http_job.h"
#include "content/test/net/url_request_slow_download_job.h"
#include "net/url_request/url_request_filter.h"
using content::BrowserThread;
namespace chrome_browser_net {
void SetUrlRequestMocksEnabled(bool enabled) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
if (enabled) {
base::ThreadRestrictions::ScopedAllowIO allow_io;
net::URLRequestFilter::GetInstance()->ClearHandlers();
content::URLRequestFailedJob::AddUrlHandler();
content::URLRequestSlowDownloadJob::AddUrlHandler();
base::FilePath root_http;
PathService::Get(chrome::DIR_TEST_DATA, &root_http);
content::URLRequestMockHTTPJob::AddUrlHandler(root_http);
content::URLRequestMockHTTPJob::AddHostnameToFileHandler(
google_util::LinkDoctorBaseURL().host(),
root_http.AppendASCII("mock-link-doctor.json"));
} else {
net::URLRequestFilter::GetInstance()->ClearHandlers();
}
}
}