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

Side by Side Diff: content/renderer/p2p/socket_client_impl.h

Issue 759923003: Detect situation when there is no missing send completion signal in P2PSocket implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_RENDERER_P2P_SOCKET_CLIENT_IMPL_H_ 5 #ifndef CONTENT_RENDERER_P2P_SOCKET_CLIENT_IMPL_H_
6 #define CONTENT_RENDERER_P2P_SOCKET_CLIENT_IMPL_H_ 6 #define CONTENT_RENDERER_P2P_SOCKET_CLIENT_IMPL_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 21 matching lines...) Expand all
32 explicit P2PSocketClientImpl(P2PSocketDispatcher* dispatcher); 32 explicit P2PSocketClientImpl(P2PSocketDispatcher* dispatcher);
33 33
34 // Initialize socket of the specified |type| and connected to the 34 // Initialize socket of the specified |type| and connected to the
35 // specified |address|. |address| matters only when |type| is set to 35 // specified |address|. |address| matters only when |type| is set to
36 // P2P_SOCKET_TCP_CLIENT. 36 // P2P_SOCKET_TCP_CLIENT.
37 virtual void Init(P2PSocketType type, 37 virtual void Init(P2PSocketType type,
38 const net::IPEndPoint& local_address, 38 const net::IPEndPoint& local_address,
39 const P2PHostAndIPEndPoint& remote_address, 39 const P2PHostAndIPEndPoint& remote_address,
40 P2PSocketClientDelegate* delegate); 40 P2PSocketClientDelegate* delegate);
41 41
42 // Send the |data| to the |address|.
43 void Send(const net::IPEndPoint& address,
44 const std::vector<char>& data) override;
45
46 // Send the |data| to the |address| using Differentiated Services Code Point 42 // Send the |data| to the |address| using Differentiated Services Code Point
47 // |dscp|. 43 // |dscp|. Return value is the unique packet_id for this packet.
48 void SendWithDscp(const net::IPEndPoint& address, 44 uint64_t Send(const net::IPEndPoint& address,
49 const std::vector<char>& data, 45 const std::vector<char>& data,
50 const rtc::PacketOptions& options) override; 46 const rtc::PacketOptions& options) override;
51 47
52 // Setting socket options. 48 // Setting socket options.
53 void SetOption(P2PSocketOption option, int value) override; 49 void SetOption(P2PSocketOption option, int value) override;
54 50
55 // Must be called before the socket is destroyed. The delegate may 51 // Must be called before the socket is destroyed. The delegate may
56 // not be called after |closed_task| is executed. 52 // not be called after |closed_task| is executed.
57 void Close() override; 53 void Close() override;
58 54
59 int GetSocketID() const override; 55 int GetSocketID() const override;
60 56
61 void SetDelegate(P2PSocketClientDelegate* delegate) override; 57 void SetDelegate(P2PSocketClientDelegate* delegate) override;
62 58
63 private: 59 private:
64 enum State { 60 enum State {
65 STATE_UNINITIALIZED, 61 STATE_UNINITIALIZED,
66 STATE_OPENING, 62 STATE_OPENING,
67 STATE_OPEN, 63 STATE_OPEN,
68 STATE_CLOSED, 64 STATE_CLOSED,
69 STATE_ERROR, 65 STATE_ERROR,
70 }; 66 };
71 67
72 friend class P2PSocketDispatcher; 68 friend class P2PSocketDispatcher;
73 69
74 ~P2PSocketClientImpl() override; 70 ~P2PSocketClientImpl() override;
75 71
76 // Message handlers that run on IPC thread. 72 // Message handlers that run on IPC thread.
77 void OnSocketCreated(const net::IPEndPoint& local_address, 73 void OnSocketCreated(const net::IPEndPoint& local_address,
78 const net::IPEndPoint& remote_address); 74 const net::IPEndPoint& remote_address);
79 void OnIncomingTcpConnection(const net::IPEndPoint& address); 75 void OnIncomingTcpConnection(const net::IPEndPoint& address);
80 void OnSendComplete(int packet_id); 76 void OnSendComplete(const P2PSendPacketMetrics& send_metrics);
81 void OnSendComplete();
82 void OnError(); 77 void OnError();
83 void OnDataReceived(const net::IPEndPoint& address, 78 void OnDataReceived(const net::IPEndPoint& address,
84 const std::vector<char>& data, 79 const std::vector<char>& data,
85 const base::TimeTicks& timestamp); 80 const base::TimeTicks& timestamp);
86 81
87 // Proxy methods that deliver messages to the delegate thread. 82 // Proxy methods that deliver messages to the delegate thread.
88 void DeliverOnSocketCreated(const net::IPEndPoint& local_address, 83 void DeliverOnSocketCreated(const net::IPEndPoint& local_address,
89 const net::IPEndPoint& remote_address); 84 const net::IPEndPoint& remote_address);
90 void DeliverOnIncomingTcpConnection( 85 void DeliverOnIncomingTcpConnection(
91 const net::IPEndPoint& address, 86 const net::IPEndPoint& address,
92 scoped_refptr<P2PSocketClient> new_client); 87 scoped_refptr<P2PSocketClient> new_client);
93 void DeliverOnSendComplete(); 88 void DeliverOnSendComplete(const P2PSendPacketMetrics& send_metrics);
94 void DeliverOnError(); 89 void DeliverOnError();
95 void DeliverOnDataReceived(const net::IPEndPoint& address, 90 void DeliverOnDataReceived(const net::IPEndPoint& address,
96 const std::vector<char>& data, 91 const std::vector<char>& data,
97 const base::TimeTicks& timestamp); 92 const base::TimeTicks& timestamp);
98 93
94 // Helper function to be called by Send to handle different threading
95 // condition.
96 void SendWithPacketId(const net::IPEndPoint& address,
97 const std::vector<char>& data,
98 const rtc::PacketOptions& options,
99 uint64_t packet_id);
100
99 // Scheduled on the IPC thread to finish initialization. 101 // Scheduled on the IPC thread to finish initialization.
100 void DoInit(P2PSocketType type, 102 void DoInit(P2PSocketType type,
101 const net::IPEndPoint& local_address, 103 const net::IPEndPoint& local_address,
102 const P2PHostAndIPEndPoint& remote_address); 104 const P2PHostAndIPEndPoint& remote_address);
103 105
104 // Scheduled on the IPC thread to finish closing the connection. 106 // Scheduled on the IPC thread to finish closing the connection.
105 void DoClose(); 107 void DoClose();
106 108
107 // Called by the dispatcher when it is destroyed. 109 // Called by the dispatcher when it is destroyed.
108 void Detach(); 110 void Detach();
109 111
110 P2PSocketDispatcher* dispatcher_; 112 P2PSocketDispatcher* dispatcher_;
111 scoped_refptr<base::MessageLoopProxy> ipc_message_loop_; 113 scoped_refptr<base::MessageLoopProxy> ipc_message_loop_;
112 scoped_refptr<base::MessageLoopProxy> delegate_message_loop_; 114 scoped_refptr<base::MessageLoopProxy> delegate_message_loop_;
113 int socket_id_; 115 int socket_id_;
114 P2PSocketClientDelegate* delegate_; 116 P2PSocketClientDelegate* delegate_;
115 State state_; 117 State state_;
116 118
117 // These two fields are used to identify packets for tracing. 119 // These two fields are used to identify packets for tracing.
118 uint32 random_socket_id_; 120 uint32 random_socket_id_;
119 uint32 next_packet_id_; 121 uint32 next_packet_id_;
120 122
121 DISALLOW_COPY_AND_ASSIGN(P2PSocketClientImpl); 123 DISALLOW_COPY_AND_ASSIGN(P2PSocketClientImpl);
122 }; 124 };
123 125
124 } // namespace content 126 } // namespace content
125 127
126 #endif // CONTENT_RENDERER_P2P_SOCKET_CLIENT_IMPL_H_ 128 #endif // CONTENT_RENDERER_P2P_SOCKET_CLIENT_IMPL_H_
OLDNEW
« no previous file with comments | « content/renderer/p2p/socket_client_delegate.h ('k') | content/renderer/p2p/socket_client_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698