| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
| 6 |
| 7 #include "base/files/file_path.h" |
| 8 #include "content/browser/service_worker/service_worker_context_core.h" |
| 9 #include "content/public/browser/browser_thread.h" |
| 10 #include "webkit/browser/quota/quota_manager.h" |
| 11 |
| 12 namespace content { |
| 13 |
| 14 ServiceWorkerContextWrapper::ServiceWorkerContextWrapper( |
| 15 const base::FilePath& user_data_directory, |
| 16 quota::QuotaManagerProxy* quota_manager_proxy) |
| 17 : quota_manager_proxy_(quota_manager_proxy), |
| 18 user_data_directory_(user_data_directory), |
| 19 is_shutdown_(false) { |
| 20 } |
| 21 |
| 22 ServiceWorkerContextWrapper::~ServiceWorkerContextWrapper() { |
| 23 } |
| 24 |
| 25 void ServiceWorkerContextWrapper::Shutdown() { |
| 26 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { |
| 27 BrowserThread::PostTask( |
| 28 BrowserThread::IO, FROM_HERE, |
| 29 base::Bind(&ServiceWorkerContextWrapper::Shutdown, this)); |
| 30 return; |
| 31 } |
| 32 is_shutdown_ = true; |
| 33 context_core_.reset(); |
| 34 } |
| 35 |
| 36 ServiceWorkerContextCore* ServiceWorkerContextWrapper::context() { |
| 37 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 38 if (is_shutdown_) |
| 39 return NULL; |
| 40 if (!context_core_) { |
| 41 context_core_.reset( |
| 42 new ServiceWorkerContextCore( |
| 43 user_data_directory_, quota_manager_proxy_)); |
| 44 } |
| 45 return context_core_.get(); |
| 46 } |
| 47 |
| 48 } // namespace content |
| OLD | NEW |