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

Side by Side 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, 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
« no previous file with comments | « chrome/renderer/p2p/socket_client.cc ('k') | chrome/renderer/p2p/socket_dispatcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // P2PSocketDispatcher is a per-renderer object that dispatchers all
6 // P2P messages received from the browser and relays all P2P messages
7 // sent to the browser. P2PSocketClient instances register themselves
8 // with the dispatcher using RegisterClient() and UnregisterClient().
9 //
10 // Relationship of classes.
11 //
12 // P2PSocketHost P2PSocketClient
13 // ^ ^
14 // | |
15 // v IPC v
16 // P2PSocketsHost <---------> P2PSocketDispatcher
17 //
18
19 #ifndef CHROME_RENDERER_P2P_SOCKET_DISPATCHER_H_
20 #define CHROME_RENDERER_P2P_SOCKET_DISPATCHER_H_
21
22 #include <vector>
23
24 #include "base/id_map.h"
25 #include "chrome/renderer/p2p/socket_client.h"
26 #include "content/common/p2p_sockets.h"
27 #include "chrome/renderer/render_view_observer.h"
28
29 namespace base {
30 class MessageLoopProxy;
31 } // namespace base
32
33 // P2PSocketDispatcher works on the renderer thread. It dispatches all
34 // messages on that thread, and all its methods must be called on the
35 // same thread.
36 class P2PSocketDispatcher : public RenderViewObserver {
37 public:
38 explicit P2PSocketDispatcher(RenderView* render_view);
39 virtual ~P2PSocketDispatcher();
40
41 P2PSocketClient* CreateSocket(P2PSocketType type, P2PSocketAddress address,
42 P2PSocketClient::Delegate* delegate);
43
44 // RenderViewObserver overrides.
45 virtual bool OnMessageReceived(const IPC::Message& message);
46
47 private:
48 friend class P2PSocketClient;
49
50 // Called by P2PSocketClient.
51 int RegisterClient(P2PSocketClient* client);
52 void UnregisterClient(int id);
53 void SendP2PMessage(IPC::Message* msg);
54 base::MessageLoopProxy* message_loop();
55
56 // Incoming message handlers.
57 void OnSocketCreated(int socket_id, P2PSocketAddress address);
58 void OnError(int socket_id);
59 void OnDataReceived(int socket_id, P2PSocketAddress address,
60 const std::vector<char>& data);
61
62 P2PSocketClient* GetClient(int socket_id);
63
64 scoped_refptr<base::MessageLoopProxy> message_loop_;
65 IDMap<P2PSocketClient> clients_;
66
67 DISALLOW_COPY_AND_ASSIGN(P2PSocketDispatcher);
68 };
69
70 #endif // CHROME_RENDERER_P2P_SOCKET_DISPATCHER_H_
OLDNEW
« 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