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

Side by Side Diff: net/disk_cache/backend_impl.cc

Issue 3141: Move GetFreeDiskSpace to SysInfo. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « base/sys_info_win.cc ('k') | net/disk_cache/cache_util.h » ('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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/backend_impl.h" 5 #include "net/disk_cache/backend_impl.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/histogram.h" 8 #include "base/histogram.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
11 #include "base/sys_info.h"
11 #include "base/timer.h" 12 #include "base/timer.h"
12 #include "base/worker_pool.h" 13 #include "base/worker_pool.h"
13 #include "net/disk_cache/cache_util.h" 14 #include "net/disk_cache/cache_util.h"
14 #include "net/disk_cache/entry_impl.h" 15 #include "net/disk_cache/entry_impl.h"
15 #include "net/disk_cache/errors.h" 16 #include "net/disk_cache/errors.h"
16 #include "net/disk_cache/hash.h" 17 #include "net/disk_cache/hash.h"
17 #include "net/disk_cache/file.h" 18 #include "net/disk_cache/file.h"
18 19
19 namespace { 20 namespace {
20 21
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 index_ = new MappedFile(); 754 index_ = new MappedFile();
754 data_ = reinterpret_cast<Index*>(index_->Init(index_name, 0)); 755 data_ = reinterpret_cast<Index*>(index_->Init(index_name, 0));
755 return true; 756 return true;
756 } 757 }
757 758
758 void BackendImpl::AdjustMaxCacheSize(int table_len) { 759 void BackendImpl::AdjustMaxCacheSize(int table_len) {
759 if (max_size_) 760 if (max_size_)
760 return; 761 return;
761 762
762 // The user is not setting the size, let's figure it out. 763 // The user is not setting the size, let's figure it out.
763 int64 available = GetFreeDiskSpace(path_); 764 int64 available = base::SysInfo::AmountOfFreeDiskSpace(path_);
764 if (available < 0) { 765 if (available < 0) {
765 max_size_ = kDefaultCacheSize; 766 max_size_ = kDefaultCacheSize;
766 return; 767 return;
767 } 768 }
768 769
769 // Attempt to use 1% of the disk available for this user. 770 // Attempt to use 1% of the disk available for this user.
770 available /= 100; 771 available /= 100;
771 772
772 if (available < kDefaultCacheSize) 773 if (available < kDefaultCacheSize)
773 max_size_ = kDefaultCacheSize; 774 max_size_ = kDefaultCacheSize;
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
1104 1105
1105 return num_dirty; 1106 return num_dirty;
1106 } 1107 }
1107 1108
1108 bool BackendImpl::CheckEntry(EntryImpl* cache_entry) { 1109 bool BackendImpl::CheckEntry(EntryImpl* cache_entry) {
1109 RankingsNode* rankings = cache_entry->rankings()->Data(); 1110 RankingsNode* rankings = cache_entry->rankings()->Data();
1110 return !rankings->pointer; 1111 return !rankings->pointer;
1111 } 1112 }
1112 1113
1113 } // namespace disk_cache 1114 } // namespace disk_cache
OLDNEW
« no previous file with comments | « base/sys_info_win.cc ('k') | net/disk_cache/cache_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698