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

Unified Diff: chrome/renderer/p2p/sockets_dispatcher.h

Issue 6602039: P2P sockets IPC dispatcher for the renderer side. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
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: chrome/renderer/p2p/sockets_dispatcher.h
diff --git a/chrome/renderer/p2p/sockets_dispatcher.h b/chrome/renderer/p2p/sockets_dispatcher.h
new file mode 100644
index 0000000000000000000000000000000000000000..8ccfc3a1c274bd4fad2e85741e90797bccba7ccb
--- /dev/null
+++ b/chrome/renderer/p2p/sockets_dispatcher.h
@@ -0,0 +1,54 @@
+// 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 CHROME_RENDERER_P2P_SOCKETS_DISPATCHER_H_
+#define CHROME_RENDERER_P2P_SOCKETS_DISPATCHER_H_
+
awong 2011/03/01 20:21:55 We need a comment showing how these classes intera
Sergey Ulanov 2011/03/02 16:12:29 Done.
+#include <vector>
+
+#include "base/id_map.h"
+#include "chrome/common/p2p_sockets.h"
+#include "chrome/renderer/p2p/socket_client.h"
+#include "ipc/ipc_channel_proxy.h"
+
+class P2PSocketsDispatcher : public IPC::ChannelProxy::MessageFilter {
awong 2011/03/01 20:21:55 Aren't these usually named XXXXFilter? So P2pSock
Alpha Left Google 2011/03/01 21:32:20 Looks like this lives on the IO thread, please com
Sergey Ulanov 2011/03/02 16:12:29 Done.
Sergey Ulanov 2011/03/02 16:12:29 There are many that are named Dispatcher. I think
+ public:
+ explicit P2PSocketsDispatcher(int32 routing_id);
+ virtual ~P2PSocketsDispatcher();
+
+ P2PSocketClient* CreateSocket(P2PSocketType type, P2PSocketAddress address,
+ P2PSocketClient::Delegate* delegate);
+
+ // IPC::ChannelProxy::MessageFilter implementation.
+ virtual bool OnMessageReceived(const IPC::Message& message);
+ virtual void OnFilterAdded(IPC::Channel* channel);
+ virtual void OnFilterRemoved();
+ virtual void OnChannelClosing();
+
+ private:
+ friend class P2PSocketClient;
+
+ // Called by P2PSocketClient.
+ int RegisterClient(P2PSocketClient* client);
+ void UnregisterClient(int id);
+ void Send(IPC::Message* msg);
+ MessageLoop* message_loop();
+
+ // Incoming message handlers.
+ void OnSocketCreated(int socket_id, P2PSocketAddress address);
+ void OnError(int socket_id);
+ void OnDataReceived(int socket_id, P2PSocketAddress address,
+ const std::vector<char>& data);
+
+ P2PSocketClient* GetClient(int socket_id);
+
+ IPC::Channel* channel_;
+ int32 routing_id_;
+ MessageLoop* message_loop_;
+ IDMap<P2PSocketClient> clients_;
+
+ DISALLOW_COPY_AND_ASSIGN(P2PSocketsDispatcher);
+};
+
+#endif // CHROME_RENDERER_P2P_SOCKETS_DISPATCHER_H_

Powered by Google App Engine
This is Rietveld 408576698