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