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

Side by Side Diff: chrome/renderer/p2p/socket_client.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
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 CHROME_RENDERER_P2P_SOCKET_CLIENT_H_
6 #define CHROME_RENDERER_P2P_SOCKET_CLIENT_H_
7
8 #include <vector>
9
10 #include "base/ref_counted.h"
11 #include "chrome/common/p2p_sockets.h"
12
13 class P2PSocketsDispatcher;
14 class Task;
15
16 // P2P socket that rountes all calls over . Can be created
awong 2011/03/01 20:21:55 Comment is unfinished.
Sergey Ulanov 2011/03/02 16:12:29 Done.
17 // and used from
18 class P2PSocketClient : public base::RefCountedThreadSafe<P2PSocketClient> {
Alpha Left Google 2011/03/01 21:32:20 Why is this refcounted? Should this be only used o
Sergey Ulanov 2011/03/02 16:12:29 It can be used from any thread. It will be used in
19 public:
20 class Delegate {
21 public:
22 virtual ~Delegate();
23
24 virtual void OnOpen(P2PSocketAddress address) = 0;
25 virtual void OnError() = 0;
26 virtual void OnDataReceived(P2PSocketAddress address,
27 const std::vector<char>& data) = 0;
28 };
29
30 explicit P2PSocketClient(P2PSocketsDispatcher* dispatcher);
31 ~P2PSocketClient();
awong 2011/03/01 20:21:55 Should the destructor be private or protected?
Sergey Ulanov 2011/03/02 16:12:29 Done.
32
33 // Initialize socket of the specified |type| and connected to the
34 // specified |address|. |address| matters only when |type| is set to
35 // P2P_SOCKET_TCP_CLIENT.
36 void Init(P2PSocketType type, P2PSocketAddress address, Delegate* delegate);
37
38 // Send the |data| to the |address|.
39 void Send(P2PSocketAddress address, const std::vector<char>& data);
40
41 // Must be called before the socket is destroyed. The delegate may
42 // not be called after |closed_task| is executed.
43 void Close(Task* closed_task);
44
45 int id() const { return id_; }
awong 2011/03/01 20:21:55 What is this id? Add comment?
Sergey Ulanov 2011/03/02 16:12:29 it is id of the socket. Renamed it to socket_id().
46
47 private:
48 enum State {
49 STATE_UNINITIALIZED,
Alpha Left Google 2011/03/01 21:32:20 nit: use kStateXXX.
Sergey Ulanov 2011/03/02 16:12:29 http://www.chromium.org/developers/coding-style sa
50 STATE_OPENING,
51 STATE_OPEN,
52 STATE_CLOSED,
53 STATE_ERROR,
54 };
55
56 friend class P2PSocketsDispatcher;
57
58 void OnSocketCreated(P2PSocketAddress address);
59 void OnError();
60 void OnDataReceived(P2PSocketAddress address,
61 const std::vector<char>& data);
62
63 P2PSocketsDispatcher* dispatcher_;
64 int id_;
65 Delegate* delegate_;
66 State state_;
67
68 DISALLOW_COPY_AND_ASSIGN(P2PSocketClient);
69 };
70
71 #endif // CHROME_RENDERER_P2P_SOCKET_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698