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

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

Issue 13813015: Separate Simple Backend creation from initialization. (Closed) Base URL: http://git.chromium.org/chromium/src.git@trace-2
Patch Set: . 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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_index.h" 5 #include "net/disk_cache/simple/simple_index.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/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/task_runner.h" 10 #include "base/task_runner.h"
(...skipping 27 matching lines...) Expand all
38 38
39 } // namespace 39 } // namespace
40 40
41 namespace disk_cache { 41 namespace disk_cache {
42 42
43 SimpleIndex::SimpleIndex( 43 SimpleIndex::SimpleIndex(
44 const scoped_refptr<base::TaskRunner>& cache_thread, 44 const scoped_refptr<base::TaskRunner>& cache_thread,
45 const base::FilePath& path) 45 const base::FilePath& path)
46 : path_(path), 46 : path_(path),
47 cache_thread_(cache_thread) { 47 cache_thread_(cache_thread) {
48 index_filename_ = path_.AppendASCII("simple-index"); 48 index_filename_ = path_.AppendASCII("index");
49 } 49 }
50 50
51 bool SimpleIndex::Initialize() { 51 bool SimpleIndex::Initialize() {
52 if (!OpenIndexFile()) 52 if (!OpenIndexFile())
53 return RestoreFromDisk(); 53 return RestoreFromDisk();
54 uLong incremental_crc = crc32(0L, Z_NULL, 0); 54 uLong incremental_crc = crc32(0L, Z_NULL, 0);
55 int64 index_file_offset = 0; 55 int64 index_file_offset = 0;
56 SimpleIndexFile::Header metadata; 56 SimpleIndexFile::Header metadata;
57 if (base::ReadPlatformFile(index_file_, 57 if (base::ReadPlatformFile(index_file_,
58 index_file_offset, 58 index_file_offset,
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 file_util::Delete(temp_filename, /* recursive = */ false); 222 file_util::Delete(temp_filename, /* recursive = */ false);
223 return; 223 return;
224 } 224 }
225 225
226 // Swap temp and index_file. 226 // Swap temp and index_file.
227 bool result = file_util::ReplaceFile(temp_filename, index_filename); 227 bool result = file_util::ReplaceFile(temp_filename, index_filename);
228 DCHECK(result); 228 DCHECK(result);
229 } 229 }
230 230
231 } // namespace disk_cache 231 } // namespace disk_cache
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698