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

Side by Side Diff: content/browser/net/url_request_mock_http_job.h

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 // A net::URLRequestJob class that pulls the content and http headers from disk. 5 // A net::URLRequestJob class that pulls the content and http headers from disk.
6 6
7 #ifndef CONTENT_BROWSER_NET_URL_REQUEST_MOCK_HTTP_JOB_H_ 7 #ifndef CONTENT_BROWSER_NET_URL_REQUEST_MOCK_HTTP_JOB_H_
8 #define CONTENT_BROWSER_NET_URL_REQUEST_MOCK_HTTP_JOB_H_ 8 #define CONTENT_BROWSER_NET_URL_REQUEST_MOCK_HTTP_JOB_H_
9 #pragma once 9 #pragma once
10 10
11 #include <string> 11 #include <string>
12 12
13 #include "net/url_request/url_request_file_job.h" 13 #include "net/url_request/url_request_file_job.h"
14 14
15 class FilePath; 15 class FilePath;
16 16
17 class URLRequestMockHTTPJob : public net::URLRequestFileJob { 17 class URLRequestMockHTTPJob : public net::URLRequestFileJob {
18 public: 18 public:
19 URLRequestMockHTTPJob(net::URLRequest* request, const FilePath& file_path); 19 URLRequestMockHTTPJob(net::URLRequest* request, const FilePath& file_path);
20 20
21 virtual bool GetMimeType(std::string* mime_type) const; 21 virtual bool GetMimeType(std::string* mime_type) const;
22 virtual bool GetCharset(std::string* charset); 22 virtual bool GetCharset(std::string* charset);
23 virtual void GetResponseInfo(net::HttpResponseInfo* info); 23 virtual void GetResponseInfo(net::HttpResponseInfo* info);
24 virtual bool IsRedirectResponse(GURL* location, int* http_status_code); 24 virtual bool IsRedirectResponse(GURL* location, int* http_status_code);
25 25
26 static net::URLRequest::ProtocolFactory Factory; 26 static net::URLRequest::ProtocolFactory Factory;
27 static net::URLRequest::ProtocolFactory FactoryForMockUrlOfTempDir;
eroman 2011/08/04 20:09:44 Our style disallows non-POD static initializers. L
haraken1 2011/08/08 06:18:53 Done.
27 28
28 // Adds the testing URLs to the net::URLRequestFilter. 29 // Adds URLs for the DIR_TEST_DATA directory to the net::URLRequestFilter.
29 static void AddUrlHandler(const FilePath& base_path); 30 static void AddUrlHandler(const FilePath& test_dir);
30 31
31 // Given the path to a file relative to base_path_, construct a mock URL. 32 // Adds URLs for the temporary directory to the net::URLRequestFilter.
33 static void AddUrlOfTempDirHandler(const FilePath& temp_dir);
34
35 // Given the path to a file relative to the DIR_TEST_DATA directory,
36 // construct a mock URL.
32 static GURL GetMockUrl(const FilePath& path); 37 static GURL GetMockUrl(const FilePath& path);
33 38
34 // Given the path to a file relative to base_path_, 39 // Given the path to a file relative to the temporary directory,
40 // construct a mock URL.
41 static GURL GetMockUrlOfTempDir(const FilePath& path);
42
43 // Given the path to a file relative to test_dir_ or temp_dir_,
35 // construct a mock URL for view source. 44 // construct a mock URL for view source.
36 static GURL GetMockViewSourceUrl(const FilePath& path); 45 static GURL GetMockViewSourceUrl(const FilePath& path);
37 46
38 protected: 47 protected:
39 virtual ~URLRequestMockHTTPJob() { } 48 virtual ~URLRequestMockHTTPJob() { }
40 49
41 static FilePath GetOnDiskPath(const FilePath& base_path, 50 static FilePath GetOnDiskPath(const FilePath& base_path,
42 net::URLRequest* request, 51 net::URLRequest* request,
43 const std::string& scheme); 52 const std::string& scheme);
44 53
45 private: 54 private:
46 void GetResponseInfoConst(net::HttpResponseInfo* info) const; 55 void GetResponseInfoConst(net::HttpResponseInfo* info) const;
47 56
48 // This is the file path leading to the root of the directory to use as the 57 // The DIR_TEST_DATA directory. This is used as the root directory
49 // root of the http server. 58 // of the http server.
50 static FilePath base_path_; 59 static FilePath test_dir_;
eroman 2011/08/04 20:09:44 See earlier comment --> no static initializers ple
haraken1 2011/08/08 06:18:53 Removed this variable.
60
61 // The temporary directory. This is used as the root directory
62 // of the http server.
63 static FilePath temp_dir_;
51 }; 64 };
52 65
53 #endif // CONTENT_BROWSER_NET_URL_REQUEST_MOCK_HTTP_JOB_H_ 66 #endif // CONTENT_BROWSER_NET_URL_REQUEST_MOCK_HTTP_JOB_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698