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 WEBKIT_BROWSER_APPCACHE_APPCACHE_UPDATE_JOB_H_ | 5 #ifndef WEBKIT_BROWSER_APPCACHE_APPCACHE_UPDATE_JOB_H_ |
6 #define WEBKIT_BROWSER_APPCACHE_APPCACHE_UPDATE_JOB_H_ | 6 #define WEBKIT_BROWSER_APPCACHE_APPCACHE_UPDATE_JOB_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 AppCacheResponseWriter* response_writer() const { | 120 AppCacheResponseWriter* response_writer() const { |
121 return response_writer_.get(); | 121 return response_writer_.get(); |
122 } | 122 } |
123 void set_existing_response_headers(net::HttpResponseHeaders* headers) { | 123 void set_existing_response_headers(net::HttpResponseHeaders* headers) { |
124 existing_response_headers_ = headers; | 124 existing_response_headers_ = headers; |
125 } | 125 } |
126 void set_existing_entry(const AppCacheEntry& entry) { | 126 void set_existing_entry(const AppCacheEntry& entry) { |
127 existing_entry_ = entry; | 127 existing_entry_ = entry; |
128 } | 128 } |
129 ResultType result() const { return result_; } | 129 ResultType result() const { return result_; } |
| 130 int redirect_response_code() const { return redirect_response_code_; } |
130 | 131 |
131 private: | 132 private: |
132 // URLRequest::Delegate overrides | 133 // URLRequest::Delegate overrides |
133 virtual void OnReceivedRedirect(net::URLRequest* request, | 134 virtual void OnReceivedRedirect(net::URLRequest* request, |
134 const GURL& new_url, | 135 const GURL& new_url, |
135 bool* defer_redirect) OVERRIDE; | 136 bool* defer_redirect) OVERRIDE; |
136 virtual void OnResponseStarted(net::URLRequest* request) OVERRIDE; | 137 virtual void OnResponseStarted(net::URLRequest* request) OVERRIDE; |
137 virtual void OnReadCompleted(net::URLRequest* request, | 138 virtual void OnReadCompleted(net::URLRequest* request, |
138 int bytes_read) OVERRIDE; | 139 int bytes_read) OVERRIDE; |
139 | 140 |
140 void AddConditionalHeaders(const net::HttpResponseHeaders* headers); | 141 void AddConditionalHeaders(const net::HttpResponseHeaders* headers); |
141 void OnWriteComplete(int result); | 142 void OnWriteComplete(int result); |
142 void ReadResponseData(); | 143 void ReadResponseData(); |
143 bool ConsumeResponseData(int bytes_read); | 144 bool ConsumeResponseData(int bytes_read); |
144 void OnResponseCompleted(); | 145 void OnResponseCompleted(); |
145 bool MaybeRetryRequest(); | 146 bool MaybeRetryRequest(); |
146 | 147 |
147 GURL url_; | 148 GURL url_; |
148 AppCacheUpdateJob* job_; | 149 AppCacheUpdateJob* job_; |
149 FetchType fetch_type_; | 150 FetchType fetch_type_; |
150 int retry_503_attempts_; | 151 int retry_503_attempts_; |
151 scoped_refptr<net::IOBuffer> buffer_; | 152 scoped_refptr<net::IOBuffer> buffer_; |
152 scoped_ptr<net::URLRequest> request_; | 153 scoped_ptr<net::URLRequest> request_; |
153 AppCacheEntry existing_entry_; | 154 AppCacheEntry existing_entry_; |
154 scoped_refptr<net::HttpResponseHeaders> existing_response_headers_; | 155 scoped_refptr<net::HttpResponseHeaders> existing_response_headers_; |
155 std::string manifest_data_; | 156 std::string manifest_data_; |
156 ResultType result_; | 157 ResultType result_; |
| 158 int redirect_response_code_; |
157 scoped_ptr<AppCacheResponseWriter> response_writer_; | 159 scoped_ptr<AppCacheResponseWriter> response_writer_; |
158 }; // class URLFetcher | 160 }; // class URLFetcher |
159 | 161 |
160 AppCacheResponseWriter* CreateResponseWriter(); | 162 AppCacheResponseWriter* CreateResponseWriter(); |
161 | 163 |
162 // Methods for AppCacheStorage::Delegate. | 164 // Methods for AppCacheStorage::Delegate. |
163 virtual void OnResponseInfoLoaded(AppCacheResponseInfo* response_info, | 165 virtual void OnResponseInfoLoaded(AppCacheResponseInfo* response_info, |
164 int64 response_id) OVERRIDE; | 166 int64 response_id) OVERRIDE; |
165 virtual void OnGroupAndNewestCacheStored(AppCacheGroup* group, | 167 virtual void OnGroupAndNewestCacheStored(AppCacheGroup* group, |
166 AppCache* newest_cache, | 168 AppCache* newest_cache, |
167 bool success, | 169 bool success, |
168 bool would_exceed_quota) OVERRIDE; | 170 bool would_exceed_quota) OVERRIDE; |
169 virtual void OnGroupMadeObsolete(AppCacheGroup* group, bool success) OVERRIDE; | 171 virtual void OnGroupMadeObsolete(AppCacheGroup* group, |
| 172 bool success, |
| 173 int response_code) OVERRIDE; |
170 | 174 |
171 // Methods for AppCacheHost::Observer. | 175 // Methods for AppCacheHost::Observer. |
172 virtual void OnCacheSelectionComplete(AppCacheHost* host) OVERRIDE {} // N/A | 176 virtual void OnCacheSelectionComplete(AppCacheHost* host) OVERRIDE {} // N/A |
173 virtual void OnDestructionImminent(AppCacheHost* host) OVERRIDE; | 177 virtual void OnDestructionImminent(AppCacheHost* host) OVERRIDE; |
174 | 178 |
175 // Methods for AppCacheService::Observer. | 179 // Methods for AppCacheService::Observer. |
176 virtual void OnServiceReinitialized( | 180 virtual void OnServiceReinitialized( |
177 AppCacheStorageReference* old_storage) OVERRIDE; | 181 AppCacheStorageReference* old_storage) OVERRIDE; |
178 | 182 |
179 void HandleCacheFailure(const std::string& error_message, | 183 void HandleCacheFailure(const ErrorDetails& details, |
180 ResultType result, | 184 ResultType result, |
181 const GURL& failed_resource_url); | 185 const GURL& failed_resource_url); |
182 | 186 |
183 void FetchManifest(bool is_first_fetch); | 187 void FetchManifest(bool is_first_fetch); |
184 void HandleManifestFetchCompleted(URLFetcher* fetcher); | 188 void HandleManifestFetchCompleted(URLFetcher* fetcher); |
185 void ContinueHandleManifestFetchCompleted(bool changed); | 189 void ContinueHandleManifestFetchCompleted(bool changed); |
186 | 190 |
187 void HandleUrlFetchCompleted(URLFetcher* fetcher); | 191 void HandleUrlFetchCompleted(URLFetcher* fetcher); |
188 void HandleMasterEntryFetchCompleted(URLFetcher* fetcher); | 192 void HandleMasterEntryFetchCompleted(URLFetcher* fetcher); |
189 | 193 |
190 void HandleManifestRefetchCompleted(URLFetcher* fetcher); | 194 void HandleManifestRefetchCompleted(URLFetcher* fetcher); |
191 void OnManifestInfoWriteComplete(int result); | 195 void OnManifestInfoWriteComplete(int result); |
192 void OnManifestDataWriteComplete(int result); | 196 void OnManifestDataWriteComplete(int result); |
193 | 197 |
194 void StoreGroupAndCache(); | 198 void StoreGroupAndCache(); |
195 | 199 |
196 void NotifySingleHost(AppCacheHost* host, EventID event_id); | 200 void NotifySingleHost(AppCacheHost* host, EventID event_id); |
197 void NotifyAllAssociatedHosts(EventID event_id); | 201 void NotifyAllAssociatedHosts(EventID event_id); |
198 void NotifyAllProgress(const GURL& url); | 202 void NotifyAllProgress(const GURL& url); |
199 void NotifyAllFinalProgress(); | 203 void NotifyAllFinalProgress(); |
200 void NotifyAllError(const std::string& error_message); | 204 void NotifyAllError(const ErrorDetails& detals); |
201 void AddAllAssociatedHostsToNotifier(HostNotifier* notifier); | 205 void AddAllAssociatedHostsToNotifier(HostNotifier* notifier); |
202 | 206 |
203 // Checks if manifest is byte for byte identical with the manifest | 207 // Checks if manifest is byte for byte identical with the manifest |
204 // in the newest application cache. | 208 // in the newest application cache. |
205 void CheckIfManifestChanged(); | 209 void CheckIfManifestChanged(); |
206 void OnManifestDataReadComplete(int result); | 210 void OnManifestDataReadComplete(int result); |
207 | 211 |
208 // Creates the list of files that may need to be fetched and initiates | 212 // Creates the list of files that may need to be fetched and initiates |
209 // fetches. Section 6.9.4 steps 12-17 | 213 // fetches. Section 6.9.4 steps 12-17 |
210 void BuildUrlFileList(const Manifest& manifest); | 214 void BuildUrlFileList(const Manifest& manifest); |
211 void AddUrlToFileList(const GURL& url, int type); | 215 void AddUrlToFileList(const GURL& url, int type); |
212 void FetchUrls(); | 216 void FetchUrls(); |
213 void CancelAllUrlFetches(); | 217 void CancelAllUrlFetches(); |
214 bool ShouldSkipUrlFetch(const AppCacheEntry& entry); | 218 bool ShouldSkipUrlFetch(const AppCacheEntry& entry); |
215 | 219 |
216 // If entry already exists in the cache currently being updated, merge | 220 // If entry already exists in the cache currently being updated, merge |
217 // the entry type information with the existing entry. | 221 // the entry type information with the existing entry. |
218 // Returns true if entry exists in cache currently being updated. | 222 // Returns true if entry exists in cache currently being updated. |
219 bool AlreadyFetchedEntry(const GURL& url, int entry_type); | 223 bool AlreadyFetchedEntry(const GURL& url, int entry_type); |
220 | 224 |
221 // TODO(jennb): Delete when update no longer fetches master entries directly. | 225 // TODO(jennb): Delete when update no longer fetches master entries directly. |
222 // Creates the list of master entries that need to be fetched and initiates | 226 // Creates the list of master entries that need to be fetched and initiates |
223 // fetches. | 227 // fetches. |
224 void AddMasterEntryToFetchList(AppCacheHost* host, const GURL& url, | 228 void AddMasterEntryToFetchList(AppCacheHost* host, const GURL& url, |
225 bool is_new); | 229 bool is_new); |
226 void FetchMasterEntries(); | 230 void FetchMasterEntries(); |
227 void CancelAllMasterEntryFetches(const std::string& error_message); | 231 void CancelAllMasterEntryFetches(const ErrorDetails& details); |
228 | 232 |
229 // Asynchronously loads the entry from the newest complete cache if the | 233 // Asynchronously loads the entry from the newest complete cache if the |
230 // HTTP caching semantics allow. | 234 // HTTP caching semantics allow. |
231 // Returns false if immediately obvious that data cannot be loaded from | 235 // Returns false if immediately obvious that data cannot be loaded from |
232 // newest complete cache. | 236 // newest complete cache. |
233 bool MaybeLoadFromNewestCache(const GURL& url, AppCacheEntry& entry); | 237 bool MaybeLoadFromNewestCache(const GURL& url, AppCacheEntry& entry); |
234 void LoadFromNewestCacheFailed(const GURL& url, | 238 void LoadFromNewestCacheFailed(const GURL& url, |
235 AppCacheResponseInfo* newest_response_info); | 239 AppCacheResponseInfo* newest_response_info); |
236 | 240 |
237 // Does nothing if update process is still waiting for pending master | 241 // Does nothing if update process is still waiting for pending master |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 AppCacheStorage* storage_; | 334 AppCacheStorage* storage_; |
331 | 335 |
332 FRIEND_TEST_ALL_PREFIXES(AppCacheGroupTest, QueueUpdate); | 336 FRIEND_TEST_ALL_PREFIXES(AppCacheGroupTest, QueueUpdate); |
333 | 337 |
334 DISALLOW_COPY_AND_ASSIGN(AppCacheUpdateJob); | 338 DISALLOW_COPY_AND_ASSIGN(AppCacheUpdateJob); |
335 }; | 339 }; |
336 | 340 |
337 } // namespace appcache | 341 } // namespace appcache |
338 | 342 |
339 #endif // WEBKIT_BROWSER_APPCACHE_APPCACHE_UPDATE_JOB_H_ | 343 #endif // WEBKIT_BROWSER_APPCACHE_APPCACHE_UPDATE_JOB_H_ |
OLD | NEW |