OLD | NEW |
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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 const scoped_refptr<base::TaskRunner>& io_thread, | 74 const scoped_refptr<base::TaskRunner>& io_thread, |
75 const base::FilePath& path) | 75 const base::FilePath& path) |
76 : cache_size_(0), | 76 : cache_size_(0), |
77 initialized_(false), | 77 initialized_(false), |
78 index_filename_(path.AppendASCII("simple-index")), | 78 index_filename_(path.AppendASCII("simple-index")), |
79 cache_thread_(cache_thread), | 79 cache_thread_(cache_thread), |
80 io_thread_(io_thread) {} | 80 io_thread_(io_thread) {} |
81 | 81 |
82 SimpleIndex::~SimpleIndex() { | 82 SimpleIndex::~SimpleIndex() { |
83 DCHECK(io_thread_checker_.CalledOnValidThread()); | 83 DCHECK(io_thread_checker_.CalledOnValidThread()); |
84 | |
85 } | 84 } |
86 | 85 |
87 void SimpleIndex::Initialize() { | 86 void SimpleIndex::Initialize() { |
88 DCHECK(io_thread_checker_.CalledOnValidThread()); | 87 DCHECK(io_thread_checker_.CalledOnValidThread()); |
89 IndexCompletionCallback merge_callback = | 88 IndexCompletionCallback merge_callback = |
90 base::Bind(&SimpleIndex::MergeInitializingSet, AsWeakPtr()); | 89 base::Bind(&SimpleIndex::MergeInitializingSet, this); |
91 base::WorkerPool::PostTask(FROM_HERE, | 90 base::WorkerPool::PostTask(FROM_HERE, |
92 base::Bind(&SimpleIndex::LoadFromDisk, | 91 base::Bind(&SimpleIndex::LoadFromDisk, |
93 index_filename_, | 92 index_filename_, |
94 io_thread_, | 93 io_thread_, |
95 merge_callback), | 94 merge_callback), |
96 true); | 95 true); |
97 } | 96 } |
98 | 97 |
99 void SimpleIndex::Insert(const std::string& key) { | 98 void SimpleIndex::Insert(const std::string& key) { |
100 DCHECK(io_thread_checker_.CalledOnValidThread()); | 99 DCHECK(io_thread_checker_.CalledOnValidThread()); |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 cache_size_); | 279 cache_size_); |
281 scoped_ptr<Pickle> pickle = SimpleIndexFile::Serialize(index_metadata, | 280 scoped_ptr<Pickle> pickle = SimpleIndexFile::Serialize(index_metadata, |
282 entries_set_); | 281 entries_set_); |
283 cache_thread_->PostTask(FROM_HERE, base::Bind( | 282 cache_thread_->PostTask(FROM_HERE, base::Bind( |
284 &SimpleIndex::WriteToDiskInternal, | 283 &SimpleIndex::WriteToDiskInternal, |
285 index_filename_, | 284 index_filename_, |
286 base::Passed(&pickle))); | 285 base::Passed(&pickle))); |
287 } | 286 } |
288 | 287 |
289 } // namespace disk_cache | 288 } // namespace disk_cache |
OLD | NEW |