OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "jingle/glue/channel_socket_adapter.h" | 5 #include "jingle/glue/channel_socket_adapter.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 // Channel is not writable yet. | 92 // Channel is not writable yet. |
93 result = net::ERR_IO_PENDING; | 93 result = net::ERR_IO_PENDING; |
94 write_callback_ = callback; | 94 write_callback_ = callback; |
95 write_buffer_ = buffer; | 95 write_buffer_ = buffer; |
96 write_buffer_size_ = buffer_size; | 96 write_buffer_size_ = buffer_size; |
97 } | 97 } |
98 | 98 |
99 return result; | 99 return result; |
100 } | 100 } |
101 | 101 |
102 bool TransportChannelSocketAdapter::SetReceiveBufferSize(int32 size) { | 102 int TransportChannelSocketAdapter::SetReceiveBufferSize(int32 size) { |
103 DCHECK_EQ(base::MessageLoop::current(), message_loop_); | 103 DCHECK_EQ(base::MessageLoop::current(), message_loop_); |
104 return channel_->SetOption(talk_base::Socket::OPT_RCVBUF, size) == 0; | 104 return (channel_->SetOption(talk_base::Socket::OPT_RCVBUF, size) == 0) ? |
| 105 net::OK : net::ERR_SOCKET_SET_RECEIVE_BUFFER_SIZE_ERROR; |
105 } | 106 } |
106 | 107 |
107 bool TransportChannelSocketAdapter::SetSendBufferSize(int32 size) { | 108 int TransportChannelSocketAdapter::SetSendBufferSize(int32 size) { |
108 DCHECK_EQ(base::MessageLoop::current(), message_loop_); | 109 DCHECK_EQ(base::MessageLoop::current(), message_loop_); |
109 return channel_->SetOption(talk_base::Socket::OPT_SNDBUF, size) == 0; | 110 return (channel_->SetOption(talk_base::Socket::OPT_SNDBUF, size) == 0) ? |
| 111 net::OK : net::ERR_SOCKET_SET_SEND_BUFFER_SIZE_ERROR; |
110 } | 112 } |
111 | 113 |
112 void TransportChannelSocketAdapter::Close(int error_code) { | 114 void TransportChannelSocketAdapter::Close(int error_code) { |
113 DCHECK_EQ(base::MessageLoop::current(), message_loop_); | 115 DCHECK_EQ(base::MessageLoop::current(), message_loop_); |
114 | 116 |
115 if (!channel_) // Already closed. | 117 if (!channel_) // Already closed. |
116 return; | 118 return; |
117 | 119 |
118 DCHECK(error_code != net::OK); | 120 DCHECK(error_code != net::OK); |
119 closed_error_code_ = error_code; | 121 closed_error_code_ = error_code; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 } | 191 } |
190 | 192 |
191 void TransportChannelSocketAdapter::OnChannelDestroyed( | 193 void TransportChannelSocketAdapter::OnChannelDestroyed( |
192 cricket::TransportChannel* channel) { | 194 cricket::TransportChannel* channel) { |
193 DCHECK_EQ(base::MessageLoop::current(), message_loop_); | 195 DCHECK_EQ(base::MessageLoop::current(), message_loop_); |
194 DCHECK_EQ(channel, channel_); | 196 DCHECK_EQ(channel, channel_); |
195 Close(net::ERR_CONNECTION_ABORTED); | 197 Close(net::ERR_CONNECTION_ABORTED); |
196 } | 198 } |
197 | 199 |
198 } // namespace jingle_glue | 200 } // namespace jingle_glue |
OLD | NEW |