| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #include <time.h> | 11 #include <time.h> |
| 12 | 12 |
| 13 #if defined(WEBRTC_WIN) | 13 #if defined(WEBRTC_WIN) |
| 14 #include "webrtc/base/win32.h" | 14 #include "webrtc/base/win32.h" |
| 15 #endif | 15 #endif |
| 16 | 16 |
| 17 #include <algorithm> | 17 #include <algorithm> |
| 18 #include <memory> | 18 #include <memory> |
| 19 | 19 |
| 20 #include "webrtc/base/arraysize.h" | 20 #include "webrtc/base/arraysize.h" |
| 21 #include "webrtc/base/checks.h" | 21 #include "webrtc/base/checks.h" |
| 22 #include "webrtc/base/diskcache.h" | 22 #include "webrtc/base/diskcache.h" |
| 23 #include "webrtc/base/fileutils.h" | 23 #include "webrtc/base/fileutils.h" |
| 24 #include "webrtc/base/pathutils.h" | 24 #include "webrtc/base/pathutils.h" |
| 25 #include "webrtc/base/stream.h" | 25 #include "webrtc/base/stream.h" |
| 26 #include "webrtc/base/stringencode.h" | 26 #include "webrtc/base/stringencode.h" |
| 27 #include "webrtc/base/stringutils.h" | 27 #include "webrtc/base/stringutils.h" |
| 28 | 28 |
| 29 #if !defined(NDEBUG) | 29 #define TRANSPARENT_CACHE_NAMES RTC_DCHECK_IS_ON |
| 30 #define TRANSPARENT_CACHE_NAMES 1 | |
| 31 #else | |
| 32 #define TRANSPARENT_CACHE_NAMES 0 | |
| 33 #endif | |
| 34 | 30 |
| 35 namespace rtc { | 31 namespace rtc { |
| 36 | 32 |
| 37 class DiskCache; | 33 class DiskCache; |
| 38 | 34 |
| 39 /////////////////////////////////////////////////////////////////////////////// | 35 /////////////////////////////////////////////////////////////////////////////// |
| 40 // DiskCacheAdapter | 36 // DiskCacheAdapter |
| 41 /////////////////////////////////////////////////////////////////////////////// | 37 /////////////////////////////////////////////////////////////////////////////// |
| 42 | 38 |
| 43 class DiskCacheAdapter : public StreamAdapterInterface { | 39 class DiskCacheAdapter : public StreamAdapterInterface { |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 success = false; | 203 success = false; |
| 208 } | 204 } |
| 209 } | 205 } |
| 210 | 206 |
| 211 total_size_ -= entry->size; | 207 total_size_ -= entry->size; |
| 212 map_.erase(id); | 208 map_.erase(id); |
| 213 return success; | 209 return success; |
| 214 } | 210 } |
| 215 | 211 |
| 216 bool DiskCache::CheckLimit() { | 212 bool DiskCache::CheckLimit() { |
| 217 #if !defined(NDEBUG) | 213 #if RTC_DCHECK_IS_ON |
| 218 // Temporary check to make sure everything is working correctly. | 214 // Temporary check to make sure everything is working correctly. |
| 219 size_t cache_size = 0; | 215 size_t cache_size = 0; |
| 220 for (EntryMap::iterator it = map_.begin(); it != map_.end(); ++it) { | 216 for (EntryMap::iterator it = map_.begin(); it != map_.end(); ++it) { |
| 221 cache_size += it->second.size; | 217 cache_size += it->second.size; |
| 222 } | 218 } |
| 223 RTC_DCHECK(cache_size == total_size_); | 219 RTC_DCHECK(cache_size == total_size_); |
| 224 #endif | 220 #endif |
| 225 | 221 |
| 226 // TODO: Replace this with a non-brain-dead algorithm for clearing out the | 222 // TODO: Replace this with a non-brain-dead algorithm for clearing out the |
| 227 // oldest resources... something that isn't O(n^2) | 223 // oldest resources... something that isn't O(n^2) |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 entry2->last_modified = time(0); | 338 entry2->last_modified = time(0); |
| 343 entry2->lock_state = LS_UNLOCKED; | 339 entry2->lock_state = LS_UNLOCKED; |
| 344 this2->CheckLimit(); | 340 this2->CheckLimit(); |
| 345 } | 341 } |
| 346 } | 342 } |
| 347 } | 343 } |
| 348 | 344 |
| 349 /////////////////////////////////////////////////////////////////////////////// | 345 /////////////////////////////////////////////////////////////////////////////// |
| 350 | 346 |
| 351 } // namespace rtc | 347 } // namespace rtc |
| OLD | NEW |