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

Side by Side Diff: chrome/browser/extensions/autoupdate_interceptor.h

Issue 11293252: Change Interceptors into URLRequestJobFactory::ProtocolHandlers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: some cleanup Created 8 years 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) 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_EXTENSIONS_AUTOUPDATE_INTERCEPTOR_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_AUTOUPDATE_INTERCEPTOR_H_
6 #define CHROME_BROWSER_EXTENSIONS_AUTOUPDATE_INTERCEPTOR_H_ 6 #define CHROME_BROWSER_EXTENSIONS_AUTOUPDATE_INTERCEPTOR_H_
7 7
8 #include <map>
9 #include <string> 8 #include <string>
10 9
11 #include "googleurl/src/gurl.h" 10 #include "base/basictypes.h"
12 #include "net/url_request/url_request.h" 11
12 class FilePath;
13 13
14 namespace extensions { 14 namespace extensions {
15 15
16 // This url request interceptor lets us respond to localhost http request urls 16 // This url request interceptor lets us respond to localhost http request urls
17 // with the contents of files on disk for use in tests. 17 // with the contents of files on disk for use in tests.
18 class AutoUpdateInterceptor 18 class AutoUpdateInterceptor {
19 : public net::URLRequest::Interceptor,
20 public base::RefCountedThreadSafe<AutoUpdateInterceptor> {
21 public: 19 public:
22 AutoUpdateInterceptor(); 20 AutoUpdateInterceptor();
23 21 virtual ~AutoUpdateInterceptor();
24 // When computing matches, this ignores query parameters (since the autoupdate
25 // fetch code appends a bunch of them to manifest fetches).
26 virtual net::URLRequestJob* MaybeIntercept(
27 net::URLRequest* request,
28 net::NetworkDelegate* network_delegate) OVERRIDE;
29 22
30 // When requests for |url| arrive, respond with the contents of |path|. The 23 // When requests for |url| arrive, respond with the contents of |path|. The
31 // hostname of |url| must be "localhost" to avoid DNS lookups, and the scheme 24 // hostname of |url| must be "localhost" to avoid DNS lookups, and the scheme
32 // must be "http" so MaybeIntercept can ignore "chrome" and other schemes. 25 // must be "http" so MaybeIntercept can ignore "chrome" and other schemes.
33 // Also, the match for |url| will ignore any query parameters. 26 // Also, the match for |url| will ignore any query parameters.
34 void SetResponse(const std::string url, const FilePath& path); 27 void SetResponse(const std::string url, const FilePath& path);
35 28
36 // A helper function to call SetResponse on the I/O thread. 29 private:
37 void SetResponseOnIOThread(const std::string url, const FilePath& path); 30 class Delegate;
38 31
39 private: 32 Delegate* delegate_;
40 friend class base::RefCountedThreadSafe<AutoUpdateInterceptor>;
41
42 virtual ~AutoUpdateInterceptor();
43
44 std::map<GURL, FilePath> responses_;
45 33
46 DISALLOW_COPY_AND_ASSIGN(AutoUpdateInterceptor); 34 DISALLOW_COPY_AND_ASSIGN(AutoUpdateInterceptor);
47 }; 35 };
48 36
49 } // namespace extensions 37 } // namespace extensions
50 38
51 #endif // CHROME_BROWSER_EXTENSIONS_AUTOUPDATE_INTERCEPTOR_H_ 39 #endif // CHROME_BROWSER_EXTENSIONS_AUTOUPDATE_INTERCEPTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698