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

Side by Side Diff: net/http/infinite_cache.cc

Issue 11267028: Http cache: Measure back navigations on the infinite cache simulation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 1 month 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/http/infinite_cache.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) 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/http/infinite_cache.h" 5 #include "net/http/infinite_cache.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 const std::string cache_key = cache_->GenerateKey(request); 268 const std::string cache_key = cache_->GenerateKey(request);
269 if (cache_key == kGaJsHttpUrl) { 269 if (cache_key == kGaJsHttpUrl) {
270 resource_data_->details.flags |= GA_JS_HTTP; 270 resource_data_->details.flags |= GA_JS_HTTP;
271 } else if (cache_key == kGaJsHttpsUrl) { 271 } else if (cache_key == kGaJsHttpsUrl) {
272 resource_data_->details.flags |= GA_JS_HTTPS; 272 resource_data_->details.flags |= GA_JS_HTTPS;
273 } 273 }
274 274
275 CryptoHash(cache_key, &resource_data_->key); 275 CryptoHash(cache_key, &resource_data_->key);
276 } 276 }
277 277
278 void InfiniteCacheTransaction::OnBackForwardNavigation() {
279 if (!cache_)
280 return;
281 UMA_HISTOGRAM_BOOLEAN("InfiniteCache.BackForwardNavigation", true);
282 }
283
278 void InfiniteCacheTransaction::OnResponseReceived( 284 void InfiniteCacheTransaction::OnResponseReceived(
279 const HttpResponseInfo* response) { 285 const HttpResponseInfo* response) {
280 if (!cache_) 286 if (!cache_)
281 return; 287 return;
282 288
283 Details& details = resource_data_->details; 289 Details& details = resource_data_->details;
284 290
285 // Store the old flag values that we want to preserve. 291 // Store the old flag values that we want to preserve.
286 const uint32 kPreserveFlagsBitMask = (GA_JS_HTTP | GA_JS_HTTPS | DOOM_METHOD); 292 const uint32 kPreserveFlagsBitMask = (GA_JS_HTTP | GA_JS_HTTPS | DOOM_METHOD);
287 uint32 old_flag_values = details.flags & kPreserveFlagsBitMask; 293 uint32 old_flag_values = details.flags & kPreserveFlagsBitMask;
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 if (!init_) 521 if (!init_)
516 return; 522 return;
517 523
518 if (data->details.response_size > kMaxTrackingSize) 524 if (data->details.response_size > kMaxTrackingSize)
519 return; 525 return;
520 526
521 if (header_->num_entries == kMaxNumEntries || header_->disabled) 527 if (header_->num_entries == kMaxNumEntries || header_->disabled)
522 return; 528 return;
523 529
524 UMA_HISTOGRAM_BOOLEAN("InfiniteCache.TotalRequests", true); 530 UMA_HISTOGRAM_BOOLEAN("InfiniteCache.TotalRequests", true);
531 if (data->details.flags & NO_STORE)
532 UMA_HISTOGRAM_BOOLEAN("InfiniteCache.NoStore", true);
533
525 header_->num_requests++; 534 header_->num_requests++;
526 KeyMap::iterator i = map_.find(data->key); 535 KeyMap::iterator i = map_.find(data->key);
527 if (i != map_.end()) { 536 if (i != map_.end()) {
528 if (data->details.flags & DOOM_METHOD) { 537 if (data->details.flags & DOOM_METHOD) {
538 UMA_HISTOGRAM_BOOLEAN("InfiniteCache.DoomMethodHit", true);
529 Remove(i->second); 539 Remove(i->second);
530 map_.erase(i); 540 map_.erase(i);
531 return; 541 return;
532 } 542 }
533 data->details.use_count = i->second.use_count; 543 data->details.use_count = i->second.use_count;
534 data->details.update_count = i->second.update_count; 544 data->details.update_count = i->second.update_count;
535 bool reused = CanReuse(i->second, data->details); 545 bool reused = CanReuse(i->second, data->details);
536 bool data_changed = DataChanged(i->second, data->details); 546 bool data_changed = DataChanged(i->second, data->details);
537 bool headers_changed = HeadersChanged(i->second, data->details); 547 bool headers_changed = HeadersChanged(i->second, data->details);
538 548
(...skipping 15 matching lines...) Expand all
554 return; 564 return;
555 } 565 }
556 566
557 map_[data->key] = data->details; 567 map_[data->key] = data->details;
558 return; 568 return;
559 } 569 }
560 570
561 if (data->details.flags & NO_STORE) 571 if (data->details.flags & NO_STORE)
562 return; 572 return;
563 573
564 if (data->details.flags & DOOM_METHOD) 574 if (data->details.flags & DOOM_METHOD) {
575 UMA_HISTOGRAM_BOOLEAN("InfiniteCache.DoomMethodHit", false);
565 return; 576 return;
577 }
566 578
567 map_[data->key] = data->details; 579 map_[data->key] = data->details;
568 Add(data->details); 580 Add(data->details);
569 } 581 }
570 582
571 void InfiniteCache::Worker::LoadData() { 583 void InfiniteCache::Worker::LoadData() {
572 if (path_.empty()) 584 if (path_.empty())
573 return InitializeData();; 585 return InitializeData();
574 586
575 PlatformFile file = base::CreatePlatformFile( 587 PlatformFile file = base::CreatePlatformFile(
576 path_, base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ, NULL, NULL); 588 path_, base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ, NULL, NULL);
577 if (file == base::kInvalidPlatformFileValue) 589 if (file == base::kInvalidPlatformFileValue)
578 return InitializeData(); 590 return InitializeData();
579 if (!ReadData(file)) 591 if (!ReadData(file))
580 InitializeData(); 592 InitializeData();
581 base::ClosePlatformFile(file); 593 base::ClosePlatformFile(file);
582 if (header_->disabled) { 594 if (header_->disabled) {
583 UMA_HISTOGRAM_BOOLEAN("InfiniteCache.Full", true); 595 UMA_HISTOGRAM_BOOLEAN("InfiniteCache.Full", true);
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 int InfiniteCache::FlushDataForTest(const CompletionCallback& callback) { 1102 int InfiniteCache::FlushDataForTest(const CompletionCallback& callback) {
1091 DCHECK(worker_); 1103 DCHECK(worker_);
1092 int* result = new int; 1104 int* result = new int;
1093 task_runner_->PostTaskAndReply( 1105 task_runner_->PostTaskAndReply(
1094 FROM_HERE, base::Bind(&InfiniteCache::Worker::Flush, worker_, result), 1106 FROM_HERE, base::Bind(&InfiniteCache::Worker::Flush, worker_, result),
1095 base::Bind(&OnComplete, callback, base::Owned(result))); 1107 base::Bind(&OnComplete, callback, base::Owned(result)));
1096 return net::ERR_IO_PENDING; 1108 return net::ERR_IO_PENDING;
1097 } 1109 }
1098 1110
1099 } // namespace net 1111 } // namespace net
OLDNEW
« no previous file with comments | « net/http/infinite_cache.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698