Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(256)

Side by Side Diff: chrome/browser/nacl_host/pnacl_translation_cache.h

Issue 16232011: Add PNaCl translation cache based on Chrome disk_cache (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test type Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/nacl_host/pnacl_translation_cache.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_NACL_HOST_PNACL_TRANSLATION_CACHE_H_
6 #define CHROME_BROWSER_NACL_HOST_PNACL_TRANSLATION_CACHE_H_
7
8 #include <map>
9
10 #include "base/callback.h"
11 #include "base/files/file_path.h"
12 #include "base/memory/weak_ptr.h"
13 #include "net/base/cache_type.h"
14
15 namespace base {
16 class MessageLoopProxy;
17 }
18
19 namespace disk_cache {
20 class Backend;
21 }
22
23 namespace pnacl_cache {
24 typedef base::Callback<void(int)> CompletionCallback;
25 class PNaClTranslationCacheWriteEntry;
26 extern const int kMaxMemCacheSize;
27
28 class PNaClTranslationCache
29 : public base::SupportsWeakPtr<PNaClTranslationCache> {
30 public:
31 PNaClTranslationCache();
32 virtual ~PNaClTranslationCache();
33
34 // Initialize the translation cache in |cache_dir| (or in memory if
35 // |in_memory| is true). Call |callback| with a 0 argument on sucess and
36 // <0 otherwise.
37 int InitCache(const base::FilePath& cache_dir,
38 bool in_memory,
39 const CompletionCallback& callback);
40
41 // Store the nexe in the translation cache.
42 void StoreNexe(const std::string& key, const std::string& nexe);
43
44 // Store the nexe in the translation cache, and call |callback| with
45 // the result. The result passed to the callback is 0 on success and
46 // <0 otherwise.
47 void StoreNexe(const std::string& key,
48 const std::string& nexe,
49 const CompletionCallback& callback);
50
51 // Retrieve the nexe from the translation cache. (Not implemented yet.)
52 int GetNexe(const std::string& key,
53 std::string* nexe,
54 const CompletionCallback& callback);
55
56 // Return the number of entries in the cache backend.
57 int Size();
58
59 private:
60 friend class PNaClTranslationCacheWriteEntry;
61 // PNaClTranslationCacheWriteEntry should only use the
62 // WriteComplete and backend methods on PNaClTranslationCache.
63 void WriteComplete(PNaClTranslationCacheWriteEntry* entry);
64 disk_cache::Backend* backend() { return disk_cache_; }
65
66 int InitWithDiskBackend(const base::FilePath& disk_cache_dir,
67 int cache_size,
68 const CompletionCallback& callback);
69
70 int InitWithMemBackend(int cache_size, const CompletionCallback& callback);
71
72 int Init(net::CacheType,
73 const base::FilePath& directory,
74 int cache_size,
75 const CompletionCallback& callback);
76
77 void OnCreateBackendComplete(int rv);
78
79 disk_cache::Backend* disk_cache_;
80 CompletionCallback init_callback_;
81 bool in_memory_;
82 std::map<void*, scoped_refptr<PNaClTranslationCacheWriteEntry> >
83 write_entries_;
84
85 DISALLOW_COPY_AND_ASSIGN(PNaClTranslationCache);
86 };
87
88 } // namespace pnacl_cache
89
90 #endif // CHROME_BROWSER_NACL_HOST_PNACL_TRANSLATION_CACHE_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/nacl_host/pnacl_translation_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698