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 #include "webkit/appcache/appcache_quota_client.h" | 5 #include "webkit/appcache/appcache_quota_client.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 return; | 73 return; |
74 } | 74 } |
75 | 75 |
76 if (!appcache_is_ready_) { | 76 if (!appcache_is_ready_) { |
77 pending_batch_requests_.push_back( | 77 pending_batch_requests_.push_back( |
78 base::Bind(&AppCacheQuotaClient::GetOriginUsage, | 78 base::Bind(&AppCacheQuotaClient::GetOriginUsage, |
79 base::Unretained(this), origin, type, callback)); | 79 base::Unretained(this), origin, type, callback)); |
80 return; | 80 return; |
81 } | 81 } |
82 | 82 |
83 if (type == quota::kStorageTypePersistent) { | 83 if (type != quota::kStorageTypeTemporary) { |
84 callback.Run(0); | 84 callback.Run(0); |
85 return; | 85 return; |
86 } | 86 } |
87 | 87 |
88 const AppCacheStorage::UsageMap* map = GetUsageMap(); | 88 const AppCacheStorage::UsageMap* map = GetUsageMap(); |
89 AppCacheStorage::UsageMap::const_iterator found = map->find(origin); | 89 AppCacheStorage::UsageMap::const_iterator found = map->find(origin); |
90 if (found == map->end()) { | 90 if (found == map->end()) { |
91 callback.Run(0); | 91 callback.Run(0); |
92 return; | 92 return; |
93 } | 93 } |
(...skipping 29 matching lines...) Expand all Loading... |
123 } | 123 } |
124 | 124 |
125 if (!appcache_is_ready_ || !current_delete_request_callback_.is_null()) { | 125 if (!appcache_is_ready_ || !current_delete_request_callback_.is_null()) { |
126 pending_serial_requests_.push_back( | 126 pending_serial_requests_.push_back( |
127 base::Bind(&AppCacheQuotaClient::DeleteOriginData, | 127 base::Bind(&AppCacheQuotaClient::DeleteOriginData, |
128 base::Unretained(this), origin, type, callback)); | 128 base::Unretained(this), origin, type, callback)); |
129 return; | 129 return; |
130 } | 130 } |
131 | 131 |
132 current_delete_request_callback_ = callback; | 132 current_delete_request_callback_ = callback; |
133 if (type == quota::kStorageTypePersistent) { | 133 if (type != quota::kStorageTypeTemporary) { |
134 DidDeleteAppCachesForOrigin(net::OK); | 134 DidDeleteAppCachesForOrigin(net::OK); |
135 return; | 135 return; |
136 } | 136 } |
137 | 137 |
138 service_->DeleteAppCachesForOrigin( | 138 service_->DeleteAppCachesForOrigin( |
139 origin, GetServiceDeleteCallback()->callback()); | 139 origin, GetServiceDeleteCallback()->callback()); |
140 } | 140 } |
141 | 141 |
142 void AppCacheQuotaClient::DidDeleteAppCachesForOrigin(int rv) { | 142 void AppCacheQuotaClient::DidDeleteAppCachesForOrigin(int rv) { |
143 DCHECK(service_); | 143 DCHECK(service_); |
(...skipping 22 matching lines...) Expand all Loading... |
166 return; | 166 return; |
167 } | 167 } |
168 | 168 |
169 if (!appcache_is_ready_) { | 169 if (!appcache_is_ready_) { |
170 pending_batch_requests_.push_back( | 170 pending_batch_requests_.push_back( |
171 base::Bind(&AppCacheQuotaClient::GetOriginsHelper, | 171 base::Bind(&AppCacheQuotaClient::GetOriginsHelper, |
172 base::Unretained(this), type, opt_host, callback)); | 172 base::Unretained(this), type, opt_host, callback)); |
173 return; | 173 return; |
174 } | 174 } |
175 | 175 |
176 if (type == quota::kStorageTypePersistent) { | 176 if (type != quota::kStorageTypeTemporary) { |
177 callback.Run(std::set<GURL>(), type); | 177 callback.Run(std::set<GURL>(), type); |
178 return; | 178 return; |
179 } | 179 } |
180 | 180 |
181 const AppCacheStorage::UsageMap* map = GetUsageMap(); | 181 const AppCacheStorage::UsageMap* map = GetUsageMap(); |
182 std::set<GURL> origins; | 182 std::set<GURL> origins; |
183 for (AppCacheStorage::UsageMap::const_iterator iter = map->begin(); | 183 for (AppCacheStorage::UsageMap::const_iterator iter = map->begin(); |
184 iter != map->end(); ++iter) { | 184 iter != map->end(); ++iter) { |
185 if (opt_host.empty() || iter->first.host() == opt_host) | 185 if (opt_host.empty() || iter->first.host() == opt_host) |
186 origins.insert(iter->first); | 186 origins.insert(iter->first); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 current_delete_request_callback_.Run(quota::kQuotaErrorAbort); | 237 current_delete_request_callback_.Run(quota::kQuotaErrorAbort); |
238 current_delete_request_callback_.Reset(); | 238 current_delete_request_callback_.Reset(); |
239 GetServiceDeleteCallback()->Cancel(); | 239 GetServiceDeleteCallback()->Cancel(); |
240 } | 240 } |
241 | 241 |
242 if (quota_manager_is_destroyed_) | 242 if (quota_manager_is_destroyed_) |
243 delete this; | 243 delete this; |
244 } | 244 } |
245 | 245 |
246 } // namespace appcache | 246 } // namespace appcache |
OLD | NEW |