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 "webkit/appcache/appcache_disk_cache.h" | 5 #include "webkit/appcache/appcache_disk_cache.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 net::CompletionCallback callback_; | 147 net::CompletionCallback callback_; |
148 AppCacheDiskCache* owner_; | 148 AppCacheDiskCache* owner_; |
149 disk_cache::Entry* entry_ptr_; | 149 disk_cache::Entry* entry_ptr_; |
150 }; | 150 }; |
151 | 151 |
152 AppCacheDiskCache::AppCacheDiskCache() | 152 AppCacheDiskCache::AppCacheDiskCache() |
153 : is_disabled_(false) { | 153 : is_disabled_(false) { |
154 } | 154 } |
155 | 155 |
156 AppCacheDiskCache::~AppCacheDiskCache() { | 156 AppCacheDiskCache::~AppCacheDiskCache() { |
157 if (create_backend_callback_) { | 157 if (create_backend_callback_.get()) { |
158 create_backend_callback_->Cancel(); | 158 create_backend_callback_->Cancel(); |
159 create_backend_callback_ = NULL; | 159 create_backend_callback_ = NULL; |
160 OnCreateBackendComplete(net::ERR_ABORTED); | 160 OnCreateBackendComplete(net::ERR_ABORTED); |
161 } | 161 } |
162 disk_cache_.reset(); | 162 disk_cache_.reset(); |
163 STLDeleteElements(&active_calls_); | 163 STLDeleteElements(&active_calls_); |
164 } | 164 } |
165 | 165 |
166 int AppCacheDiskCache::InitWithDiskBackend( | 166 int AppCacheDiskCache::InitWithDiskBackend( |
167 const FilePath& disk_cache_directory, int disk_cache_size, bool force, | 167 const FilePath& disk_cache_directory, int disk_cache_size, bool force, |
168 base::MessageLoopProxy* cache_thread, | 168 base::MessageLoopProxy* cache_thread, |
169 const net::CompletionCallback& callback) { | 169 const net::CompletionCallback& callback) { |
170 return Init(net::APP_CACHE, disk_cache_directory, | 170 return Init(net::APP_CACHE, disk_cache_directory, |
171 disk_cache_size, force, cache_thread, callback); | 171 disk_cache_size, force, cache_thread, callback); |
172 } | 172 } |
173 | 173 |
174 int AppCacheDiskCache::InitWithMemBackend( | 174 int AppCacheDiskCache::InitWithMemBackend( |
175 int mem_cache_size, const net::CompletionCallback& callback) { | 175 int mem_cache_size, const net::CompletionCallback& callback) { |
176 return Init(net::MEMORY_CACHE, FilePath(), mem_cache_size, false, NULL, | 176 return Init(net::MEMORY_CACHE, FilePath(), mem_cache_size, false, NULL, |
177 callback); | 177 callback); |
178 } | 178 } |
179 | 179 |
180 void AppCacheDiskCache::Disable() { | 180 void AppCacheDiskCache::Disable() { |
181 if (is_disabled_) | 181 if (is_disabled_) |
182 return; | 182 return; |
183 | 183 |
184 is_disabled_ = true; | 184 is_disabled_ = true; |
185 | 185 |
186 if (create_backend_callback_) { | 186 if (create_backend_callback_.get()) { |
187 create_backend_callback_->Cancel(); | 187 create_backend_callback_->Cancel(); |
188 create_backend_callback_ = NULL; | 188 create_backend_callback_ = NULL; |
189 OnCreateBackendComplete(net::ERR_ABORTED); | 189 OnCreateBackendComplete(net::ERR_ABORTED); |
190 } | 190 } |
191 } | 191 } |
192 | 192 |
193 int AppCacheDiskCache::CreateEntry(int64 key, Entry** entry, | 193 int AppCacheDiskCache::CreateEntry(int64 key, Entry** entry, |
194 const net::CompletionCallback& callback) { | 194 const net::CompletionCallback& callback) { |
195 DCHECK(entry); | 195 DCHECK(entry); |
196 DCHECK(!callback.is_null()); | 196 DCHECK(!callback.is_null()); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 NOTREACHED(); | 313 NOTREACHED(); |
314 break; | 314 break; |
315 } | 315 } |
316 if (rv != net::ERR_IO_PENDING) | 316 if (rv != net::ERR_IO_PENDING) |
317 iter->callback.Run(rv); | 317 iter->callback.Run(rv); |
318 } | 318 } |
319 pending_calls_.clear(); | 319 pending_calls_.clear(); |
320 } | 320 } |
321 | 321 |
322 } // namespace appcache | 322 } // namespace appcache |
OLD | NEW |