Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 CONTENT_PUBLIC_RENDERER_P2P_SOCKET_CLIENT_H_ | |
| 6 #define CONTENT_PUBLIC_RENDERER_P2P_SOCKET_CLIENT_H_ | |
| 7 | |
| 8 #include <vector> | |
| 9 | |
| 10 #include "base/memory/ref_counted.h" | |
| 11 #include "content/public/common/p2p_socket_type.h" | |
| 12 #include "net/base/ip_endpoint.h" | |
| 13 | |
| 14 namespace content { | |
| 15 | |
| 16 class P2PSocketClientDelegate; | |
| 17 | |
| 18 // P2P socket that routes all calls over IPC. | |
| 19 // Note that while ref-counting is thread-safe, all methods must be | |
| 20 // called on the same thread. | |
| 21 class P2PSocketClient : public base::RefCountedThreadSafe<P2PSocketClient> { | |
| 22 public: | |
| 23 P2PSocketClient() {} | |
| 24 | |
| 25 // Initialize socket of the specified |type| and connected to the | |
| 26 // specified |address|. |address| matters only when |type| is set to | |
| 27 // P2P_SOCKET_TCP_CLIENT. | |
| 28 virtual void Init(P2PSocketType type, | |
| 29 const net::IPEndPoint& local_address, | |
| 30 const net::IPEndPoint& remote_address, | |
| 31 P2PSocketClientDelegate* delegate) = 0; | |
| 32 | |
| 33 // Send the |data| to the |address|. | |
| 34 virtual void Send(const net::IPEndPoint& address, | |
| 35 const std::vector<char>& data) = 0; | |
| 36 | |
| 37 // Send the |data| to the |address| using Differentiated Services Code Point | |
| 38 // |dscp|. | |
| 39 virtual void SendWithDscp(const net::IPEndPoint& address, | |
| 40 const std::vector<char>& data, | |
| 41 net::DiffServCodePoint dscp) = 0; | |
| 42 | |
| 43 // Must be called before the socket is destroyed. | |
| 44 virtual void Close() = 0; | |
| 45 | |
| 46 virtual int GetSocketID() const = 0; | |
| 47 virtual void SetDelegate(P2PSocketClientDelegate* delegate) = 0; | |
| 48 | |
| 49 protected: | |
| 50 virtual ~P2PSocketClient() {} | |
| 51 | |
| 52 private: | |
| 53 // Calls destructor. | |
| 54 friend class base::RefCountedThreadSafe<P2PSocketClient>; | |
| 55 }; | |
| 56 | |
| 57 // Create a new P2PSocketClient(). Please note that you must called | |
|
jam
2013/11/23 02:03:14
nit: "must call"
hubbe
2013/11/25 19:15:07
Done.
| |
| 58 // Init() before using the socket. Also, the methods on the returned | |
|
jam
2013/11/23 02:03:14
i'm curious why not combine the initialization and
hubbe
2013/11/25 19:15:07
Done.
| |
| 59 // socket may only be called on the same thread that created it. | |
| 60 P2PSocketClient* CreateP2PSocket(); | |
|
jam
2013/11/23 02:03:14
nit: the convention in content/public is to put th
hubbe
2013/11/25 19:15:07
Done.
| |
| 61 | |
| 62 } // namespace content | |
| 63 | |
| 64 #endif // CONTENT_PUBLIC_RENDERER_P2P_SOCKET_CLIENT_H_ | |
| OLD | NEW |