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

Side by Side Diff: ipc/ipc_channel_nacl.h

Issue 310293002: Make IPC::Channel polymorphic (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Another attempt to fix build breakage Created 6 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 | « ipc/ipc_channel_common.cc ('k') | ipc/ipc_channel_nacl.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 (c) 2012 The Chromium Authors. All rights reserved. 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 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 IPC_IPC_CHANNEL_NACL_H_ 5 #ifndef IPC_IPC_CHANNEL_NACL_H_
6 #define IPC_IPC_CHANNEL_NACL_H_ 6 #define IPC_IPC_CHANNEL_NACL_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <string> 9 #include <string>
10 10
11 #include "base/memory/linked_ptr.h" 11 #include "base/memory/linked_ptr.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/process/process.h" 14 #include "base/process/process.h"
15 #include "base/threading/simple_thread.h" 15 #include "base/threading/simple_thread.h"
16 #include "ipc/ipc_channel.h" 16 #include "ipc/ipc_channel.h"
17 #include "ipc/ipc_channel_reader.h" 17 #include "ipc/ipc_channel_reader.h"
18 18
19 namespace IPC { 19 namespace IPC {
20 20
21 // Contains the results from one call to imc_recvmsg (data and file 21 // Contains the results from one call to imc_recvmsg (data and file
22 // descriptors). 22 // descriptors).
23 struct MessageContents; 23 struct MessageContents;
24 24
25 // Similar to the Posix version of ChannelImpl but for Native Client code. 25 // Similar to the ChannelPosix but for Native Client code.
26 // This is somewhat different because sendmsg/recvmsg here do not follow POSIX 26 // This is somewhat different because sendmsg/recvmsg here do not follow POSIX
27 // semantics. Instead, they are implemented by a custom embedding of 27 // semantics. Instead, they are implemented by a custom embedding of
28 // NaClDescCustom. See NaClIPCAdapter for the trusted-side implementation. 28 // NaClDescCustom. See NaClIPCAdapter for the trusted-side implementation.
29 // 29 //
30 // We don't need to worry about complicated set up and READWRITE mode for 30 // We don't need to worry about complicated set up and READWRITE mode for
31 // sharing handles. We also currently do not support passing file descriptors or 31 // sharing handles. We also currently do not support passing file descriptors or
32 // named pipes, and we use background threads to emulate signaling when we can 32 // named pipes, and we use background threads to emulate signaling when we can
33 // read or write without blocking. 33 // read or write without blocking.
34 class Channel::ChannelImpl : public internal::ChannelReader { 34 class ChannelNacl : public Channel,
35 public internal::ChannelReader {
35 public: 36 public:
36 // Mirror methods of Channel, see ipc_channel.h for description. 37 // Mirror methods of Channel, see ipc_channel.h for description.
37 ChannelImpl(const IPC::ChannelHandle& channel_handle, 38 ChannelNacl(const IPC::ChannelHandle& channel_handle,
38 Mode mode, 39 Mode mode,
39 Listener* listener); 40 Listener* listener);
40 virtual ~ChannelImpl(); 41 virtual ~ChannelNacl();
41 42
42 // Channel implementation. 43 // Channel implementation.
43 base::ProcessId peer_pid() const; 44 virtual base::ProcessId GetPeerPID() const OVERRIDE;
44 bool Connect(); 45 virtual bool Connect() OVERRIDE;
45 void Close(); 46 virtual void Close() OVERRIDE;
46 bool Send(Message* message); 47 virtual bool Send(Message* message) OVERRIDE;
47 48
48 // Posted to the main thread by ReaderThreadRunner. 49 // Posted to the main thread by ReaderThreadRunner.
49 void DidRecvMsg(scoped_ptr<MessageContents> contents); 50 void DidRecvMsg(scoped_ptr<MessageContents> contents);
50 void ReadDidFail(); 51 void ReadDidFail();
51 52
52 private: 53 private:
53 class ReaderThreadRunner; 54 class ReaderThreadRunner;
54 55
55 bool CreatePipe(const IPC::ChannelHandle& channel_handle); 56 bool CreatePipe(const IPC::ChannelHandle& channel_handle);
56 bool ProcessOutgoingMessages(); 57 bool ProcessOutgoingMessages();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 // Queue of file descriptors extracted from imc_recvmsg messages. 104 // Queue of file descriptors extracted from imc_recvmsg messages.
104 // NOTE: The implementation assumes underlying storage here is contiguous, so 105 // NOTE: The implementation assumes underlying storage here is contiguous, so
105 // don't change to something like std::deque<> without changing the 106 // don't change to something like std::deque<> without changing the
106 // implementation! 107 // implementation!
107 std::vector<int> input_fds_; 108 std::vector<int> input_fds_;
108 109
109 // This queue is used when a message is sent prior to Connect having been 110 // This queue is used when a message is sent prior to Connect having been
110 // called. Normally after we're connected, the queue is empty. 111 // called. Normally after we're connected, the queue is empty.
111 std::deque<linked_ptr<Message> > output_queue_; 112 std::deque<linked_ptr<Message> > output_queue_;
112 113
113 base::WeakPtrFactory<ChannelImpl> weak_ptr_factory_; 114 base::WeakPtrFactory<ChannelNacl> weak_ptr_factory_;
114 115
115 DISALLOW_IMPLICIT_CONSTRUCTORS(ChannelImpl); 116 DISALLOW_IMPLICIT_CONSTRUCTORS(ChannelNacl);
116 }; 117 };
117 118
118 } // namespace IPC 119 } // namespace IPC
119 120
120 #endif // IPC_IPC_CHANNEL_NACL_H_ 121 #endif // IPC_IPC_CHANNEL_NACL_H_
OLDNEW
« no previous file with comments | « ipc/ipc_channel_common.cc ('k') | ipc/ipc_channel_nacl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698