OLD | NEW |
---|---|
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 #ifndef CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_INTERCEPTOR_H_ | 5 #ifndef CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_INTERCEPTOR_H_ |
6 #define CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_INTERCEPTOR_H_ | 6 #define CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_INTERCEPTOR_H_ |
7 | 7 |
8 #include <string> | |
9 | |
8 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
9 | 11 |
10 class GURL; | 12 class GURL; |
11 | 13 |
12 namespace base { | 14 namespace base { |
13 class FilePath; | 15 class FilePath; |
14 } | 16 } |
15 | 17 |
16 namespace content { | 18 namespace content { |
17 | 19 |
18 // Intercepts HTTP requests and gives pre-defined responses to specified URLs. | 20 // Intercepts HTTP requests and gives pre-defined responses to specified URLs. |
19 // The pre-defined responses are loaded from files on disk. The interception | 21 // The pre-defined responses are loaded from files on disk. The interception |
20 // occurs while the URLRequestPrepackagedInterceptor is alive. | 22 // occurs while the URLRequestPrepackagedInterceptor is alive. |
21 class URLRequestPrepackagedInterceptor { | 23 class URLRequestPrepackagedInterceptor { |
22 public: | 24 public: |
23 URLRequestPrepackagedInterceptor(); | 25 URLRequestPrepackagedInterceptor(const std::string& scheme, |
agl
2013/03/26 22:27:16
This constructor needs a comment.
rpaquay
2013/03/27 22:57:25
Done.
| |
26 const std::string& hostname); | |
24 virtual ~URLRequestPrepackagedInterceptor(); | 27 virtual ~URLRequestPrepackagedInterceptor(); |
25 | 28 |
26 // When requests for |url| arrive, respond with the contents of |path|. The | 29 // When requests for |url| arrive, respond with the contents of |path|. The |
27 // hostname of |url| must be "localhost" to avoid DNS lookups, and the scheme | 30 // hostname and scheme of |url| must match the corresponding parameters |
28 // must be "http". | 31 // passed as constructor arguments. |
29 void SetResponse(const GURL& url, const base::FilePath& path); | 32 void SetResponse(const GURL& url, const base::FilePath& path); |
30 | 33 |
31 // Identical to SetResponse except that query parameters are ignored on | 34 // Identical to SetResponse except that query parameters are ignored on |
32 // incoming URLs when comparing against |url|. | 35 // incoming URLs when comparing against |url|. |
33 void SetResponseIgnoreQuery(const GURL& url, const base::FilePath& path); | 36 void SetResponseIgnoreQuery(const GURL& url, const base::FilePath& path); |
34 | 37 |
35 // Returns how many requests have been issued that have a stored reply. | 38 // Returns how many requests have been issued that have a stored reply. |
36 int GetHitCount(); | 39 int GetHitCount(); |
37 | 40 |
38 private: | 41 private: |
39 class Delegate; | 42 class Delegate; |
40 | 43 |
44 std::string scheme_; | |
agl
2013/03/26 22:27:16
can be const I think.
rpaquay
2013/03/27 22:57:25
Done.
| |
45 std::string hostname_; | |
46 | |
41 // After creation, |delegate_| lives on the IO thread, and a task to delete | 47 // After creation, |delegate_| lives on the IO thread, and a task to delete |
42 // it is posted from ~URLRequestPrepackagedInterceptor(). | 48 // it is posted from ~URLRequestPrepackagedInterceptor(). |
43 Delegate* delegate_; | 49 Delegate* delegate_; |
44 | 50 |
45 DISALLOW_COPY_AND_ASSIGN(URLRequestPrepackagedInterceptor); | 51 DISALLOW_COPY_AND_ASSIGN(URLRequestPrepackagedInterceptor); |
46 }; | 52 }; |
47 | 53 |
54 // Intercepts HTTP requests and gives pre-defined responses to specified URLs. | |
agl
2013/03/26 22:27:16
Is this actually useful? It seems that just using
rpaquay
2013/03/27 22:57:25
I don't have a strong opinion on this. The common
| |
55 // The hostname of urls must be "localhost", and the scheme must be "http". | |
56 class URLLocalHostRequestPrepackagedInterceptor | |
57 : public URLRequestPrepackagedInterceptor { | |
58 public: | |
59 URLLocalHostRequestPrepackagedInterceptor(); | |
60 | |
61 private: | |
62 DISALLOW_COPY_AND_ASSIGN(URLLocalHostRequestPrepackagedInterceptor); | |
63 }; | |
64 | |
48 } // namespace content | 65 } // namespace content |
49 | 66 |
50 #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_INTERCEPTOR_H_ | 67 #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_INTERCEPTOR_H_ |
OLD | NEW |