| 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 "components/nacl/browser/pnacl_translation_cache.h" | 5 #include "components/nacl/browser/pnacl_translation_cache.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 const int kMaxMemCacheSize = 100 * 1024 * 1024; | 35 const int kMaxMemCacheSize = 100 * 1024 * 1024; |
| 36 | 36 |
| 37 ////////////////////////////////////////////////////////////////////// | 37 ////////////////////////////////////////////////////////////////////// |
| 38 // Handle Reading/Writing to Cache. | 38 // Handle Reading/Writing to Cache. |
| 39 | 39 |
| 40 // PnaclTranslationCacheEntry is a shim that provides storage for the | 40 // PnaclTranslationCacheEntry is a shim that provides storage for the |
| 41 // 'key' and 'data' strings as the disk_cache is performing various async | 41 // 'key' and 'data' strings as the disk_cache is performing various async |
| 42 // operations. It also tracks the open disk_cache::Entry | 42 // operations. It also tracks the open disk_cache::Entry |
| 43 // and ensures that the entry is closed. | 43 // and ensures that the entry is closed. |
| 44 class PnaclTranslationCacheEntry | 44 class PnaclTranslationCacheEntry |
| 45 : public base::RefCounted<PnaclTranslationCacheEntry> { | 45 : public base::RefCountedThreadSafe<PnaclTranslationCacheEntry> { |
| 46 public: | 46 public: |
| 47 static PnaclTranslationCacheEntry* GetReadEntry( | 47 static PnaclTranslationCacheEntry* GetReadEntry( |
| 48 base::WeakPtr<PnaclTranslationCache> cache, | 48 base::WeakPtr<PnaclTranslationCache> cache, |
| 49 const std::string& key, | 49 const std::string& key, |
| 50 const GetNexeCallback& callback); | 50 const GetNexeCallback& callback); |
| 51 static PnaclTranslationCacheEntry* GetWriteEntry( | 51 static PnaclTranslationCacheEntry* GetWriteEntry( |
| 52 base::WeakPtr<PnaclTranslationCache> cache, | 52 base::WeakPtr<PnaclTranslationCache> cache, |
| 53 const std::string& key, | 53 const std::string& key, |
| 54 net::DrainableIOBuffer* write_nexe, | 54 net::DrainableIOBuffer* write_nexe, |
| 55 const CompletionCallback& callback); | 55 const CompletionCallback& callback); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 69 enum CacheStep { | 69 enum CacheStep { |
| 70 UNINITIALIZED, | 70 UNINITIALIZED, |
| 71 OPEN_ENTRY, | 71 OPEN_ENTRY, |
| 72 CREATE_ENTRY, | 72 CREATE_ENTRY, |
| 73 TRANSFER_ENTRY, | 73 TRANSFER_ENTRY, |
| 74 CLOSE_ENTRY, | 74 CLOSE_ENTRY, |
| 75 FINISHED | 75 FINISHED |
| 76 }; | 76 }; |
| 77 | 77 |
| 78 private: | 78 private: |
| 79 friend class base::RefCounted<PnaclTranslationCacheEntry>; | 79 friend class base::RefCountedThreadSafe<PnaclTranslationCacheEntry>; |
| 80 PnaclTranslationCacheEntry(base::WeakPtr<PnaclTranslationCache> cache, | 80 PnaclTranslationCacheEntry(base::WeakPtr<PnaclTranslationCache> cache, |
| 81 const std::string& key, | 81 const std::string& key, |
| 82 bool is_read); | 82 bool is_read); |
| 83 ~PnaclTranslationCacheEntry(); | 83 ~PnaclTranslationCacheEntry(); |
| 84 | 84 |
| 85 // Try to open an existing entry in the backend | 85 // Try to open an existing entry in the backend |
| 86 void OpenEntry(); | 86 void OpenEntry(); |
| 87 // Create a new entry in the backend (for writes) | 87 // Create a new entry in the backend (for writes) |
| 88 void CreateEntry(); | 88 void CreateEntry(); |
| 89 // Write |len| bytes to the backend, starting at |offset| | 89 // Write |len| bytes to the backend, starting at |offset| |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 } | 438 } |
| 439 | 439 |
| 440 int PnaclTranslationCache::DoomEntriesBetween( | 440 int PnaclTranslationCache::DoomEntriesBetween( |
| 441 base::Time initial, | 441 base::Time initial, |
| 442 base::Time end, | 442 base::Time end, |
| 443 const CompletionCallback& callback) { | 443 const CompletionCallback& callback) { |
| 444 return disk_cache_->DoomEntriesBetween(initial, end, callback); | 444 return disk_cache_->DoomEntriesBetween(initial, end, callback); |
| 445 } | 445 } |
| 446 | 446 |
| 447 } // namespace pnacl | 447 } // namespace pnacl |
| OLD | NEW |