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 CONTENT_BROWSER_APPCACHE_APPCACHE_UPDATE_JOB_H_ | 5 #ifndef CONTENT_BROWSER_APPCACHE_APPCACHE_UPDATE_JOB_H_ |
6 #define CONTENT_BROWSER_APPCACHE_APPCACHE_UPDATE_JOB_H_ | 6 #define CONTENT_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> |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 17 #include "base/timer/timer.h" |
17 #include "content/browser/appcache/appcache.h" | 18 #include "content/browser/appcache/appcache.h" |
18 #include "content/browser/appcache/appcache_host.h" | 19 #include "content/browser/appcache/appcache_host.h" |
19 #include "content/browser/appcache/appcache_response.h" | 20 #include "content/browser/appcache/appcache_response.h" |
20 #include "content/browser/appcache/appcache_service_impl.h" | 21 #include "content/browser/appcache/appcache_service_impl.h" |
21 #include "content/browser/appcache/appcache_storage.h" | 22 #include "content/browser/appcache/appcache_storage.h" |
22 #include "content/common/appcache_interfaces.h" | 23 #include "content/common/appcache_interfaces.h" |
23 #include "content/common/content_export.h" | 24 #include "content/common/content_export.h" |
24 #include "net/base/completion_callback.h" | 25 #include "net/base/completion_callback.h" |
25 #include "net/http/http_response_headers.h" | 26 #include "net/http/http_response_headers.h" |
26 #include "net/url_request/url_request.h" | 27 #include "net/url_request/url_request.h" |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 scoped_refptr<net::IOBuffer> buffer_; | 155 scoped_refptr<net::IOBuffer> buffer_; |
155 scoped_ptr<net::URLRequest> request_; | 156 scoped_ptr<net::URLRequest> request_; |
156 AppCacheEntry existing_entry_; | 157 AppCacheEntry existing_entry_; |
157 scoped_refptr<net::HttpResponseHeaders> existing_response_headers_; | 158 scoped_refptr<net::HttpResponseHeaders> existing_response_headers_; |
158 std::string manifest_data_; | 159 std::string manifest_data_; |
159 ResultType result_; | 160 ResultType result_; |
160 int redirect_response_code_; | 161 int redirect_response_code_; |
161 scoped_ptr<AppCacheResponseWriter> response_writer_; | 162 scoped_ptr<AppCacheResponseWriter> response_writer_; |
162 }; // class URLFetcher | 163 }; // class URLFetcher |
163 | 164 |
| 165 void DelayableStart(); |
| 166 |
164 AppCacheResponseWriter* CreateResponseWriter(); | 167 AppCacheResponseWriter* CreateResponseWriter(); |
165 | 168 |
166 // Methods for AppCacheStorage::Delegate. | 169 // Methods for AppCacheStorage::Delegate. |
167 void OnResponseInfoLoaded(AppCacheResponseInfo* response_info, | 170 void OnResponseInfoLoaded(AppCacheResponseInfo* response_info, |
168 int64 response_id) override; | 171 int64 response_id) override; |
169 void OnGroupAndNewestCacheStored(AppCacheGroup* group, | 172 void OnGroupAndNewestCacheStored(AppCacheGroup* group, |
170 AppCache* newest_cache, | 173 AppCache* newest_cache, |
171 bool success, | 174 bool success, |
172 bool would_exceed_quota) override; | 175 bool would_exceed_quota) override; |
173 void OnGroupMadeObsolete(AppCacheGroup* group, | 176 void OnGroupMadeObsolete(AppCacheGroup* group, |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 // have to delete the duplicates upon successful update. These ids | 331 // have to delete the duplicates upon successful update. These ids |
329 // are also in the stored_response_ids_ collection so we only schedule | 332 // are also in the stored_response_ids_ collection so we only schedule |
330 // these for deletion on success. | 333 // these for deletion on success. |
331 // TODO(michaeln): Rework when we no longer fetches master entries directly. | 334 // TODO(michaeln): Rework when we no longer fetches master entries directly. |
332 std::vector<int64> duplicate_response_ids_; | 335 std::vector<int64> duplicate_response_ids_; |
333 | 336 |
334 // Whether we've stored the resulting group/cache yet. | 337 // Whether we've stored the resulting group/cache yet. |
335 StoredState stored_state_; | 338 StoredState stored_state_; |
336 | 339 |
337 AppCacheStorage* storage_; | 340 AppCacheStorage* storage_; |
| 341 base::OneShotTimer<AppCacheUpdateJob> delayed_start_timer_; |
| 342 base::WeakPtrFactory<AppCacheUpdateJob> weak_factory_; |
338 | 343 |
339 FRIEND_TEST_ALL_PREFIXES(content::AppCacheGroupTest, QueueUpdate); | 344 FRIEND_TEST_ALL_PREFIXES(content::AppCacheGroupTest, QueueUpdate); |
340 | 345 |
341 DISALLOW_COPY_AND_ASSIGN(AppCacheUpdateJob); | 346 DISALLOW_COPY_AND_ASSIGN(AppCacheUpdateJob); |
342 }; | 347 }; |
343 | 348 |
344 } // namespace content | 349 } // namespace content |
345 | 350 |
346 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_UPDATE_JOB_H_ | 351 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_UPDATE_JOB_H_ |
OLD | NEW |