| 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 #ifndef COMPONENTS_NACL_BROWSER_PNACL_HOST_H_ | 5 #ifndef COMPONENTS_NACL_BROWSER_PNACL_HOST_H_ |
| 6 #define COMPONENTS_NACL_BROWSER_PNACL_HOST_H_ | 6 #define COMPONENTS_NACL_BROWSER_PNACL_HOST_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 class PnaclHostTest; | 27 class PnaclHostTest; |
| 28 class PnaclHostTestDisk; | 28 class PnaclHostTestDisk; |
| 29 class PnaclTranslationCache; | 29 class PnaclTranslationCache; |
| 30 | 30 |
| 31 // Shared state (translation cache) and common utilities (temp file creation) | 31 // Shared state (translation cache) and common utilities (temp file creation) |
| 32 // for all PNaCl translations. Unless otherwise specified, all methods should be | 32 // for all PNaCl translations. Unless otherwise specified, all methods should be |
| 33 // called on the IO thread. | 33 // called on the IO thread. |
| 34 class PnaclHost { | 34 class PnaclHost { |
| 35 public: | 35 public: |
| 36 typedef base::Callback<void(base::File)> TempFileCallback; | 36 typedef base::Callback<void(base::File)> TempFileCallback; |
| 37 typedef base::Callback<void(const base::File&, bool is_hit)> NexeFdCallback; | 37 typedef base::Callback<void(base::File, bool is_hit)> NexeFdCallback; |
| 38 | 38 |
| 39 // Gets the PnaclHost singleton instance (creating it if necessary). | 39 // Gets the PnaclHost singleton instance (creating it if necessary). |
| 40 // PnaclHost is a singleton because there is only one translation cache, and | 40 // PnaclHost is a singleton because there is only one translation cache, and |
| 41 // so that the BrowsingDataRemover can clear it even if no translation has | 41 // so that the BrowsingDataRemover can clear it even if no translation has |
| 42 // ever been started. | 42 // ever been started. |
| 43 static PnaclHost* GetInstance(); | 43 static PnaclHost* GetInstance(); |
| 44 | 44 |
| 45 // The PnaclHost instance is intentionally leaked on shutdown. DeInitIfSafe() | 45 // The PnaclHost instance is intentionally leaked on shutdown. DeInitIfSafe() |
| 46 // attempts to cleanup |disk_cache_| earlier, but if it fails to do so in | 46 // attempts to cleanup |disk_cache_| earlier, but if it fails to do so in |
| 47 // time, it will be too late when AtExitManager kicks in anway so subscribing | 47 // time, it will be too late when AtExitManager kicks in anway so subscribing |
| (...skipping 15 matching lines...) Expand all Loading... |
| 63 // Returns by calling |cb| with a PlatformFile handle. | 63 // Returns by calling |cb| with a PlatformFile handle. |
| 64 // If the nexe is already present | 64 // If the nexe is already present |
| 65 // in the cache, |is_hit| is set to true and the contents of the nexe | 65 // in the cache, |is_hit| is set to true and the contents of the nexe |
| 66 // have been copied into the temporary file. Otherwise |is_hit| is set to | 66 // have been copied into the temporary file. Otherwise |is_hit| is set to |
| 67 // false and the temporary file will be writeable. | 67 // false and the temporary file will be writeable. |
| 68 // Currently the implementation is a stub, which always sets is_hit to false | 68 // Currently the implementation is a stub, which always sets is_hit to false |
| 69 // and calls the implementation of CreateTemporaryFile. | 69 // and calls the implementation of CreateTemporaryFile. |
| 70 // If the cache request was a miss, the caller is expected to call | 70 // If the cache request was a miss, the caller is expected to call |
| 71 // TranslationFinished after it finishes translation to allow the nexe to be | 71 // TranslationFinished after it finishes translation to allow the nexe to be |
| 72 // stored in the cache. | 72 // stored in the cache. |
| 73 // The returned temp fd may be closed at any time by PnaclHost, so it should | |
| 74 // be duplicated (e.g. with IPC::GetPlatformFileForTransit) before the | |
| 75 // callback returns. | |
| 76 // If |is_incognito| is true, the nexe will not be stored | 73 // If |is_incognito| is true, the nexe will not be stored |
| 77 // in the cache, but the renderer is still expected to call | 74 // in the cache, but the renderer is still expected to call |
| 78 // TranslationFinished. | 75 // TranslationFinished. |
| 79 void GetNexeFd(int render_process_id, | 76 void GetNexeFd(int render_process_id, |
| 80 int render_view_id, | 77 int render_view_id, |
| 81 int pp_instance, | 78 int pp_instance, |
| 82 bool is_incognito, | 79 bool is_incognito, |
| 83 const nacl::PnaclCacheInfo& cache_info, | 80 const nacl::PnaclCacheInfo& cache_info, |
| 84 const NexeFdCallback& cb); | 81 const NexeFdCallback& cb); |
| 85 | 82 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 base::FilePath temp_dir_; | 181 base::FilePath temp_dir_; |
| 185 std::unique_ptr<PnaclTranslationCache> disk_cache_; | 182 std::unique_ptr<PnaclTranslationCache> disk_cache_; |
| 186 PendingTranslationMap pending_translations_; | 183 PendingTranslationMap pending_translations_; |
| 187 base::ThreadChecker thread_checker_; | 184 base::ThreadChecker thread_checker_; |
| 188 DISALLOW_COPY_AND_ASSIGN(PnaclHost); | 185 DISALLOW_COPY_AND_ASSIGN(PnaclHost); |
| 189 }; | 186 }; |
| 190 | 187 |
| 191 } // namespace pnacl | 188 } // namespace pnacl |
| 192 | 189 |
| 193 #endif // COMPONENTS_NACL_BROWSER_PNACL_HOST_H_ | 190 #endif // COMPONENTS_NACL_BROWSER_PNACL_HOST_H_ |
| OLD | NEW |