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