Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
|
Alpha Left Google
2013/10/25 21:28:48
This is still called socket_client.h though, shoul
jam
2013/11/20 23:26:24
+1
hubbe
2013/11/21 22:07:30
Done.
| |
| 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 CONTENT_PUBLIC_RENDERER_SOCKET_CLIENT_H_ | |
| 6 #define CONTENT_PUBLIC_RENDERER_SOCKET_CLIENT_H_ | |
| 7 | |
| 8 #include <vector> | |
| 9 | |
| 10 #include "base/memory/ref_counted.h" | |
| 11 #include "content/public/common/p2p_sockets.h" | |
| 12 #include "net/base/ip_endpoint.h" | |
| 13 | |
| 14 namespace content { | |
| 15 | |
| 16 // P2P socket that routes all calls over IPC. | |
| 17 // | |
| 18 // The object runs on two threads: IPC thread and delegate thread. The | |
| 19 // IPC thread is used to interact with P2PSocketDispatcher. All | |
| 20 // callbacks to the user of this class are called on the delegate | |
| 21 // thread which is specified in Init(). | |
|
jam
2013/11/20 23:26:24
you're describing the implementation details. do w
hubbe
2013/11/21 22:07:30
Fixed.
hubbe
2013/11/21 22:07:30
Fixed.
jam
2013/11/23 02:03:14
What I mean is that this is an interface. The impl
hubbe
2013/11/25 19:15:07
I think so, because we expect the callers to use s
jam
2013/11/27 21:30:18
what is the ownership here? i.e. can the embedder
hubbe
2013/11/27 23:23:01
That's not the intent, the intent is for the user
jam
2013/11/28 00:08:57
ok, so you're saying that the ownership of this cl
| |
| 22 class P2PSocketClient : public base::RefCountedThreadSafe<P2PSocketClient> { | |
| 23 public: | |
| 24 P2PSocketClient() {} | |
| 25 | |
| 26 // Delegate is called on the the same thread on which P2PSocketCLient is | |
| 27 // created. | |
| 28 class Delegate { | |
|
jam
2013/11/20 23:26:24
see http://www.chromium.org/developers/content-mod
hubbe
2013/11/21 22:07:30
Done.
| |
| 29 public: | |
| 30 virtual ~Delegate() { } | |
| 31 | |
| 32 virtual void OnOpen(const net::IPEndPoint& address) = 0; | |
|
jam
2013/11/20 23:26:24
nit: document every method
hubbe
2013/11/21 22:07:30
Done.
| |
| 33 virtual void OnIncomingTcpConnection(const net::IPEndPoint& address, | |
| 34 P2PSocketClient* client) = 0; | |
| 35 virtual void OnSendComplete() = 0; | |
| 36 virtual void OnError() = 0; | |
| 37 virtual void OnDataReceived(const net::IPEndPoint& address, | |
| 38 const std::vector<char>& data) = 0; | |
| 39 }; | |
| 40 | |
| 41 // Initialize socket of the specified |type| and connected to the | |
| 42 // specified |address|. |address| matters only when |type| is set to | |
| 43 // P2P_SOCKET_TCP_CLIENT. | |
| 44 virtual void Init(P2PSocketType type, | |
| 45 const net::IPEndPoint& local_address, | |
| 46 const net::IPEndPoint& remote_address, | |
| 47 Delegate* delegate) = 0; | |
| 48 | |
| 49 // Send the |data| to the |address|. | |
| 50 virtual void Send(const net::IPEndPoint& address, | |
| 51 const std::vector<char>& data) = 0; | |
| 52 | |
| 53 // Send the |data| to the |address| using Differentiated Services Code Point | |
| 54 // |dscp|. | |
| 55 virtual void SendWithDscp(const net::IPEndPoint& address, | |
| 56 const std::vector<char>& data, | |
| 57 net::DiffServCodePoint dscp) = 0; | |
| 58 | |
| 59 // Must be called before the socket is destroyed. | |
| 60 virtual void Close() = 0; | |
| 61 | |
| 62 virtual int socket_id() const = 0; | |
| 63 virtual void set_delegate(Delegate* delegate) = 0; | |
|
jam
2013/11/20 23:26:24
nit: these two methods don't conform to google sty
hubbe
2013/11/21 22:07:30
Done.
| |
| 64 | |
| 65 protected: | |
| 66 virtual ~P2PSocketClient() {} | |
| 67 | |
| 68 private: | |
| 69 // Calls destructor. | |
| 70 friend class base::RefCountedThreadSafe<P2PSocketClient>; | |
| 71 | |
| 72 DISALLOW_COPY_AND_ASSIGN(P2PSocketClient); | |
|
jam
2013/11/20 23:26:24
nit: don't need this since pure virtual interfaces
hubbe
2013/11/21 22:07:30
Done.
| |
| 73 }; | |
| 74 | |
| 75 } // namespace content | |
| 76 | |
| 77 #endif // CONTENT_PUBLIC_RENDERER_SOCKET_CLIENT_H_ | |
| OLD | NEW |