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