Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(308)

Side by Side Diff: net/disk_cache/memory/mem_backend_impl.cc

Issue 657013003: Use scoped_ptr::Pass instead of scoped_ptr::PassAs<T>. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/disk_cache/disk_cache_test_base.cc ('k') | net/disk_cache/simple/simple_index_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "net/disk_cache/memory/mem_backend_impl.h" 5 #include "net/disk_cache/memory/mem_backend_impl.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/sys_info.h" 8 #include "base/sys_info.h"
9 #include "net/base/net_errors.h" 9 #include "net/base/net_errors.h"
10 #include "net/disk_cache/cache_util.h" 10 #include "net/disk_cache/cache_util.h"
(...skipping 29 matching lines...) Expand all
40 } 40 }
41 DCHECK(!current_size_); 41 DCHECK(!current_size_);
42 } 42 }
43 43
44 // Static. 44 // Static.
45 scoped_ptr<Backend> MemBackendImpl::CreateBackend(int max_bytes, 45 scoped_ptr<Backend> MemBackendImpl::CreateBackend(int max_bytes,
46 net::NetLog* net_log) { 46 net::NetLog* net_log) {
47 scoped_ptr<MemBackendImpl> cache(new MemBackendImpl(net_log)); 47 scoped_ptr<MemBackendImpl> cache(new MemBackendImpl(net_log));
48 cache->SetMaxSize(max_bytes); 48 cache->SetMaxSize(max_bytes);
49 if (cache->Init()) 49 if (cache->Init())
50 return cache.PassAs<Backend>(); 50 return cache.Pass();
51 51
52 LOG(ERROR) << "Unable to create cache"; 52 LOG(ERROR) << "Unable to create cache";
53 return scoped_ptr<Backend>(); 53 return nullptr;
54 } 54 }
55 55
56 bool MemBackendImpl::Init() { 56 bool MemBackendImpl::Init() {
57 if (max_size_) 57 if (max_size_)
58 return true; 58 return true;
59 59
60 int64 total_memory = base::SysInfo::AmountOfPhysicalMemory(); 60 int64 total_memory = base::SysInfo::AmountOfPhysicalMemory();
61 61
62 if (total_memory <= 0) { 62 if (total_memory <= 0) {
63 max_size_ = kDefaultInMemoryCacheSize; 63 max_size_ = kDefaultInMemoryCacheSize;
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 if (current_size_ > max_size_) 336 if (current_size_ > max_size_)
337 TrimCache(false); 337 TrimCache(false);
338 } 338 }
339 339
340 void MemBackendImpl::SubstractStorageSize(int32 bytes) { 340 void MemBackendImpl::SubstractStorageSize(int32 bytes) {
341 current_size_ -= bytes; 341 current_size_ -= bytes;
342 DCHECK_GE(current_size_, 0); 342 DCHECK_GE(current_size_, 0);
343 } 343 }
344 344
345 } // namespace disk_cache 345 } // namespace disk_cache
OLDNEW
« no previous file with comments | « net/disk_cache/disk_cache_test_base.cc ('k') | net/disk_cache/simple/simple_index_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698