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

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

Issue 146136: Add a command line switch to allow setting the max size... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 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 | « chrome/common/chrome_switches.cc ('k') | no next file » | 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_path.h" 7 #include "base/file_path.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/histogram.h" 9 #include "base/histogram.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 575
576 bool BackendImpl::SetMaxSize(int max_bytes) { 576 bool BackendImpl::SetMaxSize(int max_bytes) {
577 COMPILE_ASSERT(sizeof(max_bytes) == sizeof(max_size_), unsupported_int_model); 577 COMPILE_ASSERT(sizeof(max_bytes) == sizeof(max_size_), unsupported_int_model);
578 if (max_bytes < 0) 578 if (max_bytes < 0)
579 return false; 579 return false;
580 580
581 // Zero size means use the default. 581 // Zero size means use the default.
582 if (!max_bytes) 582 if (!max_bytes)
583 return true; 583 return true;
584 584
585 // Avoid a DCHECK later on.
586 if (max_bytes >= kint32max - kint32max / 10)
587 max_bytes = kint32max - kint32max / 10 - 1;
588
585 user_flags_ |= kMaxSize; 589 user_flags_ |= kMaxSize;
586 max_size_ = max_bytes; 590 max_size_ = max_bytes;
587 return true; 591 return true;
588 } 592 }
589 593
590 void BackendImpl::SetType(net::CacheType type) { 594 void BackendImpl::SetType(net::CacheType type) {
591 DCHECK(type != net::MEMORY_CACHE); 595 DCHECK(type != net::MEMORY_CACHE);
592 cache_type_ = type; 596 cache_type_ = type;
593 } 597 }
594 598
(...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after
1518 1522
1519 return num_dirty; 1523 return num_dirty;
1520 } 1524 }
1521 1525
1522 bool BackendImpl::CheckEntry(EntryImpl* cache_entry) { 1526 bool BackendImpl::CheckEntry(EntryImpl* cache_entry) {
1523 RankingsNode* rankings = cache_entry->rankings()->Data(); 1527 RankingsNode* rankings = cache_entry->rankings()->Data();
1524 return !rankings->pointer; 1528 return !rankings->pointer;
1525 } 1529 }
1526 1530
1527 } // namespace disk_cache 1531 } // namespace disk_cache
OLDNEW
« no previous file with comments | « chrome/common/chrome_switches.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698