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 <stddef.h> |
| 9 #include <stdint.h> |
| 10 |
8 #include <deque> | 11 #include <deque> |
9 #include <map> | 12 #include <map> |
10 #include <set> | 13 #include <set> |
11 #include <string> | 14 #include <string> |
12 #include <vector> | 15 #include <vector> |
13 | 16 |
14 #include "base/gtest_prod_util.h" | 17 #include "base/gtest_prod_util.h" |
| 18 #include "base/macros.h" |
15 #include "base/memory/ref_counted.h" | 19 #include "base/memory/ref_counted.h" |
16 #include "base/memory/weak_ptr.h" | 20 #include "base/memory/weak_ptr.h" |
17 #include "base/time/time.h" | 21 #include "base/time/time.h" |
18 #include "content/browser/appcache/appcache.h" | 22 #include "content/browser/appcache/appcache.h" |
19 #include "content/browser/appcache/appcache_host.h" | 23 #include "content/browser/appcache/appcache_host.h" |
20 #include "content/browser/appcache/appcache_response.h" | 24 #include "content/browser/appcache/appcache_response.h" |
21 #include "content/browser/appcache/appcache_service_impl.h" | 25 #include "content/browser/appcache/appcache_service_impl.h" |
22 #include "content/browser/appcache/appcache_storage.h" | 26 #include "content/browser/appcache/appcache_storage.h" |
23 #include "content/common/appcache_interfaces.h" | 27 #include "content/common/appcache_interfaces.h" |
24 #include "content/common/content_export.h" | 28 #include "content/common/content_export.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 private: | 60 private: |
57 friend class content::AppCacheGroupTest; | 61 friend class content::AppCacheGroupTest; |
58 friend class content::AppCacheUpdateJobTest; | 62 friend class content::AppCacheUpdateJobTest; |
59 class URLFetcher; | 63 class URLFetcher; |
60 | 64 |
61 // Master entries have multiple hosts, for example, the same page is opened | 65 // Master entries have multiple hosts, for example, the same page is opened |
62 // in different tabs. | 66 // in different tabs. |
63 typedef std::vector<AppCacheHost*> PendingHosts; | 67 typedef std::vector<AppCacheHost*> PendingHosts; |
64 typedef std::map<GURL, PendingHosts> PendingMasters; | 68 typedef std::map<GURL, PendingHosts> PendingMasters; |
65 typedef std::map<GURL, URLFetcher*> PendingUrlFetches; | 69 typedef std::map<GURL, URLFetcher*> PendingUrlFetches; |
66 typedef std::map<int64, GURL> LoadingResponses; | 70 typedef std::map<int64_t, GURL> LoadingResponses; |
67 | 71 |
68 static const int kRerunDelayMs = 1000; | 72 static const int kRerunDelayMs = 1000; |
69 | 73 |
70 // TODO(michaeln): Rework the set of states vs update types vs stored states. | 74 // TODO(michaeln): Rework the set of states vs update types vs stored states. |
71 // The NO_UPDATE state is really more of an update type. For all update types | 75 // The NO_UPDATE state is really more of an update type. For all update types |
72 // storing the results is relevant. | 76 // storing the results is relevant. |
73 | 77 |
74 enum UpdateType { | 78 enum UpdateType { |
75 UNKNOWN_TYPE, | 79 UNKNOWN_TYPE, |
76 UPGRADE_ATTEMPT, | 80 UPGRADE_ATTEMPT, |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 std::string manifest_data_; | 163 std::string manifest_data_; |
160 ResultType result_; | 164 ResultType result_; |
161 int redirect_response_code_; | 165 int redirect_response_code_; |
162 scoped_ptr<AppCacheResponseWriter> response_writer_; | 166 scoped_ptr<AppCacheResponseWriter> response_writer_; |
163 }; // class URLFetcher | 167 }; // class URLFetcher |
164 | 168 |
165 AppCacheResponseWriter* CreateResponseWriter(); | 169 AppCacheResponseWriter* CreateResponseWriter(); |
166 | 170 |
167 // Methods for AppCacheStorage::Delegate. | 171 // Methods for AppCacheStorage::Delegate. |
168 void OnResponseInfoLoaded(AppCacheResponseInfo* response_info, | 172 void OnResponseInfoLoaded(AppCacheResponseInfo* response_info, |
169 int64 response_id) override; | 173 int64_t response_id) override; |
170 void OnGroupAndNewestCacheStored(AppCacheGroup* group, | 174 void OnGroupAndNewestCacheStored(AppCacheGroup* group, |
171 AppCache* newest_cache, | 175 AppCache* newest_cache, |
172 bool success, | 176 bool success, |
173 bool would_exceed_quota) override; | 177 bool would_exceed_quota) override; |
174 void OnGroupMadeObsolete(AppCacheGroup* group, | 178 void OnGroupMadeObsolete(AppCacheGroup* group, |
175 bool success, | 179 bool success, |
176 int response_code) override; | 180 int response_code) override; |
177 | 181 |
178 // Methods for AppCacheHost::Observer. | 182 // Methods for AppCacheHost::Observer. |
179 void OnCacheSelectionComplete(AppCacheHost* host) override {} // N/A | 183 void OnCacheSelectionComplete(AppCacheHost* host) override {} // N/A |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 std::string loaded_manifest_data_; | 322 std::string loaded_manifest_data_; |
319 scoped_ptr<AppCacheResponseReader> manifest_response_reader_; | 323 scoped_ptr<AppCacheResponseReader> manifest_response_reader_; |
320 bool manifest_has_valid_mime_type_; | 324 bool manifest_has_valid_mime_type_; |
321 | 325 |
322 // New master entries added to the cache by this job, used to cleanup | 326 // New master entries added to the cache by this job, used to cleanup |
323 // in error conditions. | 327 // in error conditions. |
324 std::vector<GURL> added_master_entries_; | 328 std::vector<GURL> added_master_entries_; |
325 | 329 |
326 // Response ids stored by this update job, used to cleanup in | 330 // Response ids stored by this update job, used to cleanup in |
327 // error conditions. | 331 // error conditions. |
328 std::vector<int64> stored_response_ids_; | 332 std::vector<int64_t> stored_response_ids_; |
329 | 333 |
330 // In some cases we fetch the same resource multiple times, and then | 334 // In some cases we fetch the same resource multiple times, and then |
331 // have to delete the duplicates upon successful update. These ids | 335 // have to delete the duplicates upon successful update. These ids |
332 // are also in the stored_response_ids_ collection so we only schedule | 336 // are also in the stored_response_ids_ collection so we only schedule |
333 // these for deletion on success. | 337 // these for deletion on success. |
334 // TODO(michaeln): Rework when we no longer fetches master entries directly. | 338 // TODO(michaeln): Rework when we no longer fetches master entries directly. |
335 std::vector<int64> duplicate_response_ids_; | 339 std::vector<int64_t> duplicate_response_ids_; |
336 | 340 |
337 // Whether we've stored the resulting group/cache yet. | 341 // Whether we've stored the resulting group/cache yet. |
338 StoredState stored_state_; | 342 StoredState stored_state_; |
339 | 343 |
340 AppCacheStorage* storage_; | 344 AppCacheStorage* storage_; |
341 base::WeakPtrFactory<AppCacheUpdateJob> weak_factory_; | 345 base::WeakPtrFactory<AppCacheUpdateJob> weak_factory_; |
342 | 346 |
343 FRIEND_TEST_ALL_PREFIXES(content::AppCacheGroupTest, QueueUpdate); | 347 FRIEND_TEST_ALL_PREFIXES(content::AppCacheGroupTest, QueueUpdate); |
344 | 348 |
345 DISALLOW_COPY_AND_ASSIGN(AppCacheUpdateJob); | 349 DISALLOW_COPY_AND_ASSIGN(AppCacheUpdateJob); |
346 }; | 350 }; |
347 | 351 |
348 } // namespace content | 352 } // namespace content |
349 | 353 |
350 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_UPDATE_JOB_H_ | 354 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_UPDATE_JOB_H_ |
OLD | NEW |