Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2011 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 CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_POSIX_H_ | |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_POSIX_H_ | |
| 7 | |
| 8 #include "content/common/p2p_sockets.h" | |
| 9 | |
| 10 #include "base/message_loop.h" | |
| 11 #include "content/browser/renderer_host/p2p_socket_host.h" | |
| 12 | |
| 13 class P2PSocketHostPosix : public P2PSocketHost { | |
| 14 public: | |
| 15 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
| |
| 16 ~P2PSocketHostPosix(); | |
| 17 | |
| 18 virtual bool Init(); | |
| 19 virtual void Send(P2PSocketAddress socket_address, | |
| 20 const std::vector<char>& data); | |
| 21 virtual void DestroyConnection(P2PSocketAddress socket_address); | |
| 22 | |
| 23 private: | |
| 24 enum State { | |
| 25 STATE_UNINITIALIZED, | |
| 26 STATE_OPEN, | |
| 27 STATE_ERROR, | |
| 28 }; | |
| 29 | |
| 30 class ReadWatcher : public MessageLoopForIO::Watcher { | |
|
jam
2011/03/02 00:41:09
comment please
Sergey Ulanov
2011/03/02 11:00:47
Done.
| |
| 31 public: | |
| 32 explicit ReadWatcher(P2PSocketHostPosix* socket) : socket_(socket) { } | |
| 33 | |
| 34 // MessageLoopForIO::Watcher methods | |
| 35 virtual void OnFileCanReadWithoutBlocking(int /* fd */) { | |
| 36 socket_->DidCompleteRead(); | |
| 37 } | |
| 38 virtual void OnFileCanWriteWithoutBlocking(int /* fd */) {} | |
| 39 | |
| 40 private: | |
| 41 P2PSocketHostPosix* socket_; | |
| 42 | |
| 43 DISALLOW_COPY_AND_ASSIGN(ReadWatcher); | |
| 44 }; | |
| 45 | |
| 46 void DidCompleteRead(); | |
| 47 void OnError(); | |
| 48 | |
| 49 State state_; | |
| 50 int socket_; | |
| 51 MessageLoopForIO::FileDescriptorWatcher read_socket_watcher_; | |
| 52 ReadWatcher read_watcher_; | |
| 53 | |
| 54 DISALLOW_COPY_AND_ASSIGN(P2PSocketHostPosix); | |
| 55 }; | |
| 56 | |
| 57 #endif // CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_POSIX_H_ | |
| OLD | NEW |