OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/browser/nacl_host/pnacl_host.h" | 5 #include "components/nacl/browser/pnacl_host.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_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/task_runner_util.h" | 12 #include "base/task_runner_util.h" |
13 #include "base/threading/sequenced_worker_pool.h" | 13 #include "base/threading/sequenced_worker_pool.h" |
14 #include "components/nacl/browser/nacl_browser.h" | 14 #include "components/nacl/browser/nacl_browser.h" |
15 #include "components/nacl/browser/pnacl_translation_cache.h" | 15 #include "components/nacl/browser/pnacl_translation_cache.h" |
16 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
17 #include "net/base/io_buffer.h" | 17 #include "net/base/io_buffer.h" |
18 #include "net/base/net_errors.h" | 18 #include "net/base/net_errors.h" |
19 | 19 |
20 using content::BrowserThread; | 20 using content::BrowserThread; |
21 | 21 |
22 namespace { | 22 namespace { |
23 static const base::FilePath::CharType kTranslationCacheDirectoryName[] = | 23 static const base::FilePath::CharType kTranslationCacheDirectoryName[] = |
24 FILE_PATH_LITERAL("PnaclTranslationCache"); | 24 FILE_PATH_LITERAL("PnaclTranslationCache"); |
25 // Delay to wait for initialization of the cache backend | 25 // Delay to wait for initialization of the cache backend |
26 static const int kTranslationCacheInitializationDelayMs = 20; | 26 static const int kTranslationCacheInitializationDelayMs = 20; |
27 } | 27 } |
28 | 28 |
| 29 namespace pnacl { |
| 30 |
29 PnaclHost::PnaclHost() | 31 PnaclHost::PnaclHost() |
30 : pending_backend_operations_(0), | 32 : pending_backend_operations_(0), |
31 cache_state_(CacheUninitialized), | 33 cache_state_(CacheUninitialized), |
32 weak_factory_(this) {} | 34 weak_factory_(this) {} |
33 | 35 |
34 PnaclHost::~PnaclHost() { | 36 PnaclHost::~PnaclHost() { |
35 // When PnaclHost is destroyed, it's too late to post anything to the cache | 37 // When PnaclHost is destroyed, it's too late to post anything to the cache |
36 // thread (it will hang shutdown). So just leak the cache backend. | 38 // thread (it will hang shutdown). So just leak the cache backend. |
37 pnacl::PnaclTranslationCache* cache = disk_cache_.release(); | 39 pnacl::PnaclTranslationCache* cache = disk_cache_.release(); |
38 (void)cache; | 40 (void)cache; |
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 // inside PnaclTranslationCache, we do not delete the backend if there are any | 623 // inside PnaclTranslationCache, we do not delete the backend if there are any |
622 // backend requests in flight. As a last resort in the destructor, we just leak | 624 // backend requests in flight. As a last resort in the destructor, we just leak |
623 // the backend to avoid hanging shutdown. | 625 // the backend to avoid hanging shutdown. |
624 void PnaclHost::DeInitIfSafe() { | 626 void PnaclHost::DeInitIfSafe() { |
625 DCHECK(pending_backend_operations_ >= 0); | 627 DCHECK(pending_backend_operations_ >= 0); |
626 if (pending_translations_.empty() && pending_backend_operations_ <= 0) { | 628 if (pending_translations_.empty() && pending_backend_operations_ <= 0) { |
627 cache_state_ = CacheUninitialized; | 629 cache_state_ = CacheUninitialized; |
628 disk_cache_.reset(); | 630 disk_cache_.reset(); |
629 } | 631 } |
630 } | 632 } |
| 633 |
| 634 } // namespace pnacl |
OLD | NEW |