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

Side by Side Diff: components/nacl/browser/pnacl_host.h

Issue 165663002: Remove some PlatformFile uses from NaCl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add empty line Created 6 years, 10 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 | « components/nacl/browser/nacl_process_host.cc ('k') | components/nacl/browser/pnacl_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <map> 8 #include <map>
9 9
10 #include "base/callback_forward.h" 10 #include "base/callback_forward.h"
11 #include "base/files/file.h"
11 #include "base/memory/singleton.h" 12 #include "base/memory/singleton.h"
12 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
13 #include "base/threading/thread_checker.h" 14 #include "base/threading/thread_checker.h"
14 #include "components/nacl/browser/nacl_file_host.h" 15 #include "components/nacl/browser/nacl_file_host.h"
15 #include "components/nacl/common/pnacl_types.h" 16 #include "components/nacl/common/pnacl_types.h"
16 #include "ipc/ipc_platform_file.h" 17 #include "ipc/ipc_platform_file.h"
17 18
18 namespace net { 19 namespace net {
19 class DrainableIOBuffer; 20 class DrainableIOBuffer;
20 } 21 }
21 22
22 namespace pnacl { 23 namespace pnacl {
23 24
24 class PnaclHostTest; 25 class PnaclHostTest;
25 class PnaclHostTestDisk; 26 class PnaclHostTestDisk;
26 class PnaclTranslationCache; 27 class PnaclTranslationCache;
27 28
28 // Shared state (translation cache) and common utilities (temp file creation) 29 // Shared state (translation cache) and common utilities (temp file creation)
29 // for all PNaCl translations. Unless otherwise specified, all methods should be 30 // for all PNaCl translations. Unless otherwise specified, all methods should be
30 // called on the IO thread. 31 // called on the IO thread.
31 class PnaclHost { 32 class PnaclHost {
32 public: 33 public:
33 typedef base::Callback<void(base::PlatformFile)> TempFileCallback; 34 typedef base::Callback<void(base::File)> TempFileCallback;
34 typedef base::Callback<void(base::PlatformFile, bool is_hit)> NexeFdCallback; 35 typedef base::Callback<void(base::PlatformFile, bool is_hit)> NexeFdCallback;
35 36
36 static PnaclHost* GetInstance(); 37 static PnaclHost* GetInstance();
37 38
38 PnaclHost(); 39 PnaclHost();
39 ~PnaclHost(); 40 ~PnaclHost();
40 41
41 // Initialize cache backend. GetNexeFd will also initialize the backend if 42 // Initialize cache backend. GetNexeFd will also initialize the backend if
42 // necessary, but calling Init ahead of time will minimize the latency. 43 // necessary, but calling Init ahead of time will minimize the latency.
43 void Init(); 44 void Init();
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 136
136 static void DoCreateTemporaryFile(base::FilePath temp_dir_, 137 static void DoCreateTemporaryFile(base::FilePath temp_dir_,
137 TempFileCallback cb); 138 TempFileCallback cb);
138 139
139 // GetNexeFd common steps 140 // GetNexeFd common steps
140 void SendCacheQueryAndTempFileRequest(const std::string& key, 141 void SendCacheQueryAndTempFileRequest(const std::string& key,
141 const TranslationID& id); 142 const TranslationID& id);
142 void OnCacheQueryReturn(const TranslationID& id, 143 void OnCacheQueryReturn(const TranslationID& id,
143 int net_error, 144 int net_error,
144 scoped_refptr<net::DrainableIOBuffer> buffer); 145 scoped_refptr<net::DrainableIOBuffer> buffer);
145 void OnTempFileReturn(const TranslationID& id, base::PlatformFile fd); 146 void OnTempFileReturn(const TranslationID& id, base::File file);
146 void CheckCacheQueryReady(const PendingTranslationMap::iterator& entry); 147 void CheckCacheQueryReady(const PendingTranslationMap::iterator& entry);
147 148
148 // GetNexeFd miss path 149 // GetNexeFd miss path
149 void ReturnMiss(const PendingTranslationMap::iterator& entry); 150 void ReturnMiss(const PendingTranslationMap::iterator& entry);
150 static scoped_refptr<net::DrainableIOBuffer> CopyFileToBuffer( 151 static scoped_refptr<net::DrainableIOBuffer> CopyFileToBuffer(
151 base::PlatformFile fd); 152 base::PlatformFile fd);
152 void StoreTranslatedNexe(TranslationID id, 153 void StoreTranslatedNexe(TranslationID id,
153 scoped_refptr<net::DrainableIOBuffer>); 154 scoped_refptr<net::DrainableIOBuffer>);
154 void OnTranslatedNexeStored(const TranslationID& id, int net_error); 155 void OnTranslatedNexeStored(const TranslationID& id, int net_error);
155 void RequeryMatchingTranslations(const std::string& key); 156 void RequeryMatchingTranslations(const std::string& key);
(...skipping 15 matching lines...) Expand all
171 scoped_ptr<pnacl::PnaclTranslationCache> disk_cache_; 172 scoped_ptr<pnacl::PnaclTranslationCache> disk_cache_;
172 PendingTranslationMap pending_translations_; 173 PendingTranslationMap pending_translations_;
173 base::ThreadChecker thread_checker_; 174 base::ThreadChecker thread_checker_;
174 base::WeakPtrFactory<PnaclHost> weak_factory_; 175 base::WeakPtrFactory<PnaclHost> weak_factory_;
175 DISALLOW_COPY_AND_ASSIGN(PnaclHost); 176 DISALLOW_COPY_AND_ASSIGN(PnaclHost);
176 }; 177 };
177 178
178 } // namespace pnacl 179 } // namespace pnacl
179 180
180 #endif // COMPONENTS_NACL_BROWSER_PNACL_HOST_H_ 181 #endif // COMPONENTS_NACL_BROWSER_PNACL_HOST_H_
OLDNEW
« no previous file with comments | « components/nacl/browser/nacl_process_host.cc ('k') | components/nacl/browser/pnacl_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698