| 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_working_set.h" | 5 #include "webkit/appcache/appcache_working_set.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "webkit/appcache/appcache.h" | 8 #include "webkit/appcache/appcache.h" |
| 9 #include "webkit/appcache/appcache_group.h" | 9 #include "webkit/appcache/appcache_group.h" |
| 10 #include "webkit/appcache/appcache_response.h" | 10 #include "webkit/appcache/appcache_response.h" |
| 11 | 11 |
| 12 namespace appcache { | 12 namespace appcache { |
| 13 | 13 |
| 14 AppCacheWorkingSet::~AppCacheWorkingSet() { | 14 AppCacheWorkingSet::~AppCacheWorkingSet() { |
| 15 DCHECK(caches_.empty()); | 15 DCHECK(caches_.empty()); |
| 16 DCHECK(groups_.empty()); | 16 DCHECK(groups_.empty()); |
| 17 } | 17 } |
| 18 | 18 |
| 19 void AppCacheWorkingSet::AddCache(AppCache* cache) { | 19 void AppCacheWorkingSet::AddCache(AppCache* cache) { |
| 20 DCHECK(cache->cache_id() != kNoCacheId); |
| 20 int64 cache_id = cache->cache_id(); | 21 int64 cache_id = cache->cache_id(); |
| 21 DCHECK(caches_.find(cache_id) == caches_.end()); | 22 DCHECK(caches_.find(cache_id) == caches_.end()); |
| 22 caches_.insert(CacheMap::value_type(cache_id, cache)); | 23 caches_.insert(CacheMap::value_type(cache_id, cache)); |
| 23 } | 24 } |
| 24 | 25 |
| 25 void AppCacheWorkingSet::RemoveCache(AppCache* cache) { | 26 void AppCacheWorkingSet::RemoveCache(AppCache* cache) { |
| 26 caches_.erase(cache->cache_id()); | 27 caches_.erase(cache->cache_id()); |
| 27 } | 28 } |
| 28 | 29 |
| 29 void AppCacheWorkingSet::AddGroup(AppCacheGroup* group) { | 30 void AppCacheWorkingSet::AddGroup(AppCacheGroup* group) { |
| 30 const GURL& url = group->manifest_url(); | 31 const GURL& url = group->manifest_url(); |
| 31 DCHECK(groups_.find(url) == groups_.end()); | 32 DCHECK(groups_.find(url) == groups_.end()); |
| 32 groups_.insert(GroupMap::value_type(url, group)); | 33 groups_.insert(GroupMap::value_type(url, group)); |
| 33 } | 34 } |
| 34 | 35 |
| 35 void AppCacheWorkingSet::RemoveGroup(AppCacheGroup* group) { | 36 void AppCacheWorkingSet::RemoveGroup(AppCacheGroup* group) { |
| 36 groups_.erase(group->manifest_url()); | 37 groups_.erase(group->manifest_url()); |
| 37 } | 38 } |
| 38 | 39 |
| 39 void AppCacheWorkingSet::AddResponseInfo(AppCacheResponseInfo* info) { | 40 void AppCacheWorkingSet::AddResponseInfo(AppCacheResponseInfo* info) { |
| 41 DCHECK(info->response_id() != kNoResponseId); |
| 40 int64 response_id = info->response_id(); | 42 int64 response_id = info->response_id(); |
| 41 DCHECK(response_infos_.find(response_id) == response_infos_.end()); | 43 DCHECK(response_infos_.find(response_id) == response_infos_.end()); |
| 42 response_infos_.insert(ResponseInfoMap::value_type(response_id, info)); | 44 response_infos_.insert(ResponseInfoMap::value_type(response_id, info)); |
| 43 } | 45 } |
| 44 | 46 |
| 45 void AppCacheWorkingSet::RemoveResponseInfo(AppCacheResponseInfo* info) { | 47 void AppCacheWorkingSet::RemoveResponseInfo(AppCacheResponseInfo* info) { |
| 46 response_infos_.erase(info->response_id()); | 48 response_infos_.erase(info->response_id()); |
| 47 } | 49 } |
| 48 | 50 |
| 49 } // namespace | 51 } // namespace |
| OLD | NEW |