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 "base/files/file_path.h" | 5 #include "base/files/file_path.h" |
6 #include "base/metrics/field_trial.h" | 6 #include "base/metrics/field_trial.h" |
7 #include "base/profiler/scoped_profile.h" | 7 #include "base/profiler/scoped_tracker.h" |
8 #include "base/single_thread_task_runner.h" | 8 #include "base/single_thread_task_runner.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "net/base/cache_type.h" | 10 #include "net/base/cache_type.h" |
11 #include "net/base/net_errors.h" | 11 #include "net/base/net_errors.h" |
12 #include "net/disk_cache/blockfile/backend_impl.h" | 12 #include "net/disk_cache/blockfile/backend_impl.h" |
13 #include "net/disk_cache/cache_util.h" | 13 #include "net/disk_cache/cache_util.h" |
14 #include "net/disk_cache/disk_cache.h" | 14 #include "net/disk_cache/disk_cache.h" |
15 #include "net/disk_cache/memory/mem_backend_impl.h" | 15 #include "net/disk_cache/memory/mem_backend_impl.h" |
16 #include "net/disk_cache/simple/simple_backend_impl.h" | 16 #include "net/disk_cache/simple/simple_backend_impl.h" |
17 | 17 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 LOG(ERROR) << "Unable to create cache"; | 133 LOG(ERROR) << "Unable to create cache"; |
134 created_cache_.reset(); | 134 created_cache_.reset(); |
135 } | 135 } |
136 callback_.Run(result); | 136 callback_.Run(result); |
137 delete this; | 137 delete this; |
138 } | 138 } |
139 | 139 |
140 // If the initialization of the cache fails, and |force| is true, we will | 140 // If the initialization of the cache fails, and |force| is true, we will |
141 // discard the whole cache and create a new one. | 141 // discard the whole cache and create a new one. |
142 void CacheCreator::OnIOComplete(int result) { | 142 void CacheCreator::OnIOComplete(int result) { |
143 // TODO(vadimt): Remove ScopedProfile below once crbug.com/422516 is fixed. | 143 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. |
144 tracked_objects::ScopedProfile tracking_profile( | 144 tracked_objects::ScopedTracker tracking_profile( |
145 FROM_HERE_WITH_EXPLICIT_FUNCTION("422516 CacheCreator::OnIOComplete")); | 145 FROM_HERE_WITH_EXPLICIT_FUNCTION("422516 CacheCreator::OnIOComplete")); |
146 | 146 |
147 if (result == net::OK || !force_ || retry_) | 147 if (result == net::OK || !force_ || retry_) |
148 return DoCallback(result); | 148 return DoCallback(result); |
149 | 149 |
150 // This is a failure and we are supposed to try again, so delete the object, | 150 // This is a failure and we are supposed to try again, so delete the object, |
151 // delete all the files, and try again. | 151 // delete all the files, and try again. |
152 retry_ = true; | 152 retry_ = true; |
153 created_cache_.reset(); | 153 created_cache_.reset(); |
154 if (!disk_cache::DelayedCacheCleanup(path_)) | 154 if (!disk_cache::DelayedCacheCleanup(path_)) |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 backend_type, | 187 backend_type, |
188 kNone, | 188 kNone, |
189 thread, | 189 thread, |
190 net_log, | 190 net_log, |
191 backend, | 191 backend, |
192 callback); | 192 callback); |
193 return creator->Run(); | 193 return creator->Run(); |
194 } | 194 } |
195 | 195 |
196 } // namespace disk_cache | 196 } // namespace disk_cache |
OLD | NEW |