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

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

Issue 6973052: When the download folder does not exist, change the download folder to a user's "Downloads" (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Added URLRequestMockHTTPJob.test_dir_ and URLRequestMockHTTPJob.temp_dir_ Created 9 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/file_util.h"
9 #include "base/path_service.h" 10 #include "base/path_service.h"
10 #include "base/threading/thread_restrictions.h" 11 #include "base/threading/thread_restrictions.h"
11 #include "chrome/browser/net/url_request_mock_link_doctor_job.h" 12 #include "chrome/browser/net/url_request_mock_link_doctor_job.h"
12 #include "chrome/common/chrome_paths.h" 13 #include "chrome/common/chrome_paths.h"
13 #include "content/browser/browser_thread.h" 14 #include "content/browser/browser_thread.h"
14 #include "content/browser/net/url_request_failed_dns_job.h" 15 #include "content/browser/net/url_request_failed_dns_job.h"
15 #include "content/browser/net/url_request_mock_http_job.h" 16 #include "content/browser/net/url_request_mock_http_job.h"
16 #include "content/browser/net/url_request_slow_download_job.h" 17 #include "content/browser/net/url_request_slow_download_job.h"
17 #include "content/browser/net/url_request_slow_http_job.h" 18 #include "content/browser/net/url_request_slow_http_job.h"
18 #include "net/url_request/url_request_filter.h" 19 #include "net/url_request/url_request_filter.h"
(...skipping 10 matching lines...) Expand all
29 // this from tests, so allow these IO operations to happen 30 // this from tests, so allow these IO operations to happen
30 // anywhere. 31 // anywhere.
31 base::ThreadRestrictions::ScopedAllowIO allow_io; 32 base::ThreadRestrictions::ScopedAllowIO allow_io;
32 33
33 net::URLRequestFilter::GetInstance()->ClearHandlers(); 34 net::URLRequestFilter::GetInstance()->ClearHandlers();
34 35
35 URLRequestFailedDnsJob::AddUrlHandler(); 36 URLRequestFailedDnsJob::AddUrlHandler();
36 URLRequestMockLinkDoctorJob::AddUrlHandler(); 37 URLRequestMockLinkDoctorJob::AddUrlHandler();
37 URLRequestSlowDownloadJob::AddUrlHandler(); 38 URLRequestSlowDownloadJob::AddUrlHandler();
38 39
39 FilePath root_http; 40 FilePath test_dir;
40 PathService::Get(chrome::DIR_TEST_DATA, &root_http); 41 if (!PathService::Get(chrome::DIR_TEST_DATA, &test_dir))
41 URLRequestMockHTTPJob::AddUrlHandler(root_http); 42 NOTREACHED();
42 URLRequestSlowHTTPJob::AddUrlHandler(root_http); 43 URLRequestMockHTTPJob::AddUrlHandler(test_dir);
44 URLRequestSlowHTTPJob::AddUrlHandler(test_dir);
45
46 FilePath temp_dir;
47 if (!file_util::GetTempDir(&temp_dir))
48 NOTREACHED();
49 URLRequestMockHTTPJob::AddUrlOfTempDirHandler(temp_dir);
43 } else { 50 } else {
44 // Revert to the default handlers. 51 // Revert to the default handlers.
45 net::URLRequestFilter::GetInstance()->ClearHandlers(); 52 net::URLRequestFilter::GetInstance()->ClearHandlers();
46 } 53 }
47 } 54 }
48 55
49 } // namespace chrome_browser_net 56 } // namespace chrome_browser_net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698