| 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_storage.h" | 5 #include "webkit/appcache/appcache_storage.h" |
| 6 | 6 |
| 7 #include "base/stl_util-inl.h" | 7 #include "base/stl_util-inl.h" |
| 8 #include "webkit/appcache/appcache_response.h" | 8 #include "webkit/appcache/appcache_response.h" |
| 9 | 9 |
| 10 namespace appcache { | 10 namespace appcache { |
| 11 | 11 |
| 12 // static | 12 // static |
| 13 const int64 AppCacheStorage::kUnitializedId = -1; | 13 const int64 AppCacheStorage::kUnitializedId = -1; |
| 14 | 14 |
| 15 AppCacheStorage::AppCacheStorage(AppCacheService* service) | 15 AppCacheStorage::AppCacheStorage(AppCacheService* service) |
| 16 : last_cache_id_(kUnitializedId), last_group_id_(kUnitializedId), | 16 : last_cache_id_(kUnitializedId), last_group_id_(kUnitializedId), |
| 17 last_response_id_(kUnitializedId), service_(service) { | 17 last_response_id_(kUnitializedId), service_(service) { |
| 18 } | 18 } |
| 19 | 19 |
| 20 AppCacheStorage::~AppCacheStorage() { | 20 AppCacheStorage::~AppCacheStorage() { |
| 21 STLDeleteValues(&pending_info_loads_); | 21 STLDeleteValues(&pending_info_loads_); |
| 22 DCHECK(delegate_references_.empty()); | 22 DCHECK(delegate_references_.empty()); |
| 23 } | 23 } |
| 24 | 24 |
| 25 AppCacheStorage::DelegateReference::DelegateReference( |
| 26 Delegate* delegate, AppCacheStorage* storage) |
| 27 : delegate(delegate), storage(storage) { |
| 28 storage->delegate_references_.insert( |
| 29 DelegateReferenceMap::value_type(delegate, this)); |
| 30 } |
| 31 |
| 32 AppCacheStorage::DelegateReference::~DelegateReference() { |
| 33 if (delegate) |
| 34 storage->delegate_references_.erase(delegate); |
| 35 } |
| 36 |
| 25 AppCacheStorage::ResponseInfoLoadTask::ResponseInfoLoadTask( | 37 AppCacheStorage::ResponseInfoLoadTask::ResponseInfoLoadTask( |
| 26 const GURL& manifest_url, | 38 const GURL& manifest_url, |
| 27 int64 response_id, | 39 int64 response_id, |
| 28 AppCacheStorage* storage) | 40 AppCacheStorage* storage) |
| 29 : storage_(storage), | 41 : storage_(storage), |
| 30 manifest_url_(manifest_url), | 42 manifest_url_(manifest_url), |
| 31 response_id_(response_id), | 43 response_id_(response_id), |
| 32 info_buffer_(new HttpResponseInfoIOBuffer), | 44 info_buffer_(new HttpResponseInfoIOBuffer), |
| 33 ALLOW_THIS_IN_INITIALIZER_LIST(read_callback_( | 45 ALLOW_THIS_IN_INITIALIZER_LIST(read_callback_( |
| 34 this, &ResponseInfoLoadTask::OnReadComplete)) { | 46 this, &ResponseInfoLoadTask::OnReadComplete)) { |
| 35 storage_->pending_info_loads_.insert( | 47 storage_->pending_info_loads_.insert( |
| 36 PendingResponseInfoLoads::value_type(response_id, this)); | 48 PendingResponseInfoLoads::value_type(response_id, this)); |
| 37 } | 49 } |
| 38 | 50 |
| 51 AppCacheStorage::ResponseInfoLoadTask::~ResponseInfoLoadTask() { |
| 52 } |
| 53 |
| 39 void AppCacheStorage::ResponseInfoLoadTask::StartIfNeeded() { | 54 void AppCacheStorage::ResponseInfoLoadTask::StartIfNeeded() { |
| 40 if (reader_.get()) | 55 if (reader_.get()) |
| 41 return; | 56 return; |
| 42 reader_.reset( | 57 reader_.reset( |
| 43 storage_->CreateResponseReader(manifest_url_, response_id_)); | 58 storage_->CreateResponseReader(manifest_url_, response_id_)); |
| 44 reader_->ReadInfo(info_buffer_, &read_callback_); | 59 reader_->ReadInfo(info_buffer_, &read_callback_); |
| 45 } | 60 } |
| 46 | 61 |
| 47 void AppCacheStorage::ResponseInfoLoadTask::OnReadComplete(int result) { | 62 void AppCacheStorage::ResponseInfoLoadTask::OnReadComplete(int result) { |
| 48 storage_->pending_info_loads_.erase(response_id_); | 63 storage_->pending_info_loads_.erase(response_id_); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 int64 AppCacheStorage::GetOriginQuotaInMemory(const GURL& origin) { | 102 int64 AppCacheStorage::GetOriginQuotaInMemory(const GURL& origin) { |
| 88 DCHECK(origin == origin.GetOrigin()); | 103 DCHECK(origin == origin.GetOrigin()); |
| 89 QuotaMap::const_iterator found = in_memory_quotas_.find(origin); | 104 QuotaMap::const_iterator found = in_memory_quotas_.find(origin); |
| 90 if (found == in_memory_quotas_.end()) | 105 if (found == in_memory_quotas_.end()) |
| 91 return -1; | 106 return -1; |
| 92 return found->second; | 107 return found->second; |
| 93 } | 108 } |
| 94 | 109 |
| 95 } // namespace appcache | 110 } // namespace appcache |
| 96 | 111 |
| OLD | NEW |