OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
(...skipping 15 matching lines...) Expand all Loading... |
26 public: | 26 public: |
27 ComponentUpdateInterceptor(); | 27 ComponentUpdateInterceptor(); |
28 | 28 |
29 // 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 |
30 // hostname of |url| must be "localhost" to avoid DNS lookups, and the scheme | 30 // hostname of |url| must be "localhost" to avoid DNS lookups, and the scheme |
31 // must be "http". | 31 // must be "http". |
32 void SetResponse(const std::string& url, | 32 void SetResponse(const std::string& url, |
33 const std::string& headers, | 33 const std::string& headers, |
34 const FilePath& path); | 34 const FilePath& path); |
35 | 35 |
| 36 // Returns how many requests have been issued that have a stored reply. |
| 37 int hit_count() const { return hit_count_; } |
| 38 |
36 private: | 39 private: |
37 // When computing matches, this ignores the query parameters of the url. | 40 // When computing matches, this ignores the query parameters of the url. |
38 virtual net::URLRequestJob* MaybeIntercept(net::URLRequest* request) OVERRIDE; | 41 virtual net::URLRequestJob* MaybeIntercept(net::URLRequest* request) OVERRIDE; |
39 | 42 |
40 friend class base::RefCountedThreadSafe<ComponentUpdateInterceptor>; | 43 friend class base::RefCountedThreadSafe<ComponentUpdateInterceptor>; |
41 | 44 |
42 virtual ~ComponentUpdateInterceptor(); | 45 virtual ~ComponentUpdateInterceptor(); |
43 | 46 |
44 struct Response { | 47 struct Response { |
45 FilePath data_path; | 48 FilePath data_path; |
46 std::string headers; | 49 std::string headers; |
47 }; | 50 }; |
48 | 51 |
49 typedef std::map<GURL, Response> ResponseMap; | 52 typedef std::map<GURL, Response> ResponseMap; |
50 ResponseMap responses_; | 53 ResponseMap responses_; |
| 54 int hit_count_; |
51 | 55 |
52 DISALLOW_COPY_AND_ASSIGN(ComponentUpdateInterceptor); | 56 DISALLOW_COPY_AND_ASSIGN(ComponentUpdateInterceptor); |
53 }; | 57 }; |
54 | 58 |
55 #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_INTERCEPTOR_H_ | 59 #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_INTERCEPTOR_H_ |
OLD | NEW |