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

Side by Side Diff: remoting/protocol/fake_stream_socket.h

Issue 2757723002: Update ICE protocol to handle closed channel (Closed)
Patch Set: . Created 3 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
« no previous file with comments | « remoting/protocol/fake_session.cc ('k') | remoting/protocol/fake_stream_socket.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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 REMOTING_PROTOCOL_FAKE_STREAM_SOCKET_H_ 5 #ifndef REMOTING_PROTOCOL_FAKE_STREAM_SOCKET_H_
6 #define REMOTING_PROTOCOL_FAKE_STREAM_SOCKET_H_ 6 #define REMOTING_PROTOCOL_FAKE_STREAM_SOCKET_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/optional.h"
14 #include "net/base/completion_callback.h" 15 #include "net/base/completion_callback.h"
15 #include "remoting/protocol/p2p_stream_socket.h" 16 #include "remoting/protocol/p2p_stream_socket.h"
16 #include "remoting/protocol/stream_channel_factory.h" 17 #include "remoting/protocol/stream_channel_factory.h"
17 18
18 namespace base { 19 namespace base {
19 class SingleThreadTaskRunner; 20 class SingleThreadTaskRunner;
20 } 21 }
21 22
22 namespace remoting { 23 namespace remoting {
23 namespace protocol { 24 namespace protocol {
(...skipping 24 matching lines...) Expand all
48 49
49 // Set error codes for the next Write() call. Once returned the 50 // Set error codes for the next Write() call. Once returned the
50 // value is automatically reset to net::OK . 51 // value is automatically reset to net::OK .
51 void set_next_write_error(int error) { next_write_error_ = error; } 52 void set_next_write_error(int error) { next_write_error_ = error; }
52 53
53 // Appends |data| to the read buffer. 54 // Appends |data| to the read buffer.
54 void AppendInputData(const std::string& data); 55 void AppendInputData(const std::string& data);
55 56
56 // Causes Read() to fail with |error| once the read buffer is exhausted. If 57 // Causes Read() to fail with |error| once the read buffer is exhausted. If
57 // there is a currently pending Read, it is interrupted. 58 // there is a currently pending Read, it is interrupted.
58 void AppendReadError(int error); 59 void SetReadError(int error);
59 60
60 // Pairs the socket with |peer_socket|. Deleting either of the paired sockets 61 // Pairs the socket with |peer_socket|. Deleting either of the paired sockets
61 // unpairs them. 62 // unpairs them.
62 void PairWith(FakeStreamSocket* peer_socket); 63 void PairWith(FakeStreamSocket* peer_socket);
63 64
64 // Current input position in bytes. 65 // Current input position in bytes.
65 int input_pos() const { return input_pos_; } 66 int input_pos() const { return input_pos_; }
66 67
67 // True if a Read() call is currently pending. 68 // True if a Read() call is currently pending.
68 bool read_pending() const { return !read_callback_.is_null(); } 69 bool read_pending() const { return !read_callback_.is_null(); }
69 70
70 base::WeakPtr<FakeStreamSocket> GetWeakPtr(); 71 base::WeakPtr<FakeStreamSocket> GetWeakPtr();
71 72
72 // P2PStreamSocket interface. 73 // P2PStreamSocket interface.
73 int Read(const scoped_refptr<net::IOBuffer>& buf, int buf_len, 74 int Read(const scoped_refptr<net::IOBuffer>& buf, int buf_len,
74 const net::CompletionCallback& callback) override; 75 const net::CompletionCallback& callback) override;
75 int Write(const scoped_refptr<net::IOBuffer>& buf, int buf_len, 76 int Write(const scoped_refptr<net::IOBuffer>& buf, int buf_len,
76 const net::CompletionCallback& callback) override; 77 const net::CompletionCallback& callback) override;
77 78
78 private: 79 private:
79 void DoAsyncWrite(const scoped_refptr<net::IOBuffer>& buf, int buf_len, 80 void DoAsyncWrite(const scoped_refptr<net::IOBuffer>& buf, int buf_len,
80 const net::CompletionCallback& callback); 81 const net::CompletionCallback& callback);
81 void DoWrite(const scoped_refptr<net::IOBuffer>& buf, int buf_len); 82 void DoWrite(const scoped_refptr<net::IOBuffer>& buf, int buf_len);
82 83
83 bool async_write_ = false; 84 bool async_write_ = false;
84 bool write_pending_ = false; 85 bool write_pending_ = false;
85 int write_limit_ = 0; 86 int write_limit_ = 0;
86 int next_write_error_ = 0; 87 int next_write_error_ = 0;
87 88
88 int next_read_error_ = 0; 89 base::Optional<int> next_read_error_;
89 scoped_refptr<net::IOBuffer> read_buffer_; 90 scoped_refptr<net::IOBuffer> read_buffer_;
90 int read_buffer_size_ = 0; 91 int read_buffer_size_ = 0;
91 net::CompletionCallback read_callback_; 92 net::CompletionCallback read_callback_;
92 base::WeakPtr<FakeStreamSocket> peer_socket_; 93 base::WeakPtr<FakeStreamSocket> peer_socket_;
93 94
94 std::string written_data_; 95 std::string written_data_;
95 std::string input_data_; 96 std::string input_data_;
96 int input_pos_ = 0; 97 int input_pos_ = 0;
97 98
98 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 99 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 base::WeakPtr<FakeStreamChannelFactory> peer_factory_; 144 base::WeakPtr<FakeStreamChannelFactory> peer_factory_;
144 base::WeakPtrFactory<FakeStreamChannelFactory> weak_factory_; 145 base::WeakPtrFactory<FakeStreamChannelFactory> weak_factory_;
145 146
146 DISALLOW_COPY_AND_ASSIGN(FakeStreamChannelFactory); 147 DISALLOW_COPY_AND_ASSIGN(FakeStreamChannelFactory);
147 }; 148 };
148 149
149 } // namespace protocol 150 } // namespace protocol
150 } // namespace remoting 151 } // namespace remoting
151 152
152 #endif // REMOTING_PROTOCOL_FAKE_STREAM_SOCKET_H_ 153 #endif // REMOTING_PROTOCOL_FAKE_STREAM_SOCKET_H_
OLDNEW
« no previous file with comments | « remoting/protocol/fake_session.cc ('k') | remoting/protocol/fake_stream_socket.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698