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