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

Side by Side Diff: chrome/nacl/nacl_ipc_manager.h

Issue 9863005: Initial implementation of an IPC adapter to expose Chrome IPC to Native Client. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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 | « chrome/nacl/nacl_ipc_adapter_unittest.cc ('k') | chrome/nacl/nacl_ipc_manager.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) 2012 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_NACL_NACL_IPC_MANAGER_H_
6 #define CHROME_NACL_NACL_IPC_MANAGER_H_
7 #pragma once
8
9 #include <map>
10
11 #include "base/memory/ref_counted.h"
12 #include "base/synchronization/lock.h"
13 #include "ipc/ipc_channel_handle.h"
14
15 class NaClIPCAdapter;
16
17 // This class manages all IPC channels exposed to NaCl. We give NaCl void*
18 // "handles" to identify channels. When the untrusted nacl code does operations
19 // on these handles, this class maps them to the corresponding adapter object.
20 //
21 // This class must be threadsafe since nacl send/recvmsg functions can be
22 // called on any thread.
23 class NaClIPCManager {
24 public:
25 NaClIPCManager();
26 ~NaClIPCManager();
27
28 // Creates a nacl channel associated with the given channel handle (normally
29 // this will come from the browser process). Returns the handle that should
30 // be given to nacl to associated with this IPC channel.
31 void* CreateChannel(const IPC::ChannelHandle& handle);
32
33 // Destroys the channel with the given handle.
34 void DestroyChannel(void* handle);
35
36 // Implementation of sendmsg on the given channel. The return value is the
37 // number of bytes written or -1 on failure.
38 int SendMessage(void* handle, const char* data, int data_length);
39
40 // Implementation of recvmsg on the given channel. The return value is the
41 // number of bytes received or -1 on failure.
42 int ReceiveMessage(void* handle, char* buffer, int buffer_length);
43
44 private:
45 // Looks up the adapter if given a handle. The pointer wil be null on
46 // failures.
47 scoped_refptr<NaClIPCAdapter> GetAdapter(void* handle);
48
49 // Lock around all data below.
50 base::Lock lock_;
51
52 // All active IPC channels. Locked by lock_ above.
53 typedef std::map<void*, scoped_refptr<NaClIPCAdapter> > AdapterMap;
54 AdapterMap adapters_;
55
56 DISALLOW_COPY_AND_ASSIGN(NaClIPCManager);
57 };
58
59 #endif // CHROME_NACL_NACL_IPC_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/nacl/nacl_ipc_adapter_unittest.cc ('k') | chrome/nacl/nacl_ipc_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698