| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #include "webkit/appcache/appcache_update_job.h" | 5 #include "webkit/appcache/appcache_update_job.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
| 11 #include "net/base/load_flags.h" | 11 #include "net/base/load_flags.h" |
| 12 #include "webkit/appcache/appcache_group.h" | 12 #include "webkit/appcache/appcache_group.h" |
| 13 #include "webkit/appcache/appcache_response.h" | 13 #include "webkit/appcache/appcache_response.h" |
| 14 | 14 |
| 15 namespace appcache { | 15 namespace appcache { |
| 16 | 16 |
| 17 static const int kBufferSize = 4096; | 17 static const int kBufferSize = 32768; |
| 18 static const size_t kMaxConcurrentUrlFetches = 2; | 18 static const size_t kMaxConcurrentUrlFetches = 2; |
| 19 static const int kMax503Retries = 3; | 19 static const int kMax503Retries = 3; |
| 20 | 20 |
| 21 // Extra info associated with requests for use during response processing. | 21 // Extra info associated with requests for use during response processing. |
| 22 // This info is deleted when the URLRequest is deleted. | 22 // This info is deleted when the URLRequest is deleted. |
| 23 class UpdateJobInfo : public URLRequest::UserData { | 23 class UpdateJobInfo : public URLRequest::UserData { |
| 24 public: | 24 public: |
| 25 enum RequestType { | 25 enum RequestType { |
| 26 MANIFEST_FETCH, | 26 MANIFEST_FETCH, |
| 27 URL_FETCH, | 27 URL_FETCH, |
| (...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 727 newest_cache = group_->newest_complete_cache(); | 727 newest_cache = group_->newest_complete_cache(); |
| 728 newest_cache->set_update_time(base::TimeTicks::Now()); | 728 newest_cache->set_update_time(base::TimeTicks::Now()); |
| 729 service_->storage()->StoreGroupAndNewestCache(group_, newest_cache, | 729 service_->storage()->StoreGroupAndNewestCache(group_, newest_cache, |
| 730 this); // async | 730 this); // async |
| 731 } | 731 } |
| 732 | 732 |
| 733 void AppCacheUpdateJob::OnGroupAndNewestCacheStored(AppCacheGroup* group, | 733 void AppCacheUpdateJob::OnGroupAndNewestCacheStored(AppCacheGroup* group, |
| 734 AppCache* newest_cache, | 734 AppCache* newest_cache, |
| 735 bool success) { | 735 bool success) { |
| 736 DCHECK(stored_state_ == STORING); | 736 DCHECK(stored_state_ == STORING); |
| 737 if (success) | 737 if (success) { |
| 738 stored_state_ = STORED; | 738 stored_state_ = STORED; |
| 739 else | 739 } else { |
| 740 internal_state_ = CACHE_FAILURE; | 740 internal_state_ = CACHE_FAILURE; |
| 741 |
| 742 // Restore inprogress_cache_ to get the proper events delivered |
| 743 // and the proper cleanup to occur. |
| 744 if (newest_cache != group->newest_complete_cache()) |
| 745 inprogress_cache_ = newest_cache; |
| 746 } |
| 741 MaybeCompleteUpdate(); // will definitely complete | 747 MaybeCompleteUpdate(); // will definitely complete |
| 742 } | 748 } |
| 743 | 749 |
| 744 void AppCacheUpdateJob::NotifySingleHost(AppCacheHost* host, | 750 void AppCacheUpdateJob::NotifySingleHost(AppCacheHost* host, |
| 745 EventID event_id) { | 751 EventID event_id) { |
| 746 std::vector<int> ids(1, host->host_id()); | 752 std::vector<int> ids(1, host->host_id()); |
| 747 host->frontend()->OnEventRaised(ids, event_id); | 753 host->frontend()->OnEventRaised(ids, event_id); |
| 748 } | 754 } |
| 749 | 755 |
| 750 void AppCacheUpdateJob::NotifyAllPendingMasterHosts(EventID event_id) { | 756 void AppCacheUpdateJob::NotifyAllPendingMasterHosts(EventID event_id) { |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1260 | 1266 |
| 1261 // Break the connection with the group so the group cannot call delete | 1267 // Break the connection with the group so the group cannot call delete |
| 1262 // on this object after we've posted a task to delete ourselves. | 1268 // on this object after we've posted a task to delete ourselves. |
| 1263 group_->SetUpdateStatus(AppCacheGroup::IDLE); | 1269 group_->SetUpdateStatus(AppCacheGroup::IDLE); |
| 1264 group_ = NULL; | 1270 group_ = NULL; |
| 1265 | 1271 |
| 1266 MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 1272 MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
| 1267 } | 1273 } |
| 1268 | 1274 |
| 1269 } // namespace appcache | 1275 } // namespace appcache |
| OLD | NEW |