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

Side by Side Diff: net/disk_cache/simple/simple_version_upgrade.cc

Issue 2922973003: RFC: use some in-memory state in SimpleCache to quickly cache-miss some CantConditionalize cases
Patch Set: omewhat better take at higher-level HC::T impl, a bit lessy hacky, and actually write to cache now. Created 3 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/simple/simple_version_upgrade.h" 5 #include "net/disk_cache/simple/simple_version_upgrade.h"
6 6
7 #include <cstring> 7 #include <cstring>
8 8
9 #include "base/files/file.h" 9 #include "base/files/file.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 return false; 191 return false;
192 } 192 }
193 version_from++; 193 version_from++;
194 } 194 }
195 DCHECK_LE(6U, version_from); 195 DCHECK_LE(6U, version_from);
196 if (version_from == 6) { 196 if (version_from == 6) {
197 // No upgrade from V6 -> V7, because the entry format has not changed and 197 // No upgrade from V6 -> V7, because the entry format has not changed and
198 // the V7 index reader is backwards compatible. 198 // the V7 index reader is backwards compatible.
199 version_from++; 199 version_from++;
200 } 200 }
201
202 if (version_from == 7) {
203 // Likewise, V7 -> V8 is handled entirely by the index reader.
204 version_from++;
205 }
206
201 DCHECK_EQ(kSimpleVersion, version_from); 207 DCHECK_EQ(kSimpleVersion, version_from);
202 208
203 if (!new_fake_index_needed) 209 if (!new_fake_index_needed)
204 return true; 210 return true;
205 211
206 const base::FilePath temp_fake_index = path.AppendASCII("upgrade-index"); 212 const base::FilePath temp_fake_index = path.AppendASCII("upgrade-index");
207 if (!WriteFakeIndexFile(temp_fake_index, experiment)) { 213 if (!WriteFakeIndexFile(temp_fake_index, experiment)) {
208 base::DeleteFile(temp_fake_index, /* recursive = */ false); 214 base::DeleteFile(temp_fake_index, /* recursive = */ false);
209 LOG(ERROR) << "Failed to write a new fake index."; 215 LOG(ERROR) << "Failed to write a new fake index.";
210 LogMessageFailedUpgradeFromVersion(file_header.version); 216 LogMessageFailedUpgradeFromVersion(file_header.version);
211 return false; 217 return false;
212 } 218 }
213 if (!base::ReplaceFile(temp_fake_index, fake_index, NULL)) { 219 if (!base::ReplaceFile(temp_fake_index, fake_index, NULL)) {
214 LOG(ERROR) << "Failed to replace the fake index."; 220 LOG(ERROR) << "Failed to replace the fake index.";
215 LogMessageFailedUpgradeFromVersion(file_header.version); 221 LogMessageFailedUpgradeFromVersion(file_header.version);
216 return false; 222 return false;
217 } 223 }
218 return true; 224 return true;
219 } 225 }
220 226
221 } // namespace disk_cache 227 } // namespace disk_cache
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698