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

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

Issue 15956004: Disk cache: Avoid writing uninitialized data to disk. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 7 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 | « no previous file | net/disk_cache/stats.h » ('j') | 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/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 1376 matching lines...) Expand 10 before | Expand all | Expand 10 after
1387 return false; 1387 return false;
1388 if (cache_type_ == net::DISK_CACHE && ShouldReportAgain()) 1388 if (cache_type_ == net::DISK_CACHE && ShouldReportAgain())
1389 stats_.InitSizeHistogram(); 1389 stats_.InitSizeHistogram();
1390 return true; 1390 return true;
1391 } 1391 }
1392 1392
1393 void BackendImpl::StoreStats() { 1393 void BackendImpl::StoreStats() {
1394 int size = stats_.StorageSize(); 1394 int size = stats_.StorageSize();
1395 scoped_ptr<char[]> data(new char[size]); 1395 scoped_ptr<char[]> data(new char[size]);
1396 Addr address; 1396 Addr address;
1397 bool rv = stats_.SerializeStats(data.get(), size, &address); 1397 size = stats_.SerializeStats(data.get(), size, &address);
1398 DCHECK(rv); 1398 DCHECK(size);
1399 if (!address.is_initialized()) 1399 if (!address.is_initialized())
1400 return; 1400 return;
1401 1401
1402 MappedFile* file = File(address); 1402 MappedFile* file = File(address);
1403 if (!file) 1403 if (!file)
1404 return; 1404 return;
1405 1405
1406 size_t offset = address.start_block() * address.BlockSize() + 1406 size_t offset = address.start_block() * address.BlockSize() +
1407 kBlockHeaderSize; 1407 kBlockHeaderSize;
1408 rv = file->Write(data.get(), size, offset); // ignore result. 1408 file->Write(data.get(), size, offset); // ignore result.
1409 } 1409 }
1410 1410
1411 void BackendImpl::RestartCache(bool failure) { 1411 void BackendImpl::RestartCache(bool failure) {
1412 int64 errors = stats_.GetCounter(Stats::FATAL_ERROR); 1412 int64 errors = stats_.GetCounter(Stats::FATAL_ERROR);
1413 int64 full_dooms = stats_.GetCounter(Stats::DOOM_CACHE); 1413 int64 full_dooms = stats_.GetCounter(Stats::DOOM_CACHE);
1414 int64 partial_dooms = stats_.GetCounter(Stats::DOOM_RECENT); 1414 int64 partial_dooms = stats_.GetCounter(Stats::DOOM_RECENT);
1415 int64 ga_evictions = stats_.GetCounter(Stats::GAJS_EVICTED); 1415 int64 ga_evictions = stats_.GetCounter(Stats::GAJS_EVICTED);
1416 int64 last_report = stats_.GetCounter(Stats::LAST_REPORT); 1416 int64 last_report = stats_.GetCounter(Stats::LAST_REPORT);
1417 1417
1418 PrepareForRestart(); 1418 PrepareForRestart();
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after
2110 if (total_memory > kMaxBuffersSize || total_memory <= 0) 2110 if (total_memory > kMaxBuffersSize || total_memory <= 0)
2111 total_memory = kMaxBuffersSize; 2111 total_memory = kMaxBuffersSize;
2112 2112
2113 done = true; 2113 done = true;
2114 } 2114 }
2115 2115
2116 return static_cast<int>(total_memory); 2116 return static_cast<int>(total_memory);
2117 } 2117 }
2118 2118
2119 } // namespace disk_cache 2119 } // namespace disk_cache
OLDNEW
« no previous file with comments | « no previous file | net/disk_cache/stats.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698