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

Side by Side Diff: content/browser/renderer_host/p2p_socket_host_posix.h

Issue 6598053: P2P Sockets host implementation. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: - Created 9 years, 9 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
OLDNEW
(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);
16 virtual ~P2PSocketHostPosix();
17
18 virtual bool Init();
19 virtual void Send(P2PSocketAddress socket_address,
20 const std::vector<char>& data);
21
22 private:
23 enum State {
24 STATE_UNINITIALIZED,
25 STATE_OPEN,
26 STATE_ERROR,
27 };
28
29 // MessageLoopForIO::Watcher implementation used to catch read
30 // events from the socket.
31 class ReadWatcher : public MessageLoopForIO::Watcher {
32 public:
33 explicit ReadWatcher(P2PSocketHostPosix* socket) : socket_(socket) { }
34
35 // MessageLoopForIO::Watcher methods
36 virtual void OnFileCanReadWithoutBlocking(int /* fd */) {
37 socket_->DidCompleteRead();
38 }
39 virtual void OnFileCanWriteWithoutBlocking(int /* fd */) {}
40
41 private:
42 P2PSocketHostPosix* socket_;
43
44 DISALLOW_COPY_AND_ASSIGN(ReadWatcher);
45 };
46
47 void DidCompleteRead();
48 void OnError();
49
50 State state_;
51 int socket_;
52 MessageLoopForIO::FileDescriptorWatcher read_socket_watcher_;
53 ReadWatcher read_watcher_;
54
55 DISALLOW_COPY_AND_ASSIGN(P2PSocketHostPosix);
56 };
57
58 #endif // CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_POSIX_H_
OLDNEW
« no previous file with comments | « content/browser/renderer_host/p2p_socket_host.cc ('k') | content/browser/renderer_host/p2p_socket_host_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698