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

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

Issue 14129004: Add support for the control group in the Simple Cache Experiment. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use experiments Created 7 years, 8 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
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/disk_cache/backend_impl.h" 5 #include "net/disk_cache/backend_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 69
70 size_t GetIndexSize(int table_len) { 70 size_t GetIndexSize(int table_len) {
71 size_t table_size = sizeof(disk_cache::CacheAddr) * table_len; 71 size_t table_size = sizeof(disk_cache::CacheAddr) * table_len;
72 return sizeof(disk_cache::IndexHeader) + table_size; 72 return sizeof(disk_cache::IndexHeader) + table_size;
73 } 73 }
74 74
75 // ------------------------------------------------------------------------ 75 // ------------------------------------------------------------------------
76 76
77 // Sets group for the current experiment. Returns false if the files should be 77 // Sets group for the current experiment. Returns false if the files should be
78 // discarded. 78 // discarded.
79 bool InitExperiment(disk_cache::IndexHeader* header) { 79 bool InitExperiment(disk_cache::IndexHeader* header,
80 bool cache_created) {
80 if (header->experiment == disk_cache::EXPERIMENT_OLD_FILE1 || 81 if (header->experiment == disk_cache::EXPERIMENT_OLD_FILE1 ||
81 header->experiment == disk_cache::EXPERIMENT_OLD_FILE2) { 82 header->experiment == disk_cache::EXPERIMENT_OLD_FILE2) {
82 // Discard current cache. 83 // Discard current cache.
83 return false; 84 return false;
84 } 85 }
85 86
87
88 LOG(INFO) << "hi?";
rvargas (doing something else) 2013/04/19 17:40:55 remove
89 if (base::FieldTrialList::FindFullName("SimpleCacheTrial") == "Control") {
90 if (cache_created) {
91 LOG(INFO) << "updating to control";
rvargas (doing something else) 2013/04/19 17:40:55 remove
92 header->experiment = disk_cache::EXPERIMENT_SIMPLE_CONTROL;
93 return true;
94 } else if (header->experiment != disk_cache::EXPERIMENT_SIMPLE_CONTROL) {
95 LOG(INFO) << "YR IN THE WRONG GROUP " << header->experiment;
rvargas (doing something else) 2013/04/19 17:40:55 remove
gavinp 2013/04/20 07:17:32 Guh. Sorry for leaving these in. Now you know how
96 return false;
97 }
98 }
99
86 header->experiment = disk_cache::NO_EXPERIMENT; 100 header->experiment = disk_cache::NO_EXPERIMENT;
87 return true; 101 return true;
88 } 102 }
89 103
90 // A callback to perform final cleanup on the background thread. 104 // A callback to perform final cleanup on the background thread.
91 void FinalCleanupCallback(disk_cache::BackendImpl* backend) { 105 void FinalCleanupCallback(disk_cache::BackendImpl* backend) {
92 backend->CleanupCache(); 106 backend->CleanupCache();
93 } 107 }
94 108
95 } // namespace 109 } // namespace
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 } 265 }
252 266
253 if (!CheckIndex()) { 267 if (!CheckIndex()) {
254 ReportError(ERR_INIT_FAILED); 268 ReportError(ERR_INIT_FAILED);
255 return net::ERR_FAILED; 269 return net::ERR_FAILED;
256 } 270 }
257 271
258 if (!restarted_ && (create_files || !data_->header.num_entries)) 272 if (!restarted_ && (create_files || !data_->header.num_entries))
259 ReportError(ERR_CACHE_CREATED); 273 ReportError(ERR_CACHE_CREATED);
260 274
261 if (!(user_flags_ & kNoRandom) && 275 if (!(user_flags_ & kNoRandom) && cache_type_ == net::DISK_CACHE &&
262 cache_type_ == net::DISK_CACHE && !InitExperiment(&data_->header)) 276 !InitExperiment(&data_->header, create_files)) {
263 return net::ERR_FAILED; 277 return net::ERR_FAILED;
278 }
264 279
265 // We don't care if the value overflows. The only thing we care about is that 280 // We don't care if the value overflows. The only thing we care about is that
266 // the id cannot be zero, because that value is used as "not dirty". 281 // the id cannot be zero, because that value is used as "not dirty".
267 // Increasing the value once per second gives us many years before we start 282 // Increasing the value once per second gives us many years before we start
268 // having collisions. 283 // having collisions.
269 data_->header.this_id++; 284 data_->header.this_id++;
270 if (!data_->header.this_id) 285 if (!data_->header.this_id)
271 data_->header.this_id++; 286 data_->header.this_id++;
272 287
273 bool previous_crash = (data_->header.crash != 0); 288 bool previous_crash = (data_->header.crash != 0);
(...skipping 1769 matching lines...) Expand 10 before | Expand all | Expand 10 after
2043 if (total_memory > kMaxBuffersSize || total_memory <= 0) 2058 if (total_memory > kMaxBuffersSize || total_memory <= 0)
2044 total_memory = kMaxBuffersSize; 2059 total_memory = kMaxBuffersSize;
2045 2060
2046 done = true; 2061 done = true;
2047 } 2062 }
2048 2063
2049 return static_cast<int>(total_memory); 2064 return static_cast<int>(total_memory);
2050 } 2065 }
2051 2066
2052 } // namespace disk_cache 2067 } // namespace disk_cache
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698