OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 WEBKIT_BROWSER_APPCACHE_APPCACHE_EXECUTABLE_HANDLER_H_ | 5 #ifndef WEBKIT_BROWSER_APPCACHE_APPCACHE_EXECUTABLE_HANDLER_H_ |
6 #define WEBKIT_BROWSER_APPCACHE_APPCACHE_EXECUTABLE_HANDLER_H_ | 6 #define WEBKIT_BROWSER_APPCACHE_APPCACHE_EXECUTABLE_HANDLER_H_ |
7 | 7 |
| 8 #include <map> |
8 #include "base/callback.h" | 9 #include "base/callback.h" |
9 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
10 #include "url/gurl.h" | 11 #include "url/gurl.h" |
11 #include "webkit/browser/webkit_storage_browser_export.h" | 12 #include "webkit/browser/webkit_storage_browser_export.h" |
| 13 #include "webkit/common/appcache/appcache_interfaces.h" |
12 | 14 |
13 namespace net { | 15 namespace net { |
14 class IOBuffer; | 16 class IOBuffer; |
15 class URLRequest; | 17 class URLRequest; |
16 } | 18 } |
| 19 namespace fileapi { |
| 20 class FileSystemContext; |
| 21 } |
| 22 namespace webkit_blob { |
| 23 class BlobStorageController; |
| 24 } |
17 | 25 |
18 namespace appcache { | 26 namespace appcache { |
19 | 27 |
20 // An interface that must be provided by the embedder to support this feature. | 28 // An interface that must be provided by the embedder to support this feature. |
21 class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheExecutableHandler { | 29 class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheExecutableHandler : |
| 30 public AppCacheExecutableHandlerInterfaces { // so our request/response str
ucts are on a common lib |
22 public: | 31 public: |
23 // A handler can respond in one of 4 ways, if each of the GURL fields | |
24 // in 'Response' are empty and use_network is false, an error response is | |
25 // synthesized. | |
26 struct Response { | |
27 GURL cached_resource_url; | |
28 GURL redirect_url; | |
29 bool use_network; | |
30 // TODO: blob + headers would be a good one to provide as well, as it would | |
31 // make templating possible. | |
32 }; | |
33 typedef base::Callback<void(const Response&)> ResponseCallback; | 32 typedef base::Callback<void(const Response&)> ResponseCallback; |
34 | 33 |
35 // Deletion of the handler cancels all pending callbacks. | 34 // Deletion of the handler cancels all pending callbacks. |
36 virtual ~AppCacheExecutableHandler() {} | 35 virtual ~AppCacheExecutableHandler() {} |
37 | 36 |
38 virtual void HandleRequest(net::URLRequest* req, | 37 virtual void HandleRequest(const Request& request, |
39 ResponseCallback callback) = 0; | 38 ResponseCallback callback) = 0; |
40 }; | 39 }; |
41 | 40 |
42 // A factory to produce instances. | 41 // A factory to produce instances. |
43 class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheExecutableHandlerFactory { | 42 class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheExecutableHandlerFactory { |
44 public: | 43 public: |
45 virtual scoped_ptr<AppCacheExecutableHandler> CreateHandler( | 44 virtual scoped_ptr<AppCacheExecutableHandler> CreateHandler( |
46 const GURL& handler_url, net::IOBuffer* handler_source) = 0; | 45 int64 appcache_id, |
| 46 const GURL& handler_url, |
| 47 const std::string& raw_handler_source) = 0; |
| 48 |
| 49 // In order to return Blob responses, access to the blob and fileapi |
| 50 // contexts are needed. |
| 51 virtual webkit_blob::BlobStorageController* GetBlobStorageController() = 0; |
| 52 virtual fileapi::FileSystemContext* GetFileSystemContext() = 0; |
47 | 53 |
48 protected: | 54 protected: |
49 virtual ~AppCacheExecutableHandlerFactory() {} | 55 virtual ~AppCacheExecutableHandlerFactory() {} |
50 }; | 56 }; |
51 | 57 |
52 } // namespace appcache | 58 } // namespace appcache |
53 | 59 |
54 #endif // WEBKIT_BROWSER_APPCACHE_APPCACHE_EXECUTABLE_HANDLER_H_ | 60 #endif // WEBKIT_BROWSER_APPCACHE_APPCACHE_EXECUTABLE_HANDLER_H_ |
OLD | NEW |