| 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 "content/browser/appcache/appcache.h" | 5 #include "content/browser/appcache/appcache.h" |
| 6 | 6 |
| 7 #include <stddef.h> |
| 8 |
| 7 #include <algorithm> | 9 #include <algorithm> |
| 8 | 10 |
| 9 #include "base/logging.h" | 11 #include "base/logging.h" |
| 10 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
| 11 #include "content/browser/appcache/appcache_executable_handler.h" | 13 #include "content/browser/appcache/appcache_executable_handler.h" |
| 12 #include "content/browser/appcache/appcache_group.h" | 14 #include "content/browser/appcache/appcache_group.h" |
| 13 #include "content/browser/appcache/appcache_host.h" | 15 #include "content/browser/appcache/appcache_host.h" |
| 14 #include "content/browser/appcache/appcache_storage.h" | 16 #include "content/browser/appcache/appcache_storage.h" |
| 15 #include "content/common/appcache_interfaces.h" | 17 #include "content/common/appcache_interfaces.h" |
| 16 | 18 |
| 17 namespace content { | 19 namespace content { |
| 18 | 20 |
| 19 AppCache::AppCache(AppCacheStorage* storage, int64 cache_id) | 21 AppCache::AppCache(AppCacheStorage* storage, int64_t cache_id) |
| 20 : cache_id_(cache_id), | 22 : cache_id_(cache_id), |
| 21 owning_group_(NULL), | 23 owning_group_(NULL), |
| 22 online_whitelist_all_(false), | 24 online_whitelist_all_(false), |
| 23 is_complete_(false), | 25 is_complete_(false), |
| 24 cache_size_(0), | 26 cache_size_(0), |
| 25 storage_(storage) { | 27 storage_(storage) { |
| 26 storage_->working_set()->AddCache(this); | 28 storage_->working_set()->AddCache(this); |
| 27 } | 29 } |
| 28 | 30 |
| 29 AppCache::~AppCache() { | 31 AppCache::~AppCache() { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 cache_size_ -= found->second.response_size(); | 68 cache_size_ -= found->second.response_size(); |
| 67 entries_.erase(found); | 69 entries_.erase(found); |
| 68 } | 70 } |
| 69 | 71 |
| 70 AppCacheEntry* AppCache::GetEntry(const GURL& url) { | 72 AppCacheEntry* AppCache::GetEntry(const GURL& url) { |
| 71 EntryMap::iterator it = entries_.find(url); | 73 EntryMap::iterator it = entries_.find(url); |
| 72 return (it != entries_.end()) ? &(it->second) : NULL; | 74 return (it != entries_.end()) ? &(it->second) : NULL; |
| 73 } | 75 } |
| 74 | 76 |
| 75 const AppCacheEntry* AppCache::GetEntryAndUrlWithResponseId( | 77 const AppCacheEntry* AppCache::GetEntryAndUrlWithResponseId( |
| 76 int64 response_id, GURL* optional_url_out) { | 78 int64_t response_id, |
| 79 GURL* optional_url_out) { |
| 77 for (EntryMap::const_iterator iter = entries_.begin(); | 80 for (EntryMap::const_iterator iter = entries_.begin(); |
| 78 iter != entries_.end(); ++iter) { | 81 iter != entries_.end(); ++iter) { |
| 79 if (iter->second.response_id() == response_id) { | 82 if (iter->second.response_id() == response_id) { |
| 80 if (optional_url_out) | 83 if (optional_url_out) |
| 81 *optional_url_out = iter->first; | 84 *optional_url_out = iter->first; |
| 82 return &iter->second; | 85 return &iter->second; |
| 83 } | 86 } |
| 84 } | 87 } |
| 85 return NULL; | 88 return NULL; |
| 86 } | 89 } |
| 87 | 90 |
| 88 AppCacheExecutableHandler* AppCache::GetExecutableHandler(int64 response_id) { | 91 AppCacheExecutableHandler* AppCache::GetExecutableHandler(int64_t response_id) { |
| 89 HandlerMap::const_iterator found = executable_handlers_.find(response_id); | 92 HandlerMap::const_iterator found = executable_handlers_.find(response_id); |
| 90 if (found != executable_handlers_.end()) | 93 if (found != executable_handlers_.end()) |
| 91 return found->second; | 94 return found->second; |
| 92 return NULL; | 95 return NULL; |
| 93 } | 96 } |
| 94 | 97 |
| 95 AppCacheExecutableHandler* AppCache::GetOrCreateExecutableHandler( | 98 AppCacheExecutableHandler* AppCache::GetOrCreateExecutableHandler( |
| 96 int64 response_id, net::IOBuffer* handler_source) { | 99 int64_t response_id, |
| 100 net::IOBuffer* handler_source) { |
| 97 AppCacheExecutableHandler* handler = GetExecutableHandler(response_id); | 101 AppCacheExecutableHandler* handler = GetExecutableHandler(response_id); |
| 98 if (handler) | 102 if (handler) |
| 99 return handler; | 103 return handler; |
| 100 | 104 |
| 101 GURL handler_url; | 105 GURL handler_url; |
| 102 const AppCacheEntry* entry = GetEntryAndUrlWithResponseId( | 106 const AppCacheEntry* entry = GetEntryAndUrlWithResponseId( |
| 103 response_id, &handler_url); | 107 response_id, &handler_url); |
| 104 if (!entry || !entry->IsExecutable()) | 108 if (!entry || !entry->IsExecutable()) |
| 105 return NULL; | 109 return NULL; |
| 106 | 110 |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 const GURL& url) { | 322 const GURL& url) { |
| 319 size_t count = namespaces.size(); | 323 size_t count = namespaces.size(); |
| 320 for (size_t i = 0; i < count; ++i) { | 324 for (size_t i = 0; i < count; ++i) { |
| 321 if (namespaces[i].IsMatch(url)) | 325 if (namespaces[i].IsMatch(url)) |
| 322 return &namespaces[i]; | 326 return &namespaces[i]; |
| 323 } | 327 } |
| 324 return NULL; | 328 return NULL; |
| 325 } | 329 } |
| 326 | 330 |
| 327 } // namespace content | 331 } // namespace content |
| OLD | NEW |