| OLD | NEW |
| 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_WIN_H_ | 5 #ifndef IPC_IPC_CHANNEL_WIN_H_ |
| 6 #define IPC_IPC_CHANNEL_WIN_H_ | 6 #define IPC_IPC_CHANNEL_WIN_H_ |
| 7 | 7 |
| 8 #include "ipc/ipc_channel.h" | 8 #include "ipc/ipc_channel.h" |
| 9 | 9 |
| 10 #include <queue> | 10 #include <queue> |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
| 16 #include "base/win/scoped_handle.h" | 16 #include "base/win/scoped_handle.h" |
| 17 #include "ipc/ipc_channel_reader.h" | 17 #include "ipc/ipc_channel_reader.h" |
| 18 | 18 |
| 19 namespace base { | 19 namespace base { |
| 20 class ThreadChecker; | 20 class ThreadChecker; |
| 21 } | 21 } |
| 22 | 22 |
| 23 namespace IPC { | 23 namespace IPC { |
| 24 | 24 |
| 25 class ChannelWin : public Channel, | 25 class ChannelWin : public Channel, |
| 26 public internal::ChannelReader, | 26 public internal::ChannelReader, |
| 27 public base::MessageLoopForIO::IOHandler { | 27 public base::MessageLoopForIO::IOHandler { |
| 28 public: | 28 public: |
| 29 // Mirror methods of Channel, see ipc_channel.h for description. | 29 // Mirror methods of Channel, see ipc_channel.h for description. |
| 30 ChannelWin(const IPC::ChannelHandle &channel_handle, Mode mode, | 30 // |broker| must outlive the newly created object. |
| 31 Listener* listener); | 31 ChannelWin(const IPC::ChannelHandle& channel_handle, |
| 32 Mode mode, |
| 33 Listener* listener, |
| 34 AttachmentBroker* broker); |
| 32 ~ChannelWin() override; | 35 ~ChannelWin() override; |
| 33 | 36 |
| 34 // Channel implementation | 37 // Channel implementation |
| 35 bool Connect() override; | 38 bool Connect() override; |
| 36 void Close() override; | 39 void Close() override; |
| 37 bool Send(Message* message) override; | 40 bool Send(Message* message) override; |
| 41 AttachmentBroker* GetAttachmentBroker() override; |
| 38 base::ProcessId GetPeerPID() const override; | 42 base::ProcessId GetPeerPID() const override; |
| 39 base::ProcessId GetSelfPID() const override; | 43 base::ProcessId GetSelfPID() const override; |
| 40 | 44 |
| 41 static bool IsNamedServerInitialized(const std::string& channel_id); | 45 static bool IsNamedServerInitialized(const std::string& channel_id); |
| 42 | 46 |
| 43 | 47 |
| 44 private: | 48 private: |
| 45 // ChannelReader implementation. | 49 // ChannelReader implementation. |
| 46 ReadState ReadData(char* buffer, int buffer_len, int* bytes_read) override; | 50 ReadState ReadData(char* buffer, int buffer_len, int* bytes_read) override; |
| 47 bool WillDispatchInputMessage(Message* msg) override; | 51 bool WillDispatchInputMessage(Message* msg) override; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 | 101 |
| 98 // This is a unique per-channel value used to authenticate the client end of | 102 // This is a unique per-channel value used to authenticate the client end of |
| 99 // a connection. If the value is non-zero, the client passes it in the hello | 103 // a connection. If the value is non-zero, the client passes it in the hello |
| 100 // and the host validates. (We don't send the zero value fto preserve IPC | 104 // and the host validates. (We don't send the zero value fto preserve IPC |
| 101 // compatability with existing clients that don't validate the channel.) | 105 // compatability with existing clients that don't validate the channel.) |
| 102 int32 client_secret_; | 106 int32 client_secret_; |
| 103 | 107 |
| 104 scoped_ptr<base::ThreadChecker> thread_check_; | 108 scoped_ptr<base::ThreadChecker> thread_check_; |
| 105 base::WeakPtrFactory<ChannelWin> weak_factory_; | 109 base::WeakPtrFactory<ChannelWin> weak_factory_; |
| 106 | 110 |
| 111 // |broker_| must outlive this instance. |
| 112 AttachmentBroker* broker_; |
| 113 |
| 107 DISALLOW_COPY_AND_ASSIGN(ChannelWin); | 114 DISALLOW_COPY_AND_ASSIGN(ChannelWin); |
| 108 }; | 115 }; |
| 109 | 116 |
| 110 } // namespace IPC | 117 } // namespace IPC |
| 111 | 118 |
| 112 #endif // IPC_IPC_CHANNEL_WIN_H_ | 119 #endif // IPC_IPC_CHANNEL_WIN_H_ |
| OLD | NEW |