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

Side by Side Diff: components/nacl/loader/nacl_ipc_adapter.h

Issue 728113002: obsolete: SFI NaCl: Batch-open resource files (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 6 years, 1 month 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
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 CHROME_NACL_NACL_IPC_ADAPTER_H_ 5 #ifndef CHROME_NACL_NACL_IPC_ADAPTER_H_
6 #define CHROME_NACL_NACL_IPC_ADAPTER_H_ 6 #define CHROME_NACL_NACL_IPC_ADAPTER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <queue> 9 #include <queue>
10 #include <string> 10 #include <string>
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 ResolveFileTokenCallback; 124 ResolveFileTokenCallback;
125 125
126 // Sets a callback to be invoked for resolving file tokens received from the 126 // Sets a callback to be invoked for resolving file tokens received from the
127 // renderer. When the file token is resolved, the 127 // renderer. When the file token is resolved, the
128 // ResolveFileTokenReplyCallback passed inside the ResolveFileTokenCallback 128 // ResolveFileTokenReplyCallback passed inside the ResolveFileTokenCallback
129 // will be invoked. 129 // will be invoked.
130 void set_resolve_file_token_callback(ResolveFileTokenCallback cb) { 130 void set_resolve_file_token_callback(ResolveFileTokenCallback cb) {
131 resolve_file_token_cb_ = cb; 131 resolve_file_token_cb_ = cb;
132 } 132 }
133 133
134 typedef base::Callback<void(const IPC::Message&,
135 IPC::PlatformFileForTransit,
136 base::FilePath)> OpenResourceReplyCallback;
137
138 typedef base::Callback<bool(const IPC::Message&,
139 const std::string&, // key
140 OpenResourceReplyCallback)> OpenResourceCallback;
141
142 // Sets a callback to be invoked for intercepting open_resource IRT calls.
143 // The callback may immediately call a OpenResourceReplyCallback function to
144 // send a pre-opened resrouce descriptor to the untrusted side.
145 // OpenResourceCallback returns true when OpenResourceReplyCallback is called.
146 void set_open_resource_callback(OpenResourceCallback cb) {
147 open_resource_cb_ = cb;
148 }
149
134 private: 150 private:
135 friend class base::RefCountedThreadSafe<NaClIPCAdapter>; 151 friend class base::RefCountedThreadSafe<NaClIPCAdapter>;
136 152
137 class RewrittenMessage; 153 class RewrittenMessage;
138 154
139 // This is the data that must only be accessed inside the lock. This struct 155 // This is the data that must only be accessed inside the lock. This struct
140 // just separates it so it's easier to see. 156 // just separates it so it's easier to see.
141 struct LockedData { 157 struct LockedData {
142 LockedData(); 158 LockedData();
143 ~LockedData(); 159 ~LockedData();
(...skipping 29 matching lines...) Expand all
173 // for scanning. 189 // for scanning.
174 typedef std::map<int, uint32> PendingSyncMsgMap; 190 typedef std::map<int, uint32> PendingSyncMsgMap;
175 PendingSyncMsgMap pending_sync_msgs_; 191 PendingSyncMsgMap pending_sync_msgs_;
176 }; 192 };
177 193
178 ~NaClIPCAdapter() override; 194 ~NaClIPCAdapter() override;
179 195
180 void OnFileTokenResolved(const IPC::Message& orig_msg, 196 void OnFileTokenResolved(const IPC::Message& orig_msg,
181 IPC::PlatformFileForTransit ipc_fd, 197 IPC::PlatformFileForTransit ipc_fd,
182 base::FilePath file_path); 198 base::FilePath file_path);
199 void OnFileTokenResolvedLocked(const IPC::Message& orig_msg,
200 IPC::PlatformFileForTransit ipc_fd,
201 base::FilePath file_path);
183 202
184 bool RewriteMessage(const IPC::Message& msg, uint32_t type); 203 bool RewriteMessage(const IPC::Message& msg, uint32_t type);
185 204
186 // Returns 0 if nothing is waiting. 205 // Returns 0 if nothing is waiting.
187 int LockedReceive(NaClImcTypedMsgHdr* msg); 206 int LockedReceive(NaClImcTypedMsgHdr* msg);
188 207
189 // Sends a message that we know has been completed to the Chrome process. 208 // Sends a message that we know has been completed to the Chrome process.
190 bool SendCompleteMessage(const char* buffer, size_t buffer_len); 209 bool SendCompleteMessage(const char* buffer, size_t buffer_len);
191 210
192 // Clears the LockedData.to_be_sent_ structure in a way to make sure that 211 // Clears the LockedData.to_be_sent_ structure in a way to make sure that
193 // the memory is deleted. std::string can sometimes hold onto the buffer 212 // the memory is deleted. std::string can sometimes hold onto the buffer
194 // for future use which we don't want. 213 // for future use which we don't want.
195 void ClearToBeSent(); 214 void ClearToBeSent();
196 215
197 void ConnectChannelOnIOThread(); 216 void ConnectChannelOnIOThread();
198 void CloseChannelOnIOThread(); 217 void CloseChannelOnIOThread();
199 void SendMessageOnIOThread(scoped_ptr<IPC::Message> message); 218 void SendMessageOnIOThread(scoped_ptr<IPC::Message> message);
200 219
201 // Saves the message to forward to NaCl. This method assumes that the caller 220 // Saves the message to forward to NaCl. This method assumes that the caller
202 // holds the lock for locked_data_. 221 // holds the lock for locked_data_.
203 void SaveMessage(const IPC::Message& message, 222 void SaveMessage(const IPC::Message& message,
204 RewrittenMessage* rewritten_message); 223 RewrittenMessage* rewritten_message);
205 224
206 base::Lock lock_; 225 base::Lock lock_;
207 base::ConditionVariable cond_var_; 226 base::ConditionVariable cond_var_;
208 227
209 scoped_refptr<base::TaskRunner> task_runner_; 228 scoped_refptr<base::TaskRunner> task_runner_;
210 229
211 ResolveFileTokenCallback resolve_file_token_cb_; 230 ResolveFileTokenCallback resolve_file_token_cb_;
231 OpenResourceCallback open_resource_cb_;
212 232
213 // To be accessed inside of lock_ only. 233 // To be accessed inside of lock_ only.
214 LockedData locked_data_; 234 LockedData locked_data_;
215 235
216 // To be accessed on the I/O thread (via task runner) only. 236 // To be accessed on the I/O thread (via task runner) only.
217 IOThreadData io_thread_data_; 237 IOThreadData io_thread_data_;
218 238
219 DISALLOW_COPY_AND_ASSIGN(NaClIPCAdapter); 239 DISALLOW_COPY_AND_ASSIGN(NaClIPCAdapter);
220 }; 240 };
221 241
222 // Export TranslatePepperFileReadWriteOpenFlags for testing. 242 // Export TranslatePepperFileReadWriteOpenFlags for testing.
223 int TranslatePepperFileReadWriteOpenFlagsForTesting(int32_t pp_open_flags); 243 int TranslatePepperFileReadWriteOpenFlagsForTesting(int32_t pp_open_flags);
224 244
225 #endif // CHROME_NACL_NACL_IPC_ADAPTER_H_ 245 #endif // CHROME_NACL_NACL_IPC_ADAPTER_H_
OLDNEW
« no previous file with comments | « components/nacl/browser/nacl_process_host.cc ('k') | components/nacl/loader/nacl_ipc_adapter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698