| 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 "content/browser/appcache/appcache_storage.h" | 5 #include "content/browser/appcache/appcache_storage.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "content/browser/appcache/appcache_response.h" | 10 #include "content/browser/appcache/appcache_response.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 void AppCacheStorage::UpdateUsageMapAndNotify( | 98 void AppCacheStorage::UpdateUsageMapAndNotify( |
| 99 const GURL& origin, int64 new_usage) { | 99 const GURL& origin, int64 new_usage) { |
| 100 DCHECK_GE(new_usage, 0); | 100 DCHECK_GE(new_usage, 0); |
| 101 int64 old_usage = usage_map_[origin]; | 101 int64 old_usage = usage_map_[origin]; |
| 102 if (new_usage > 0) | 102 if (new_usage > 0) |
| 103 usage_map_[origin] = new_usage; | 103 usage_map_[origin] = new_usage; |
| 104 else | 104 else |
| 105 usage_map_.erase(origin); | 105 usage_map_.erase(origin); |
| 106 if (new_usage != old_usage && service()->quota_manager_proxy()) { | 106 if (new_usage != old_usage && service()->quota_manager_proxy()) { |
| 107 service()->quota_manager_proxy()->NotifyStorageModified( | 107 service()->quota_manager_proxy()->NotifyStorageModified( |
| 108 quota::QuotaClient::kAppcache, | 108 storage::QuotaClient::kAppcache, |
| 109 origin, quota::kStorageTypeTemporary, | 109 origin, |
| 110 storage::kStorageTypeTemporary, |
| 110 new_usage - old_usage); | 111 new_usage - old_usage); |
| 111 } | 112 } |
| 112 } | 113 } |
| 113 | 114 |
| 114 void AppCacheStorage::ClearUsageMapAndNotify() { | 115 void AppCacheStorage::ClearUsageMapAndNotify() { |
| 115 if (service()->quota_manager_proxy()) { | 116 if (service()->quota_manager_proxy()) { |
| 116 for (UsageMap::const_iterator iter = usage_map_.begin(); | 117 for (UsageMap::const_iterator iter = usage_map_.begin(); |
| 117 iter != usage_map_.end(); ++iter) { | 118 iter != usage_map_.end(); ++iter) { |
| 118 service()->quota_manager_proxy()->NotifyStorageModified( | 119 service()->quota_manager_proxy()->NotifyStorageModified( |
| 119 quota::QuotaClient::kAppcache, | 120 storage::QuotaClient::kAppcache, |
| 120 iter->first, quota::kStorageTypeTemporary, | 121 iter->first, |
| 122 storage::kStorageTypeTemporary, |
| 121 -(iter->second)); | 123 -(iter->second)); |
| 122 } | 124 } |
| 123 } | 125 } |
| 124 usage_map_.clear(); | 126 usage_map_.clear(); |
| 125 } | 127 } |
| 126 | 128 |
| 127 void AppCacheStorage::NotifyStorageAccessed(const GURL& origin) { | 129 void AppCacheStorage::NotifyStorageAccessed(const GURL& origin) { |
| 128 if (service()->quota_manager_proxy() && | 130 if (service()->quota_manager_proxy() && |
| 129 usage_map_.find(origin) != usage_map_.end()) | 131 usage_map_.find(origin) != usage_map_.end()) |
| 130 service()->quota_manager_proxy()->NotifyStorageAccessed( | 132 service()->quota_manager_proxy()->NotifyStorageAccessed( |
| 131 quota::QuotaClient::kAppcache, | 133 storage::QuotaClient::kAppcache, |
| 132 origin, quota::kStorageTypeTemporary); | 134 origin, |
| 135 storage::kStorageTypeTemporary); |
| 133 } | 136 } |
| 134 | 137 |
| 135 } // namespace content | 138 } // namespace content |
| 136 | 139 |
| OLD | NEW |