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 <algorithm> | 5 #include <algorithm> |
6 | 6 |
7 #include "webkit/appcache/appcache.h" | 7 #include "webkit/appcache/appcache.h" |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
11 #include "webkit/appcache/appcache_group.h" | 11 #include "webkit/appcache/appcache_group.h" |
12 #include "webkit/appcache/appcache_host.h" | 12 #include "webkit/appcache/appcache_host.h" |
13 #include "webkit/appcache/appcache_interfaces.h" | 13 #include "webkit/appcache/appcache_interfaces.h" |
14 #include "webkit/appcache/appcache_storage.h" | 14 #include "webkit/appcache/appcache_storage.h" |
15 | 15 |
16 namespace appcache { | 16 namespace appcache { |
17 | 17 |
18 AppCache::AppCache(AppCacheStorage* storage, int64 cache_id) | 18 AppCache::AppCache(AppCacheStorage* storage, int64 cache_id) |
19 : cache_id_(cache_id), | 19 : cache_id_(cache_id), |
20 owning_group_(NULL), | 20 owning_group_(NULL), |
21 online_whitelist_all_(false), | 21 online_whitelist_all_(false), |
22 is_complete_(false), | 22 is_complete_(false), |
23 cache_size_(0), | 23 cache_size_(0), |
24 storage_(storage) { | 24 storage_(storage) { |
25 storage_->working_set()->AddCache(this); | 25 storage_->working_set()->AddCache(this); |
26 } | 26 } |
27 | 27 |
28 AppCache::~AppCache() { | 28 AppCache::~AppCache() { |
29 DCHECK(associated_hosts_.empty()); | 29 DCHECK(associated_hosts_.empty()); |
30 if (owning_group_) { | 30 if (owning_group_.get()) { |
31 DCHECK(is_complete_); | 31 DCHECK(is_complete_); |
32 owning_group_->RemoveCache(this); | 32 owning_group_->RemoveCache(this); |
33 } | 33 } |
34 DCHECK(!owning_group_); | 34 DCHECK(!owning_group_.get()); |
35 storage_->working_set()->RemoveCache(this); | 35 storage_->working_set()->RemoveCache(this); |
36 } | 36 } |
37 | 37 |
38 void AppCache::UnassociateHost(AppCacheHost* host) { | 38 void AppCache::UnassociateHost(AppCacheHost* host) { |
39 associated_hosts_.erase(host); | 39 associated_hosts_.erase(host); |
40 } | 40 } |
41 | 41 |
42 void AppCache::AddEntry(const GURL& url, const AppCacheEntry& entry) { | 42 void AppCache::AddEntry(const GURL& url, const AppCacheEntry& entry) { |
43 DCHECK(entries_.find(url) == entries_.end()); | 43 DCHECK(entries_.find(url) == entries_.end()); |
44 entries_.insert(EntryMap::value_type(url, entry)); | 44 entries_.insert(EntryMap::value_type(url, entry)); |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 const GURL& url) { | 278 const GURL& url) { |
279 size_t count = namespaces.size(); | 279 size_t count = namespaces.size(); |
280 for (size_t i = 0; i < count; ++i) { | 280 for (size_t i = 0; i < count; ++i) { |
281 if (namespaces[i].IsMatch(url)) | 281 if (namespaces[i].IsMatch(url)) |
282 return &namespaces[i]; | 282 return &namespaces[i]; |
283 } | 283 } |
284 return NULL; | 284 return NULL; |
285 } | 285 } |
286 | 286 |
287 } // namespace appcache | 287 } // namespace appcache |
OLD | NEW |