OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "mojo/services/network/http_connection_impl.h" | 5 #include "mojo/services/network/http_connection_impl.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 // WebSocket implementation. | 143 // WebSocket implementation. |
144 void Connect(const String& url, | 144 void Connect(const String& url, |
145 Array<String> protocols, | 145 Array<String> protocols, |
146 const String& origin, | 146 const String& origin, |
147 ScopedDataPipeConsumerHandle send_stream, | 147 ScopedDataPipeConsumerHandle send_stream, |
148 WebSocketClientPtr client) override { | 148 WebSocketClientPtr client) override { |
149 NOTREACHED(); | 149 NOTREACHED(); |
150 } | 150 } |
151 | 151 |
152 void Send(bool fin, MessageType type, uint32_t num_bytes) override { | 152 void Send(bool fin, MessageType type, uint32_t num_bytes) override { |
153 if (!fin || type != MESSAGE_TYPE_TEXT) { | 153 if (!fin || type != MessageType::TEXT) { |
154 NOTIMPLEMENTED(); | 154 NOTIMPLEMENTED(); |
155 Close(); | 155 Close(); |
156 } | 156 } |
157 | 157 |
158 // TODO(yzshen): It shouldn't be an issue to pass an empty message. However, | 158 // TODO(yzshen): It shouldn't be an issue to pass an empty message. However, |
159 // WebSocket{Read,Write}Queue doesn't handle that correctly. | 159 // WebSocket{Read,Write}Queue doesn't handle that correctly. |
160 if (num_bytes == 0) | 160 if (num_bytes == 0) |
161 return; | 161 return; |
162 | 162 |
163 pending_send_count_++; | 163 pending_send_count_++; |
(...skipping 19 matching lines...) Expand all Loading... |
183 | 183 |
184 if (IsClosing()) | 184 if (IsClosing()) |
185 NotifyOwnerCloseIfAllDone(); | 185 NotifyOwnerCloseIfAllDone(); |
186 } | 186 } |
187 | 187 |
188 void OnFinishedWritingReceiveStream(uint32_t num_bytes, const char* buffer) { | 188 void OnFinishedWritingReceiveStream(uint32_t num_bytes, const char* buffer) { |
189 if (IsClosing()) | 189 if (IsClosing()) |
190 return; | 190 return; |
191 | 191 |
192 if (buffer) | 192 if (buffer) |
193 client_->DidReceiveData(true, MESSAGE_TYPE_TEXT, num_bytes); | 193 client_->DidReceiveData(true, MessageType::TEXT, num_bytes); |
194 } | 194 } |
195 | 195 |
196 // Checks whether Close() has been called. | 196 // Checks whether Close() has been called. |
197 bool IsClosing() const { return !binding_.is_bound(); } | 197 bool IsClosing() const { return !binding_.is_bound(); } |
198 | 198 |
199 void NotifyOwnerCloseIfAllDone() { | 199 void NotifyOwnerCloseIfAllDone() { |
200 DCHECK(IsClosing()); | 200 DCHECK(IsClosing()); |
201 | 201 |
202 if (pending_send_count_ == 0) | 202 if (pending_send_count_ == 0) |
203 connection_->OnWebSocketClosed(); | 203 connection_->OnWebSocketClosed(); |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 // The close operation is initiated by this object. | 411 // The close operation is initiated by this object. |
412 NotifyOwnerCloseIfAllDone(); | 412 NotifyOwnerCloseIfAllDone(); |
413 } else { | 413 } else { |
414 // The close operation is initiated by |web_socket_|; start closing this | 414 // The close operation is initiated by |web_socket_|; start closing this |
415 // object. | 415 // object. |
416 Close(); | 416 Close(); |
417 } | 417 } |
418 } | 418 } |
419 | 419 |
420 } // namespace mojo | 420 } // namespace mojo |
OLD | NEW |