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

Unified 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, 10 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 side-by-side diff with in-line comments
Download patch
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..14dbc87bf157ec9fd18bc82f6f4fd74265a00e3d
--- /dev/null
+++ b/content/browser/renderer_host/p2p_socket_host_posix.h
@@ -0,0 +1,58 @@
+// 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);
+ virtual ~P2PSocketHostPosix();
+
+ virtual bool Init();
+ virtual void Send(P2PSocketAddress socket_address,
+ const std::vector<char>& data);
+
+ private:
+ enum State {
+ STATE_UNINITIALIZED,
+ STATE_OPEN,
+ STATE_ERROR,
+ };
+
+ // MessageLoopForIO::Watcher implementation used to catch read
+ // events from the socket.
+ class ReadWatcher : public MessageLoopForIO::Watcher {
+ 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_
« 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