OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_service.h" | 5 #include "webkit/appcache/appcache_service.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/stl_util-inl.h" | 9 #include "base/stl_util-inl.h" |
10 #include "webkit/appcache/appcache_backend_impl.h" | 10 #include "webkit/appcache/appcache_backend_impl.h" |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 CallCallback(collection ? net::OK : net::ERR_FAILED); | 266 CallCallback(collection ? net::OK : net::ERR_FAILED); |
267 delete this; | 267 delete this; |
268 } | 268 } |
269 | 269 |
270 | 270 |
271 // AppCacheService ------- | 271 // AppCacheService ------- |
272 | 272 |
273 AppCacheService::AppCacheService(quota::QuotaManagerProxy* quota_manager_proxy) | 273 AppCacheService::AppCacheService(quota::QuotaManagerProxy* quota_manager_proxy) |
274 : appcache_policy_(NULL), quota_client_(NULL), | 274 : appcache_policy_(NULL), quota_client_(NULL), |
275 quota_manager_proxy_(quota_manager_proxy), | 275 quota_manager_proxy_(quota_manager_proxy), |
276 request_context_(NULL) { | 276 request_context_(NULL), clear_local_state_on_exit_(false) { |
277 if (quota_manager_proxy_) { | 277 if (quota_manager_proxy_) { |
278 quota_client_ = new AppCacheQuotaClient(this); | 278 quota_client_ = new AppCacheQuotaClient(this); |
279 quota_manager_proxy_->RegisterClient(quota_client_); | 279 quota_manager_proxy_->RegisterClient(quota_client_); |
280 } | 280 } |
281 } | 281 } |
282 | 282 |
283 AppCacheService::~AppCacheService() { | 283 AppCacheService::~AppCacheService() { |
284 DCHECK(backends_.empty()); | 284 DCHECK(backends_.empty()); |
285 std::for_each(pending_helpers_.begin(), | 285 std::for_each(pending_helpers_.begin(), |
286 pending_helpers_.end(), | 286 pending_helpers_.end(), |
287 std::mem_fun(&AsyncHelper::Cancel)); | 287 std::mem_fun(&AsyncHelper::Cancel)); |
288 STLDeleteElements(&pending_helpers_); | 288 STLDeleteElements(&pending_helpers_); |
289 if (quota_client_) | 289 if (quota_client_) |
290 quota_client_->NotifyAppCacheDestroyed(); | 290 quota_client_->NotifyAppCacheDestroyed(); |
| 291 |
| 292 // Destroy storage_ first; ~AppCacheStorageImpl accesses other data members |
| 293 // (special_storage_policy_). |
| 294 storage_.reset(); |
291 } | 295 } |
292 | 296 |
293 void AppCacheService::Initialize(const FilePath& cache_directory, | 297 void AppCacheService::Initialize(const FilePath& cache_directory, |
294 base::MessageLoopProxy* cache_thread) { | 298 base::MessageLoopProxy* cache_thread) { |
295 DCHECK(!storage_.get()); | 299 DCHECK(!storage_.get()); |
296 AppCacheStorageImpl* storage = new AppCacheStorageImpl(this); | 300 AppCacheStorageImpl* storage = new AppCacheStorageImpl(this); |
297 storage->Initialize(cache_directory, cache_thread); | 301 storage->Initialize(cache_directory, cache_thread); |
298 storage_.reset(storage); | 302 storage_.reset(storage); |
299 } | 303 } |
300 | 304 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 backends_.insert( | 340 backends_.insert( |
337 BackendMap::value_type(backend_impl->process_id(), backend_impl)); | 341 BackendMap::value_type(backend_impl->process_id(), backend_impl)); |
338 } | 342 } |
339 | 343 |
340 void AppCacheService::UnregisterBackend( | 344 void AppCacheService::UnregisterBackend( |
341 AppCacheBackendImpl* backend_impl) { | 345 AppCacheBackendImpl* backend_impl) { |
342 backends_.erase(backend_impl->process_id()); | 346 backends_.erase(backend_impl->process_id()); |
343 } | 347 } |
344 | 348 |
345 } // namespace appcache | 349 } // namespace appcache |
OLD | NEW |