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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <limits> | 10 #include <limits> |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 // WebSocket implementation. | 149 // WebSocket implementation. |
150 void Connect(const String& url, | 150 void Connect(const String& url, |
151 Array<String> protocols, | 151 Array<String> protocols, |
152 const String& origin, | 152 const String& origin, |
153 ScopedDataPipeConsumerHandle send_stream, | 153 ScopedDataPipeConsumerHandle send_stream, |
154 WebSocketClientPtr client) override { | 154 WebSocketClientPtr client) override { |
155 NOTREACHED(); | 155 NOTREACHED(); |
156 } | 156 } |
157 | 157 |
158 void Send(bool fin, MessageType type, uint32_t num_bytes) override { | 158 void Send(bool fin, MessageType type, uint32_t num_bytes) override { |
159 if (!fin || type != MESSAGE_TYPE_TEXT) { | 159 if (!fin || type != MessageType::TEXT) { |
160 NOTIMPLEMENTED(); | 160 NOTIMPLEMENTED(); |
161 Close(); | 161 Close(); |
162 } | 162 } |
163 | 163 |
164 // TODO(yzshen): It shouldn't be an issue to pass an empty message. However, | 164 // TODO(yzshen): It shouldn't be an issue to pass an empty message. However, |
165 // WebSocket{Read,Write}Queue doesn't handle that correctly. | 165 // WebSocket{Read,Write}Queue doesn't handle that correctly. |
166 if (num_bytes == 0) | 166 if (num_bytes == 0) |
167 return; | 167 return; |
168 | 168 |
169 pending_send_count_++; | 169 pending_send_count_++; |
(...skipping 19 matching lines...) Expand all Loading... |
189 | 189 |
190 if (IsClosing()) | 190 if (IsClosing()) |
191 NotifyOwnerCloseIfAllDone(); | 191 NotifyOwnerCloseIfAllDone(); |
192 } | 192 } |
193 | 193 |
194 void OnFinishedWritingReceiveStream(uint32_t num_bytes, const char* buffer) { | 194 void OnFinishedWritingReceiveStream(uint32_t num_bytes, const char* buffer) { |
195 if (IsClosing()) | 195 if (IsClosing()) |
196 return; | 196 return; |
197 | 197 |
198 if (buffer) | 198 if (buffer) |
199 client_->DidReceiveData(true, MESSAGE_TYPE_TEXT, num_bytes); | 199 client_->DidReceiveData(true, MessageType::TEXT, num_bytes); |
200 } | 200 } |
201 | 201 |
202 // Checks whether Close() has been called. | 202 // Checks whether Close() has been called. |
203 bool IsClosing() const { return !binding_.is_bound(); } | 203 bool IsClosing() const { return !binding_.is_bound(); } |
204 | 204 |
205 void NotifyOwnerCloseIfAllDone() { | 205 void NotifyOwnerCloseIfAllDone() { |
206 DCHECK(IsClosing()); | 206 DCHECK(IsClosing()); |
207 | 207 |
208 if (pending_send_count_ == 0) | 208 if (pending_send_count_ == 0) |
209 connection_->OnWebSocketClosed(); | 209 connection_->OnWebSocketClosed(); |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 // The close operation is initiated by this object. | 418 // The close operation is initiated by this object. |
419 NotifyOwnerCloseIfAllDone(); | 419 NotifyOwnerCloseIfAllDone(); |
420 } else { | 420 } else { |
421 // The close operation is initiated by |web_socket_|; start closing this | 421 // The close operation is initiated by |web_socket_|; start closing this |
422 // object. | 422 // object. |
423 Close(); | 423 Close(); |
424 } | 424 } |
425 } | 425 } |
426 | 426 |
427 } // namespace mojo | 427 } // namespace mojo |
OLD | NEW |