| 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 CHROME_BROWSER_NACL_HOST_PNACL_TRANSLATION_CACHE_H_ | 5 #ifndef CHROME_BROWSER_NACL_HOST_PNACL_TRANSLATION_CACHE_H_ |
| 6 #define CHROME_BROWSER_NACL_HOST_PNACL_TRANSLATION_CACHE_H_ | 6 #define CHROME_BROWSER_NACL_HOST_PNACL_TRANSLATION_CACHE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 GetNexeCallback; | 35 GetNexeCallback; |
| 36 class PnaclTranslationCacheEntry; | 36 class PnaclTranslationCacheEntry; |
| 37 extern const int kMaxMemCacheSize; | 37 extern const int kMaxMemCacheSize; |
| 38 | 38 |
| 39 class PnaclTranslationCache | 39 class PnaclTranslationCache |
| 40 : public base::SupportsWeakPtr<PnaclTranslationCache> { | 40 : public base::SupportsWeakPtr<PnaclTranslationCache> { |
| 41 public: | 41 public: |
| 42 PnaclTranslationCache(); | 42 PnaclTranslationCache(); |
| 43 virtual ~PnaclTranslationCache(); | 43 virtual ~PnaclTranslationCache(); |
| 44 | 44 |
| 45 // Initialize the translation cache in |cache_dir|. | 45 // Initialize the translation cache in |cache_dir|. If the return value is |
| 46 // Call |callback| with a 0 argument on sucess and <0 otherwise. | 46 // net::ERR_IO_PENDING, |callback| will be called with a 0 argument on sucess |
| 47 // and <0 otherwise. |
| 47 int InitOnDisk(const base::FilePath& cache_dir, | 48 int InitOnDisk(const base::FilePath& cache_dir, |
| 48 const CompletionCallback& callback); | 49 const CompletionCallback& callback); |
| 49 | 50 |
| 50 // Initialize the translation cache in memory. | 51 // Initialize the translation cache in memory. If the return value is |
| 51 // Call |callback| with a 0 argument on sucess and <0 otherwise. | 52 // net::ERR_IO_PENDING, |callback| will be called with a 0 argument on sucess |
| 53 // and <0 otherwise. |
| 52 int InitInMemory(const CompletionCallback& callback); | 54 int InitInMemory(const CompletionCallback& callback); |
| 53 | 55 |
| 54 // Store the nexe in the translation cache. A reference to |nexe_data| is | |
| 55 // held until completion or cancellation. | |
| 56 void StoreNexe(const std::string& key, net::DrainableIOBuffer* nexe_data); | |
| 57 | |
| 58 // Store the nexe in the translation cache, and call |callback| with | 56 // Store the nexe in the translation cache, and call |callback| with |
| 59 // the result. The result passed to the callback is 0 on success and | 57 // the result. The result passed to the callback is 0 on success and |
| 60 // <0 otherwise. A reference to |nexe_data| is held until completion | 58 // <0 otherwise. A reference to |nexe_data| is held until completion |
| 61 // or cancellation. | 59 // or cancellation. |
| 62 void StoreNexe(const std::string& key, | 60 void StoreNexe(const std::string& key, |
| 63 net::DrainableIOBuffer* nexe_data, | 61 net::DrainableIOBuffer* nexe_data, |
| 64 const CompletionCallback& callback); | 62 const CompletionCallback& callback); |
| 65 | 63 |
| 66 // Retrieve the nexe from the translation cache. Write the data into |nexe| | 64 // Retrieve the nexe from the translation cache. Write the data into |nexe| |
| 67 // and call |callback|, passing a result code (0 on success and <0 otherwise), | 65 // and call |callback|, passing a result code (0 on success and <0 otherwise), |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 CompletionCallback init_callback_; | 97 CompletionCallback init_callback_; |
| 100 bool in_memory_; | 98 bool in_memory_; |
| 101 std::map<void*, scoped_refptr<PnaclTranslationCacheEntry> > open_entries_; | 99 std::map<void*, scoped_refptr<PnaclTranslationCacheEntry> > open_entries_; |
| 102 | 100 |
| 103 DISALLOW_COPY_AND_ASSIGN(PnaclTranslationCache); | 101 DISALLOW_COPY_AND_ASSIGN(PnaclTranslationCache); |
| 104 }; | 102 }; |
| 105 | 103 |
| 106 } // namespace pnacl | 104 } // namespace pnacl |
| 107 | 105 |
| 108 #endif // CHROME_BROWSER_NACL_HOST_PNACL_TRANSLATION_CACHE_H_ | 106 #endif // CHROME_BROWSER_NACL_HOST_PNACL_TRANSLATION_CACHE_H_ |
| OLD | NEW |