Chromium Code Reviews| 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 #if RTC_DCHECK_IS_ON |
| 30 #define TRANSPARENT_CACHE_NAMES 1 | 30 #define TRANSPARENT_CACHE_NAMES 1 |
| 31 #else | 31 #else |
| 32 #define TRANSPARENT_CACHE_NAMES 0 | 32 #define TRANSPARENT_CACHE_NAMES 0 |
| 33 #endif | 33 #endif |
|
kwiberg-webrtc
2017/02/07 09:39:49
#define TRANSPARENT_CACHE_NAMES RTC_DCHECK_IS_ON
nisse-webrtc
2017/02/07 10:48:15
Done.
| |
| 34 | 34 |
| 35 namespace rtc { | 35 namespace rtc { |
| 36 | 36 |
| 37 class DiskCache; | 37 class DiskCache; |
| 38 | 38 |
| 39 /////////////////////////////////////////////////////////////////////////////// | 39 /////////////////////////////////////////////////////////////////////////////// |
| 40 // DiskCacheAdapter | 40 // DiskCacheAdapter |
| 41 /////////////////////////////////////////////////////////////////////////////// | 41 /////////////////////////////////////////////////////////////////////////////// |
| 42 | 42 |
| 43 class DiskCacheAdapter : public StreamAdapterInterface { | 43 class DiskCacheAdapter : public StreamAdapterInterface { |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 207 success = false; | 207 success = false; |
| 208 } | 208 } |
| 209 } | 209 } |
| 210 | 210 |
| 211 total_size_ -= entry->size; | 211 total_size_ -= entry->size; |
| 212 map_.erase(id); | 212 map_.erase(id); |
| 213 return success; | 213 return success; |
| 214 } | 214 } |
| 215 | 215 |
| 216 bool DiskCache::CheckLimit() { | 216 bool DiskCache::CheckLimit() { |
| 217 #if !defined(NDEBUG) | 217 #if RTC_DCHECK_IS_ON |
| 218 // Temporary check to make sure everything is working correctly. | 218 // Temporary check to make sure everything is working correctly. |
| 219 size_t cache_size = 0; | 219 size_t cache_size = 0; |
| 220 for (EntryMap::iterator it = map_.begin(); it != map_.end(); ++it) { | 220 for (EntryMap::iterator it = map_.begin(); it != map_.end(); ++it) { |
| 221 cache_size += it->second.size; | 221 cache_size += it->second.size; |
| 222 } | 222 } |
| 223 RTC_DCHECK(cache_size == total_size_); | 223 RTC_DCHECK(cache_size == total_size_); |
| 224 #endif | 224 #endif |
| 225 | 225 |
| 226 // TODO: Replace this with a non-brain-dead algorithm for clearing out the | 226 // TODO: Replace this with a non-brain-dead algorithm for clearing out the |
| 227 // oldest resources... something that isn't O(n^2) | 227 // 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); | 342 entry2->last_modified = time(0); |
| 343 entry2->lock_state = LS_UNLOCKED; | 343 entry2->lock_state = LS_UNLOCKED; |
| 344 this2->CheckLimit(); | 344 this2->CheckLimit(); |
| 345 } | 345 } |
| 346 } | 346 } |
| 347 } | 347 } |
| 348 | 348 |
| 349 /////////////////////////////////////////////////////////////////////////////// | 349 /////////////////////////////////////////////////////////////////////////////// |
| 350 | 350 |
| 351 } // namespace rtc | 351 } // namespace rtc |
| OLD | NEW |