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

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

Issue 650068: Disk cache: Use TimeTicks instead of Time for some of the... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 10 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 | « net/disk_cache/histogram_macros.h ('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/rankings.h" 5 #include "net/disk_cache/rankings.h"
6 6
7 #include "base/histogram.h" 7 #include "base/histogram.h"
8 #include "net/disk_cache/backend_impl.h" 8 #include "net/disk_cache/backend_impl.h"
9 #include "net/disk_cache/entry_impl.h" 9 #include "net/disk_cache/entry_impl.h"
10 #include "net/disk_cache/errors.h" 10 #include "net/disk_cache/errors.h"
11 #include "net/disk_cache/histogram_macros.h" 11 #include "net/disk_cache/histogram_macros.h"
12 12
13 using base::Time; 13 using base::Time;
14 using base::TimeTicks;
14 15
15 // This is used by crash_cache.exe to generate unit test files. 16 // This is used by crash_cache.exe to generate unit test files.
16 disk_cache::RankCrashes g_rankings_crash = disk_cache::NO_CRASH; 17 disk_cache::RankCrashes g_rankings_crash = disk_cache::NO_CRASH;
17 18
18 namespace { 19 namespace {
19 20
20 enum Operation { 21 enum Operation {
21 INSERT = 1, 22 INSERT = 1,
22 REMOVE 23 REMOVE
23 }; 24 };
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 heads_[i].set_value(0); 201 heads_[i].set_value(0);
201 tails_[i].set_value(0); 202 tails_[i].set_value(0);
202 } 203 }
203 control_data_ = NULL; 204 control_data_ = NULL;
204 } 205 }
205 206
206 bool Rankings::GetRanking(CacheRankingsBlock* rankings) { 207 bool Rankings::GetRanking(CacheRankingsBlock* rankings) {
207 if (!rankings->address().is_initialized()) 208 if (!rankings->address().is_initialized())
208 return false; 209 return false;
209 210
210 Time start = Time::Now(); 211 TimeTicks start = TimeTicks::Now();
211 if (!rankings->Load()) 212 if (!rankings->Load())
212 return false; 213 return false;
213 214
214 if (!SanityCheck(rankings, true)) { 215 if (!SanityCheck(rankings, true)) {
215 backend_->CriticalError(ERR_INVALID_LINKS); 216 backend_->CriticalError(ERR_INVALID_LINKS);
216 return false; 217 return false;
217 } 218 }
218 219
219 backend_->OnEvent(Stats::OPEN_RANKINGS); 220 backend_->OnEvent(Stats::OPEN_RANKINGS);
220 221
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 DecrementCounter(list); 400 DecrementCounter(list);
400 UpdateIterators(&next); 401 UpdateIterators(&next);
401 UpdateIterators(&prev); 402 UpdateIterators(&prev);
402 } 403 }
403 404
404 // A crash in between Remove and Insert will lead to a dirty entry not on the 405 // A crash in between Remove and Insert will lead to a dirty entry not on the
405 // list. We want to avoid that case as much as we can (as while waiting for IO), 406 // list. We want to avoid that case as much as we can (as while waiting for IO),
406 // but the net effect is just an assert on debug when attempting to remove the 407 // but the net effect is just an assert on debug when attempting to remove the
407 // entry. Otherwise we'll need reentrant transactions, which is an overkill. 408 // entry. Otherwise we'll need reentrant transactions, which is an overkill.
408 void Rankings::UpdateRank(CacheRankingsBlock* node, bool modified, List list) { 409 void Rankings::UpdateRank(CacheRankingsBlock* node, bool modified, List list) {
409 Time start = Time::Now(); 410 TimeTicks start = TimeTicks::Now();
410 Remove(node, list); 411 Remove(node, list);
411 Insert(node, modified, list); 412 Insert(node, modified, list);
412 CACHE_UMA(AGE_MS, "UpdateRank", 0, start); 413 CACHE_UMA(AGE_MS, "UpdateRank", 0, start);
413 } 414 }
414 415
415 void Rankings::CompleteTransaction() { 416 void Rankings::CompleteTransaction() {
416 Addr node_addr(static_cast<CacheAddr>(control_data_->transaction)); 417 Addr node_addr(static_cast<CacheAddr>(control_data_->transaction));
417 if (!node_addr.is_initialized() || node_addr.is_separate_file()) { 418 if (!node_addr.is_initialized() || node_addr.is_separate_file()) {
418 NOTREACHED(); 419 NOTREACHED();
419 LOG(ERROR) << "Invalid rankings info."; 420 LOG(ERROR) << "Invalid rankings info.";
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 void Rankings::DecrementCounter(List list) { 796 void Rankings::DecrementCounter(List list) {
796 if (!count_lists_) 797 if (!count_lists_)
797 return; 798 return;
798 799
799 DCHECK(control_data_->sizes[list] > 0); 800 DCHECK(control_data_->sizes[list] > 0);
800 if (control_data_->sizes[list] > 0) 801 if (control_data_->sizes[list] > 0)
801 control_data_->sizes[list]--; 802 control_data_->sizes[list]--;
802 } 803 }
803 804
804 } // namespace disk_cache 805 } // namespace disk_cache
OLDNEW
« no previous file with comments | « net/disk_cache/histogram_macros.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698