OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_APPCACHE_APPCACHE_REQUEST_HANDLER_H_ | 5 #ifndef WEBKIT_APPCACHE_APPCACHE_REQUEST_HANDLER_H_ |
6 #define WEBKIT_APPCACHE_APPCACHE_REQUEST_HANDLER_H_ | 6 #define WEBKIT_APPCACHE_APPCACHE_REQUEST_HANDLER_H_ |
7 | 7 |
8 #include "net/url_request/url_request.h" | 8 #include "net/url_request/url_request.h" |
9 #include "webkit/appcache/appcache_entry.h" | 9 #include "webkit/appcache/appcache_entry.h" |
10 #include "webkit/appcache/appcache_host.h" | 10 #include "webkit/appcache/appcache_host.h" |
11 #include "webkit/glue/resource_type.h" | 11 #include "webkit/glue/resource_type.h" |
12 | 12 |
13 namespace net { | |
13 class URLRequest; | 14 class URLRequest; |
14 class URLRequestJob; | 15 class URLRequestJob; |
wtc
2010/11/30 01:51:53
Nit: we should not need the forward declaration of
| |
16 } // namespace net | |
15 | 17 |
16 namespace appcache { | 18 namespace appcache { |
17 | 19 |
18 class AppCacheURLRequestJob; | 20 class AppCacheURLRequestJob; |
19 | 21 |
20 // An instance is created for each URLRequest. The instance survives all | 22 // An instance is created for each URLRequest. The instance survives all |
21 // http transactions involved in the processing of its URLRequest, and is | 23 // http transactions involved in the processing of its URLRequest, and is |
22 // given the opportunity to hijack the request along the way. Callers | 24 // given the opportunity to hijack the request along the way. Callers |
23 // should use AppCacheHost::CreateRequestHandler to manufacture instances | 25 // should use AppCacheHost::CreateRequestHandler to manufacture instances |
24 // that can retrieve resources for a particular host. | 26 // that can retrieve resources for a particular host. |
25 class AppCacheRequestHandler : public URLRequest::UserData, | 27 class AppCacheRequestHandler : public net::URLRequest::UserData, |
26 public AppCacheHost::Observer, | 28 public AppCacheHost::Observer, |
27 public AppCacheStorage::Delegate { | 29 public AppCacheStorage::Delegate { |
28 public: | 30 public: |
29 virtual ~AppCacheRequestHandler(); | 31 virtual ~AppCacheRequestHandler(); |
30 | 32 |
31 // These are called on each request intercept opportunity. | 33 // These are called on each request intercept opportunity. |
32 AppCacheURLRequestJob* MaybeLoadResource(URLRequest* request); | 34 AppCacheURLRequestJob* MaybeLoadResource(net::URLRequest* request); |
33 AppCacheURLRequestJob* MaybeLoadFallbackForRedirect(URLRequest* request, | 35 AppCacheURLRequestJob* MaybeLoadFallbackForRedirect(net::URLRequest* request, |
34 const GURL& location); | 36 const GURL& location); |
35 AppCacheURLRequestJob* MaybeLoadFallbackForResponse(URLRequest* request); | 37 AppCacheURLRequestJob* MaybeLoadFallbackForResponse(net::URLRequest* request); |
36 | 38 |
37 void GetExtraResponseInfo(int64* cache_id, GURL* manifest_url); | 39 void GetExtraResponseInfo(int64* cache_id, GURL* manifest_url); |
38 | 40 |
39 static bool IsMainResourceType(ResourceType::Type type) { | 41 static bool IsMainResourceType(ResourceType::Type type) { |
40 return ResourceType::IsFrame(type) || | 42 return ResourceType::IsFrame(type) || |
41 ResourceType::IsSharedWorker(type); | 43 ResourceType::IsSharedWorker(type); |
42 } | 44 } |
43 | 45 |
44 private: | 46 private: |
45 friend class AppCacheHost; | 47 friend class AppCacheHost; |
(...skipping 15 matching lines...) Expand all Loading... | |
61 // Helper to retrieve a pointer to the storage object. | 63 // Helper to retrieve a pointer to the storage object. |
62 AppCacheStorage* storage() const; | 64 AppCacheStorage* storage() const; |
63 | 65 |
64 bool is_main_resource() const { | 66 bool is_main_resource() const { |
65 return IsMainResourceType(resource_type_); | 67 return IsMainResourceType(resource_type_); |
66 } | 68 } |
67 | 69 |
68 // Main-resource loading ------------------------------------- | 70 // Main-resource loading ------------------------------------- |
69 // Frame and SharedWorker main resources are handled here. | 71 // Frame and SharedWorker main resources are handled here. |
70 | 72 |
71 void MaybeLoadMainResource(URLRequest* request); | 73 void MaybeLoadMainResource(net::URLRequest* request); |
72 | 74 |
73 // AppCacheStorage::Delegate methods | 75 // AppCacheStorage::Delegate methods |
74 virtual void OnMainResponseFound( | 76 virtual void OnMainResponseFound( |
75 const GURL& url, const AppCacheEntry& entry, | 77 const GURL& url, const AppCacheEntry& entry, |
76 const GURL& fallback_url, const AppCacheEntry& fallback_entry, | 78 const GURL& fallback_url, const AppCacheEntry& fallback_entry, |
77 int64 cache_id, const GURL& mainfest_url, | 79 int64 cache_id, const GURL& mainfest_url, |
78 bool was_blocked_by_policy); | 80 bool was_blocked_by_policy); |
79 | 81 |
80 // Sub-resource loading ------------------------------------- | 82 // Sub-resource loading ------------------------------------- |
81 // Dedicated worker and all manner of sub-resources are handled here. | 83 // Dedicated worker and all manner of sub-resources are handled here. |
82 | 84 |
83 void MaybeLoadSubResource(URLRequest* request); | 85 void MaybeLoadSubResource(net::URLRequest* request); |
84 void ContinueMaybeLoadSubResource(); | 86 void ContinueMaybeLoadSubResource(); |
85 | 87 |
86 // AppCacheHost::Observer override | 88 // AppCacheHost::Observer override |
87 virtual void OnCacheSelectionComplete(AppCacheHost* host); | 89 virtual void OnCacheSelectionComplete(AppCacheHost* host); |
88 | 90 |
89 // Data members ----------------------------------------------- | 91 // Data members ----------------------------------------------- |
90 | 92 |
91 // What host we're servicing a request for. | 93 // What host we're servicing a request for. |
92 AppCacheHost* host_; | 94 AppCacheHost* host_; |
93 | 95 |
(...skipping 22 matching lines...) Expand all Loading... | |
116 scoped_refptr<AppCacheURLRequestJob> job_; | 118 scoped_refptr<AppCacheURLRequestJob> job_; |
117 | 119 |
118 friend class AppCacheRequestHandlerTest; | 120 friend class AppCacheRequestHandlerTest; |
119 DISALLOW_COPY_AND_ASSIGN(AppCacheRequestHandler); | 121 DISALLOW_COPY_AND_ASSIGN(AppCacheRequestHandler); |
120 }; | 122 }; |
121 | 123 |
122 } // namespace appcache | 124 } // namespace appcache |
123 | 125 |
124 #endif // WEBKIT_APPCACHE_APPCACHE_REQUEST_HANDLER_H_ | 126 #endif // WEBKIT_APPCACHE_APPCACHE_REQUEST_HANDLER_H_ |
125 | 127 |
OLD | NEW |