diff options
author | Jocelyn Turcotte <jocelyn.turcotte@digia.com> | 2014-08-08 14:30:41 +0200 |
---|---|---|
committer | Jocelyn Turcotte <jocelyn.turcotte@digia.com> | 2014-08-12 13:49:54 +0200 |
commit | ab0a50979b9eb4dfa3320eff7e187e41efedf7a9 (patch) | |
tree | 498dfb8a97ff3361a9f7486863a52bb4e26bb898 /chromium/ipc/ipc_channel.h | |
parent | 4ce69f7403811819800e7c5ae1318b2647e778d1 (diff) | |
download | qtwebengine-chromium-ab0a50979b9eb4dfa3320eff7e187e41efedf7a9.tar.gz |
Update Chromium to beta version 37.0.2062.68
Change-Id: I188e3b5aff1bec75566014291b654eb19f5bc8ca
Reviewed-by: Andras Becsi <andras.becsi@digia.com>
Diffstat (limited to 'chromium/ipc/ipc_channel.h')
-rw-r--r-- | chromium/ipc/ipc_channel.h | 114 |
1 files changed, 62 insertions, 52 deletions
diff --git a/chromium/ipc/ipc_channel.h b/chromium/ipc/ipc_channel.h index 7e09a806f7a..bca3ea066c3 100644 --- a/chromium/ipc/ipc_channel.h +++ b/chromium/ipc/ipc_channel.h @@ -55,21 +55,15 @@ class IPC_EXPORT Channel : public Sender { }; // Some Standard Modes + // TODO(morrita): These are under deprecation work. You should use Create*() + // functions instead. enum Mode { MODE_NONE = MODE_NO_FLAG, MODE_SERVER = MODE_SERVER_FLAG, MODE_CLIENT = MODE_CLIENT_FLAG, - // Channels on Windows are named by default and accessible from other - // processes. On POSIX channels are anonymous by default and not accessible - // from other processes. Named channels work via named unix domain sockets. - // On Windows MODE_NAMED_SERVER is equivalent to MODE_SERVER and - // MODE_NAMED_CLIENT is equivalent to MODE_CLIENT. MODE_NAMED_SERVER = MODE_SERVER_FLAG | MODE_NAMED_FLAG, MODE_NAMED_CLIENT = MODE_CLIENT_FLAG | MODE_NAMED_FLAG, #if defined(OS_POSIX) - // An "open" named server accepts connections from ANY client. - // The caller must then implement their own access-control based on the - // client process' user Id. MODE_OPEN_NAMED_SERVER = MODE_OPEN_ACCESS_FLAG | MODE_SERVER_FLAG | MODE_NAMED_FLAG #endif @@ -106,15 +100,48 @@ class IPC_EXPORT Channel : public Sender { // the file descriptor in the channel handle is != -1, the channel takes // ownership of the file descriptor and will close it appropriately, otherwise // it will create a new descriptor internally. - // |mode| specifies whether this Channel is to operate in server mode or - // client mode. In server mode, the Channel is responsible for setting up the - // IPC object, whereas in client mode, the Channel merely connects to the - // already established IPC object. // |listener| receives a callback on the current thread for each newly // received message. // - Channel(const IPC::ChannelHandle &channel_handle, Mode mode, - Listener* listener); + // There are four type of modes how channels operate: + // + // - Server and named server: In these modes, the Channel is + // responsible for settingb up the IPC object + // - An "open" named server: It accepts connections from ANY client. + // The caller must then implement their own access-control based on the + // client process' user Id. + // - Client and named client: In these mode, the Channel merely + // connects to the already established IPC object. + // + // Each mode has its own Create*() API to create the Channel object. + // + // TODO(morrita): Replace CreateByModeForProxy() with one of above Create*(). + // + static scoped_ptr<Channel> Create( + const IPC::ChannelHandle &channel_handle, Mode mode,Listener* listener); + + static scoped_ptr<Channel> CreateClient( + const IPC::ChannelHandle &channel_handle, Listener* listener); + + // Channels on Windows are named by default and accessible from other + // processes. On POSIX channels are anonymous by default and not accessible + // from other processes. Named channels work via named unix domain sockets. + // On Windows MODE_NAMED_SERVER is equivalent to MODE_SERVER and + // MODE_NAMED_CLIENT is equivalent to MODE_CLIENT. + static scoped_ptr<Channel> CreateNamedServer( + const IPC::ChannelHandle &channel_handle, Listener* listener); + static scoped_ptr<Channel> CreateNamedClient( + const IPC::ChannelHandle &channel_handle, Listener* listener); +#if defined(OS_POSIX) + // An "open" named server accepts connections from ANY client. + // The caller must then implement their own access-control based on the + // client process' user Id. + static scoped_ptr<Channel> CreateOpenNamedServer( + const IPC::ChannelHandle &channel_handle, Listener* listener); +#endif + static scoped_ptr<Channel> CreateServer( + const IPC::ChannelHandle &channel_handle, Listener* listener); + virtual ~Channel(); @@ -123,14 +150,14 @@ class IPC_EXPORT Channel : public Sender { // connect to a pre-existing pipe. Note, calling Connect() // will not block the calling thread and may complete // asynchronously. - bool Connect() WARN_UNUSED_RESULT; + virtual bool Connect() WARN_UNUSED_RESULT = 0; // Close this Channel explicitly. May be called multiple times. // On POSIX calling close on an IPC channel that listens for connections will // cause it to close any accepted connections, and it will stop listening for // new connections. If you just want to close the currently accepted // connection and listen for new ones, use ResetToAcceptingConnectionState. - void Close(); + virtual void Close() = 0; // Get the process ID for the connected peer. // @@ -141,45 +168,25 @@ class IPC_EXPORT Channel : public Sender { // in response to a message from the remote side (which guarantees that it's // been connected), or you wait for the "connected" notification on the // listener. - base::ProcessId peer_pid() const; + virtual base::ProcessId GetPeerPID() const = 0; // Send a message over the Channel to the listener on the other end. // // |message| must be allocated using operator new. This object will be // deleted once the contents of the Message have been sent. - virtual bool Send(Message* message) OVERRIDE; + virtual bool Send(Message* message) = 0; -#if defined(OS_POSIX) +#if defined(OS_POSIX) && !defined(OS_NACL) // On POSIX an IPC::Channel wraps a socketpair(), this method returns the // FD # for the client end of the socket. // This method may only be called on the server side of a channel. // This method can be called on any thread. - int GetClientFileDescriptor() const; + virtual int GetClientFileDescriptor() const = 0; // Same as GetClientFileDescriptor, but transfers the ownership of the // file descriptor to the caller. // This method can be called on any thread. - int TakeClientFileDescriptor(); - - // On POSIX an IPC::Channel can either wrap an established socket, or it - // can wrap a socket that is listening for connections. Currently an - // IPC::Channel that listens for connections can only accept one connection - // at a time. - - // Returns true if the channel supports listening for connections. - bool AcceptsConnections() const; - - // Returns true if the channel supports listening for connections and is - // currently connected. - bool HasAcceptedConnection() const; - - // Returns true if the peer process' effective user id can be determined, in - // which case the supplied peer_euid is updated with it. - bool GetPeerEuid(uid_t* peer_euid) const; - - // Closes any currently connected socket, and returns to a listening state - // for more connections. - void ResetToAcceptingConnectionState(); + virtual int TakeClientFileDescriptor() = 0; #endif // defined(OS_POSIX) && !defined(OS_NACL) // Returns true if a named server channel is initialized on the given channel @@ -204,19 +211,22 @@ class IPC_EXPORT Channel : public Sender { static void SetGlobalPid(int pid); #endif - protected: - // Used in Chrome by the TestSink to provide a dummy channel implementation - // for testing. TestSink overrides the "interesting" functions in Channel so - // no actual implementation is needed. This will cause un-overridden calls to - // segfault. Do not use outside of test code! - Channel() : channel_impl_(0) { } - - private: - // PIMPL to which all channel calls are delegated. - class ChannelImpl; - ChannelImpl *channel_impl_; +#if defined(OS_ANDROID) + // Most tests are single process and work the same on all platforms. However + // in some cases we want to test multi-process, and Android differs in that it + // can't 'exec' after forking. This callback resets any data in the forked + // process such that it acts similar to if it was exec'd, for tests. + static void NotifyProcessForkedForTesting(); +#endif + }; +#if defined(OS_POSIX) +// SocketPair() creates a pair of socket FDs suitable for using with +// IPC::Channel. +IPC_EXPORT bool SocketPair(int* fd1, int* fd2); +#endif + } // namespace IPC #endif // IPC_IPC_CHANNEL_H_ |