Fix some nits from the two previous plugin power saver CLs.
[chromium-blink-merge.git] / content / renderer / p2p / socket_client.h
blobd92407cd5c9bf1e6fa83564e8d642449d06c0028
1 // Copyright 2014 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.
5 #ifndef CONTENT_RENDERER_P2P_SOCKET_CLIENT_H_
6 #define CONTENT_RENDERER_P2P_SOCKET_CLIENT_H_
8 #include <vector>
10 #include "base/memory/ref_counted.h"
11 #include "content/common/p2p_socket_type.h"
12 #include "net/base/ip_endpoint.h"
14 namespace rtc {
15 struct PacketOptions;
18 namespace content {
20 class P2PSocketClientDelegate;
22 // P2P socket that routes all calls over IPC.
23 // Note that while ref-counting is thread-safe, all methods must be
24 // called on the same thread.
25 class P2PSocketClient : public base::RefCountedThreadSafe<P2PSocketClient> {
26 public:
27 // Create a new P2PSocketClient() of the specified |type| and connected to
28 // the specified |address|. |address| matters only when |type| is set to
29 // P2P_SOCKET_TCP_CLIENT. The methods on the returned socket may only be
30 // called on the same thread that created it.
31 static scoped_refptr<P2PSocketClient> Create(
32 P2PSocketType type,
33 const net::IPEndPoint& local_address,
34 const net::IPEndPoint& remote_address,
35 P2PSocketClientDelegate* delegate);
37 P2PSocketClient() {}
39 // Send the |data| to the |address|.
40 virtual void Send(const net::IPEndPoint& address,
41 const std::vector<char>& data) = 0;
43 // Send the |data| to the |address| using Differentiated Services Code Point
44 // |dscp|.
45 virtual void SendWithDscp(const net::IPEndPoint& address,
46 const std::vector<char>& data,
47 const rtc::PacketOptions& options) = 0;
49 virtual void SetOption(P2PSocketOption option, int value) = 0;
51 // Must be called before the socket is destroyed.
52 virtual void Close() = 0;
54 virtual int GetSocketID() const = 0;
55 virtual void SetDelegate(P2PSocketClientDelegate* delegate) = 0;
57 protected:
58 virtual ~P2PSocketClient() {}
60 private:
61 // Calls destructor.
62 friend class base::RefCountedThreadSafe<P2PSocketClient>;
64 } // namespace content
66 #endif // CONTENT_RENDERER_P2P_SOCKET_CLIENT_H_