| 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 "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 | 9 |
| 10 class GURL; |
| 11 |
| 12 namespace base { |
| 10 class FilePath; | 13 class FilePath; |
| 11 class GURL; | 14 } |
| 12 | 15 |
| 13 namespace content { | 16 namespace content { |
| 14 | 17 |
| 15 // Intercepts HTTP requests and gives pre-defined responses to specified URLs. | 18 // Intercepts HTTP requests and gives pre-defined responses to specified URLs. |
| 16 // The pre-defined responses are loaded from files on disk. The interception | 19 // The pre-defined responses are loaded from files on disk. The interception |
| 17 // occurs while the URLRequestPrepackagedInterceptor is alive. | 20 // occurs while the URLRequestPrepackagedInterceptor is alive. |
| 18 class URLRequestPrepackagedInterceptor { | 21 class URLRequestPrepackagedInterceptor { |
| 19 public: | 22 public: |
| 20 URLRequestPrepackagedInterceptor(); | 23 URLRequestPrepackagedInterceptor(); |
| 21 virtual ~URLRequestPrepackagedInterceptor(); | 24 virtual ~URLRequestPrepackagedInterceptor(); |
| 22 | 25 |
| 23 // When requests for |url| arrive, respond with the contents of |path|. The | 26 // When requests for |url| arrive, respond with the contents of |path|. The |
| 24 // hostname of |url| must be "localhost" to avoid DNS lookups, and the scheme | 27 // hostname of |url| must be "localhost" to avoid DNS lookups, and the scheme |
| 25 // must be "http". | 28 // must be "http". |
| 26 void SetResponse(const GURL& url, const FilePath& path); | 29 void SetResponse(const GURL& url, const base::FilePath& path); |
| 27 | 30 |
| 28 // Identical to SetResponse except that query parameters are ignored on | 31 // Identical to SetResponse except that query parameters are ignored on |
| 29 // incoming URLs when comparing against |url|. | 32 // incoming URLs when comparing against |url|. |
| 30 void SetResponseIgnoreQuery(const GURL& url, const FilePath& path); | 33 void SetResponseIgnoreQuery(const GURL& url, const base::FilePath& path); |
| 31 | 34 |
| 32 // Returns how many requests have been issued that have a stored reply. | 35 // Returns how many requests have been issued that have a stored reply. |
| 33 int GetHitCount(); | 36 int GetHitCount(); |
| 34 | 37 |
| 35 private: | 38 private: |
| 36 class Delegate; | 39 class Delegate; |
| 37 | 40 |
| 38 // After creation, |delegate_| lives on the IO thread, and a task to delete | 41 // After creation, |delegate_| lives on the IO thread, and a task to delete |
| 39 // it is posted from ~URLRequestPrepackagedInterceptor(). | 42 // it is posted from ~URLRequestPrepackagedInterceptor(). |
| 40 Delegate* delegate_; | 43 Delegate* delegate_; |
| 41 | 44 |
| 42 DISALLOW_COPY_AND_ASSIGN(URLRequestPrepackagedInterceptor); | 45 DISALLOW_COPY_AND_ASSIGN(URLRequestPrepackagedInterceptor); |
| 43 }; | 46 }; |
| 44 | 47 |
| 45 } // namespace content | 48 } // namespace content |
| 46 | 49 |
| 47 #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_INTERCEPTOR_H_ | 50 #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_INTERCEPTOR_H_ |
| OLD | NEW |