OLD | NEW |
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 <utility> |
| 6 |
5 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
6 #include "base/macros.h" | 8 #include "base/macros.h" |
7 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
8 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
9 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
10 #include "net/base/cache_type.h" | 12 #include "net/base/cache_type.h" |
11 #include "net/base/net_errors.h" | 13 #include "net/base/net_errors.h" |
12 #include "net/disk_cache/blockfile/backend_impl.h" | 14 #include "net/disk_cache/blockfile/backend_impl.h" |
13 #include "net/disk_cache/cache_util.h" | 15 #include "net/disk_cache/cache_util.h" |
14 #include "net/disk_cache/disk_cache.h" | 16 #include "net/disk_cache/disk_cache.h" |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 int rv = new_cache->Init( | 117 int rv = new_cache->Init( |
116 base::Bind(&CacheCreator::OnIOComplete, base::Unretained(this))); | 118 base::Bind(&CacheCreator::OnIOComplete, base::Unretained(this))); |
117 DCHECK_EQ(net::ERR_IO_PENDING, rv); | 119 DCHECK_EQ(net::ERR_IO_PENDING, rv); |
118 return rv; | 120 return rv; |
119 #endif | 121 #endif |
120 } | 122 } |
121 | 123 |
122 void CacheCreator::DoCallback(int result) { | 124 void CacheCreator::DoCallback(int result) { |
123 DCHECK_NE(net::ERR_IO_PENDING, result); | 125 DCHECK_NE(net::ERR_IO_PENDING, result); |
124 if (result == net::OK) { | 126 if (result == net::OK) { |
125 *backend_ = created_cache_.Pass(); | 127 *backend_ = std::move(created_cache_); |
126 } else { | 128 } else { |
127 LOG(ERROR) << "Unable to create cache"; | 129 LOG(ERROR) << "Unable to create cache"; |
128 created_cache_.reset(); | 130 created_cache_.reset(); |
129 } | 131 } |
130 callback_.Run(result); | 132 callback_.Run(result); |
131 delete this; | 133 delete this; |
132 } | 134 } |
133 | 135 |
134 // If the initialization of the cache fails, and |force| is true, we will | 136 // If the initialization of the cache fails, and |force| is true, we will |
135 // discard the whole cache and create a new one. | 137 // discard the whole cache and create a new one. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 backend_type, | 179 backend_type, |
178 kNone, | 180 kNone, |
179 thread, | 181 thread, |
180 net_log, | 182 net_log, |
181 backend, | 183 backend, |
182 callback); | 184 callback); |
183 return creator->Run(); | 185 return creator->Run(); |
184 } | 186 } |
185 | 187 |
186 } // namespace disk_cache | 188 } // namespace disk_cache |
OLD | NEW |