Chromium Code Reviews| Index: content/browser/renderer_host/p2p_socket_host_posix.h |
| diff --git a/content/browser/renderer_host/p2p_socket_host_posix.h b/content/browser/renderer_host/p2p_socket_host_posix.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ee872f2abe80325036159d2134f2864e66319255 |
| --- /dev/null |
| +++ b/content/browser/renderer_host/p2p_socket_host_posix.h |
| @@ -0,0 +1,57 @@ |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_POSIX_H_ |
| +#define CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_POSIX_H_ |
| + |
| +#include "content/common/p2p_sockets.h" |
| + |
| +#include "base/message_loop.h" |
| +#include "content/browser/renderer_host/p2p_socket_host.h" |
| + |
| +class P2PSocketHostPosix : public P2PSocketHost { |
| + public: |
| + P2PSocketHostPosix(P2PSocketsHost* host, int routing_id, int id); |
|
jam
2011/03/02 00:41:09
if only the factory method is used to construct th
Sergey Ulanov
2011/03/02 11:00:47
The factory method is in a different class (P2PSoc
|
| + ~P2PSocketHostPosix(); |
| + |
| + virtual bool Init(); |
| + virtual void Send(P2PSocketAddress socket_address, |
| + const std::vector<char>& data); |
| + virtual void DestroyConnection(P2PSocketAddress socket_address); |
| + |
| + private: |
| + enum State { |
| + STATE_UNINITIALIZED, |
| + STATE_OPEN, |
| + STATE_ERROR, |
| + }; |
| + |
| + class ReadWatcher : public MessageLoopForIO::Watcher { |
|
jam
2011/03/02 00:41:09
comment please
Sergey Ulanov
2011/03/02 11:00:47
Done.
|
| + public: |
| + explicit ReadWatcher(P2PSocketHostPosix* socket) : socket_(socket) { } |
| + |
| + // MessageLoopForIO::Watcher methods |
| + virtual void OnFileCanReadWithoutBlocking(int /* fd */) { |
| + socket_->DidCompleteRead(); |
| + } |
| + virtual void OnFileCanWriteWithoutBlocking(int /* fd */) {} |
| + |
| + private: |
| + P2PSocketHostPosix* socket_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ReadWatcher); |
| + }; |
| + |
| + void DidCompleteRead(); |
| + void OnError(); |
| + |
| + State state_; |
| + int socket_; |
| + MessageLoopForIO::FileDescriptorWatcher read_socket_watcher_; |
| + ReadWatcher read_watcher_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(P2PSocketHostPosix); |
| +}; |
| + |
| +#endif // CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_POSIX_H_ |