| 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_TRANSLATION_CACHE_H_ | 5 #ifndef COMPONENTS_NACL_BROWSER_PNACL_TRANSLATION_CACHE_H_ |
| 6 #define COMPONENTS_NACL_BROWSER_PNACL_TRANSLATION_CACHE_H_ | 6 #define COMPONENTS_NACL_BROWSER_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 21 matching lines...) Expand all Loading... |
| 32 class PnaclTranslationCacheEntry; | 32 class PnaclTranslationCacheEntry; |
| 33 extern const int kMaxMemCacheSize; | 33 extern const int kMaxMemCacheSize; |
| 34 | 34 |
| 35 class PnaclTranslationCache | 35 class PnaclTranslationCache |
| 36 : public base::SupportsWeakPtr<PnaclTranslationCache> { | 36 : public base::SupportsWeakPtr<PnaclTranslationCache> { |
| 37 public: | 37 public: |
| 38 PnaclTranslationCache(); | 38 PnaclTranslationCache(); |
| 39 virtual ~PnaclTranslationCache(); | 39 virtual ~PnaclTranslationCache(); |
| 40 | 40 |
| 41 // Initialize the translation cache in |cache_dir|. If the return value is | 41 // Initialize the translation cache in |cache_dir|. If the return value is |
| 42 // net::ERR_IO_PENDING, |callback| will be called with a 0 argument on sucess | 42 // net::ERR_IO_PENDING, |callback| will be called with a 0 argument on success |
| 43 // and <0 otherwise. | 43 // and <0 otherwise. |
| 44 int InitOnDisk(const base::FilePath& cache_dir, | 44 int InitOnDisk(const base::FilePath& cache_dir, |
| 45 const CompletionCallback& callback); | 45 const CompletionCallback& callback); |
| 46 | 46 |
| 47 // Initialize the translation cache in memory. If the return value is | 47 // Initialize the translation cache in memory. If the return value is |
| 48 // net::ERR_IO_PENDING, |callback| will be called with a 0 argument on sucess | 48 // net::ERR_IO_PENDING, |callback| will be called with a 0 argument on success |
| 49 // and <0 otherwise. | 49 // and <0 otherwise. |
| 50 int InitInMemory(const CompletionCallback& callback); | 50 int InitInMemory(const CompletionCallback& callback); |
| 51 | 51 |
| 52 // Store the nexe in the translation cache, and call |callback| with | 52 // Store the nexe in the translation cache, and call |callback| with |
| 53 // the result. The result passed to the callback is 0 on success and | 53 // the result. The result passed to the callback is 0 on success and |
| 54 // <0 otherwise. A reference to |nexe_data| is held until completion | 54 // <0 otherwise. A reference to |nexe_data| is held until completion |
| 55 // or cancellation. | 55 // or cancellation. |
| 56 void StoreNexe(const std::string& key, | 56 void StoreNexe(const std::string& key, |
| 57 net::DrainableIOBuffer* nexe_data, | 57 net::DrainableIOBuffer* nexe_data, |
| 58 const CompletionCallback& callback); | 58 const CompletionCallback& callback); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 CompletionCallback init_callback_; | 93 CompletionCallback init_callback_; |
| 94 bool in_memory_; | 94 bool in_memory_; |
| 95 std::map<void*, scoped_refptr<PnaclTranslationCacheEntry> > open_entries_; | 95 std::map<void*, scoped_refptr<PnaclTranslationCacheEntry> > open_entries_; |
| 96 | 96 |
| 97 DISALLOW_COPY_AND_ASSIGN(PnaclTranslationCache); | 97 DISALLOW_COPY_AND_ASSIGN(PnaclTranslationCache); |
| 98 }; | 98 }; |
| 99 | 99 |
| 100 } // namespace pnacl | 100 } // namespace pnacl |
| 101 | 101 |
| 102 #endif // COMPONENTS_NACL_BROWSER_PNACL_TRANSLATION_CACHE_H_ | 102 #endif // COMPONENTS_NACL_BROWSER_PNACL_TRANSLATION_CACHE_H_ |
| OLD | NEW |