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

Unified Diff: chrome/renderer/p2p/socket_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
« no previous file with comments | « chrome/renderer/p2p/socket_client.cc ('k') | chrome/renderer/p2p/socket_dispatcher.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/p2p/socket_dispatcher.h
diff --git a/chrome/renderer/p2p/socket_dispatcher.h b/chrome/renderer/p2p/socket_dispatcher.h
new file mode 100644
index 0000000000000000000000000000000000000000..d837334d975519ac2d2bfbbf279aa7ca9a3be531
--- /dev/null
+++ b/chrome/renderer/p2p/socket_dispatcher.h
@@ -0,0 +1,70 @@
+// 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.
+
+// P2PSocketDispatcher is a per-renderer object that dispatchers all
+// P2P messages received from the browser and relays all P2P messages
+// sent to the browser. P2PSocketClient instances register themselves
+// with the dispatcher using RegisterClient() and UnregisterClient().
+//
+// Relationship of classes.
+//
+// P2PSocketHost P2PSocketClient
+// ^ ^
+// | |
+// v IPC v
+// P2PSocketsHost <---------> P2PSocketDispatcher
+//
+
+#ifndef CHROME_RENDERER_P2P_SOCKET_DISPATCHER_H_
+#define CHROME_RENDERER_P2P_SOCKET_DISPATCHER_H_
+
+#include <vector>
+
+#include "base/id_map.h"
+#include "chrome/renderer/p2p/socket_client.h"
+#include "content/common/p2p_sockets.h"
+#include "chrome/renderer/render_view_observer.h"
+
+namespace base {
+class MessageLoopProxy;
+} // namespace base
+
+// P2PSocketDispatcher works on the renderer thread. It dispatches all
+// messages on that thread, and all its methods must be called on the
+// same thread.
+class P2PSocketDispatcher : public RenderViewObserver {
+ public:
+ explicit P2PSocketDispatcher(RenderView* render_view);
+ virtual ~P2PSocketDispatcher();
+
+ P2PSocketClient* CreateSocket(P2PSocketType type, P2PSocketAddress address,
+ P2PSocketClient::Delegate* delegate);
+
+ // RenderViewObserver overrides.
+ virtual bool OnMessageReceived(const IPC::Message& message);
+
+ private:
+ friend class P2PSocketClient;
+
+ // Called by P2PSocketClient.
+ int RegisterClient(P2PSocketClient* client);
+ void UnregisterClient(int id);
+ void SendP2PMessage(IPC::Message* msg);
+ base::MessageLoopProxy* 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);
+
+ scoped_refptr<base::MessageLoopProxy> message_loop_;
+ IDMap<P2PSocketClient> clients_;
+
+ DISALLOW_COPY_AND_ASSIGN(P2PSocketDispatcher);
+};
+
+#endif // CHROME_RENDERER_P2P_SOCKET_DISPATCHER_H_
« no previous file with comments | « chrome/renderer/p2p/socket_client.cc ('k') | chrome/renderer/p2p/socket_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698