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

Side by Side Diff: webkit/browser/appcache/appcache_update_job.h

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

Powered by Google App Engine
This is Rietveld 408576698