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

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

Issue 11045008: Fix bug in percentage increase computation for cache sensitivity analysis, (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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 | Annotate | Revision Log
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/http_cache_transaction.h" 5 #include "net/http/http_cache_transaction.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #if defined(OS_POSIX) 9 #if defined(OS_POSIX)
10 #include <unistd.h> 10 #include <unistd.h>
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 ALLOW_THIS_IN_INITIALIZER_LIST(io_callback_( 143 ALLOW_THIS_IN_INITIALIZER_LIST(io_callback_(
144 base::Bind(&Transaction::OnIOComplete, 144 base::Bind(&Transaction::OnIOComplete,
145 weak_factory_.GetWeakPtr()))), 145 weak_factory_.GetWeakPtr()))),
146 transaction_pattern_(PATTERN_UNDEFINED), 146 transaction_pattern_(PATTERN_UNDEFINED),
147 bytes_read_from_cache_(0), 147 bytes_read_from_cache_(0),
148 bytes_read_from_network_(0), 148 bytes_read_from_network_(0),
149 transaction_delegate_(transaction_delegate) { 149 transaction_delegate_(transaction_delegate) {
150 COMPILE_ASSERT(HttpCache::Transaction::kNumValidationHeaders == 150 COMPILE_ASSERT(HttpCache::Transaction::kNumValidationHeaders ==
151 arraysize(kValidationHeaders), 151 arraysize(kValidationHeaders),
152 Invalid_number_of_validation_headers); 152 Invalid_number_of_validation_headers);
153 if (!base::StringToInt( 153 base::StringToInt(
rvargas (doing something else) 2012/10/03 02:01:09 Sorry, I'm confused now. What was the bug?. Why tw
tburkard 2012/10/03 16:47:21 This change here is to make the two groups work fo
rvargas (doing something else) 2012/10/03 22:19:05 I thought the original behavior is what you wanted
154 base::FieldTrialList::FindFullName("CacheSensitivityAnalysis"), 154 base::FieldTrialList::FindFullName("CacheSensitivityAnalysis"),
155 &sensitivity_analysis_percent_increase_)) { 155 &sensitivity_analysis_percent_increase_);
156 sensitivity_analysis_percent_increase_ = 0;
157 }
158 } 156 }
159 157
160 HttpCache::Transaction::~Transaction() { 158 HttpCache::Transaction::~Transaction() {
161 // We may have to issue another IO, but we should never invoke the callback_ 159 // We may have to issue another IO, but we should never invoke the callback_
162 // after this point. 160 // after this point.
163 callback_.Reset(); 161 callback_.Reset();
164 162
165 transaction_delegate_ = NULL; 163 transaction_delegate_ = NULL;
166 164
167 if (cache_) { 165 if (cache_) {
(...skipping 2110 matching lines...) Expand 10 before | Expand all | Expand 10 after
2278 } 2276 }
2279 2277
2280 return true; 2278 return true;
2281 } 2279 }
2282 2280
2283 void HttpCache::Transaction::OnIOComplete(int result) { 2281 void HttpCache::Transaction::OnIOComplete(int result) {
2284 if (!cache_io_start_.is_null()) { 2282 if (!cache_io_start_.is_null()) {
2285 base::TimeDelta cache_time = base::TimeTicks::Now() - cache_io_start_; 2283 base::TimeDelta cache_time = base::TimeTicks::Now() - cache_io_start_;
2286 cache_io_start_ = base::TimeTicks(); 2284 cache_io_start_ = base::TimeTicks();
2287 if (sensitivity_analysis_percent_increase_ > 0) { 2285 if (sensitivity_analysis_percent_increase_ > 0) {
2288 cache_time *= 100 + sensitivity_analysis_percent_increase_; 2286 cache_time *= sensitivity_analysis_percent_increase_;
2289 cache_time /= 100; 2287 cache_time /= 100;
2290 MessageLoop::current()->PostDelayedTask( 2288 MessageLoop::current()->PostDelayedTask(
2291 FROM_HERE, 2289 FROM_HERE,
2292 base::Bind(&HttpCache::Transaction::RunDelayedLoop, 2290 base::Bind(&HttpCache::Transaction::RunDelayedLoop,
2293 weak_factory_.GetWeakPtr(), 2291 weak_factory_.GetWeakPtr(),
2294 base::TimeTicks::Now(), 2292 base::TimeTicks::Now(),
2295 cache_time, 2293 cache_time,
2296 result), 2294 result),
2297 cache_time); 2295 cache_time);
2298 return; 2296 return;
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
2485 } 2483 }
2486 2484
2487 int HttpCache::Transaction::ResetCacheIOStart(int return_value) { 2485 int HttpCache::Transaction::ResetCacheIOStart(int return_value) {
2488 DCHECK(cache_io_start_.is_null()); 2486 DCHECK(cache_io_start_.is_null());
2489 if (return_value == ERR_IO_PENDING) 2487 if (return_value == ERR_IO_PENDING)
2490 cache_io_start_ = base::TimeTicks::Now(); 2488 cache_io_start_ = base::TimeTicks::Now();
2491 return return_value; 2489 return return_value;
2492 } 2490 }
2493 2491
2494 } // namespace net 2492 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698