| OLD | NEW |
| 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 #include "components/html_viewer/web_socket_handle_impl.h" | 5 #include "components/html_viewer/web_socket_handle_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/logging.h" |
| 11 #include "base/macros.h" | 12 #include "base/macros.h" |
| 12 #include "components/html_viewer/blink_basic_type_converters.h" | 13 #include "components/html_viewer/blink_basic_type_converters.h" |
| 13 #include "mojo/public/cpp/bindings/binding.h" | 14 #include "mojo/public/cpp/bindings/binding.h" |
| 14 #include "mojo/services/network/public/cpp/web_socket_read_queue.h" | 15 #include "mojo/services/network/public/cpp/web_socket_read_queue.h" |
| 15 #include "mojo/services/network/public/cpp/web_socket_write_queue.h" | 16 #include "mojo/services/network/public/cpp/web_socket_write_queue.h" |
| 16 #include "mojo/services/network/public/interfaces/web_socket_factory.mojom.h" | 17 #include "mojo/services/network/public/interfaces/web_socket_factory.mojom.h" |
| 17 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" | 18 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" |
| 18 #include "third_party/WebKit/public/platform/WebString.h" | 19 #include "third_party/WebKit/public/platform/WebString.h" |
| 19 #include "third_party/WebKit/public/platform/WebURL.h" | 20 #include "third_party/WebKit/public/platform/WebURL.h" |
| 20 #include "third_party/WebKit/public/platform/WebVector.h" | 21 #include "third_party/WebKit/public/platform/WebVector.h" |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 return; | 192 return; |
| 192 | 193 |
| 193 uint32_t size32 = static_cast<uint32_t>(size); | 194 uint32_t size32 = static_cast<uint32_t>(size); |
| 194 write_queue_->Write( | 195 write_queue_->Write( |
| 195 data, size32, | 196 data, size32, |
| 196 base::Bind(&WebSocketHandleImpl::DidWriteToSendStream, | 197 base::Bind(&WebSocketHandleImpl::DidWriteToSendStream, |
| 197 base::Unretained(this), | 198 base::Unretained(this), |
| 198 fin, type, size32)); | 199 fin, type, size32)); |
| 199 } | 200 } |
| 200 | 201 |
| 202 void WebSocketHandleImpl::sendBlob(const blink::WebString& uuid, |
| 203 uint64_t expectedSize) { |
| 204 NOTIMPLEMENTED(); |
| 205 } |
| 206 |
| 201 void WebSocketHandleImpl::flowControl(int64_t quota) { | 207 void WebSocketHandleImpl::flowControl(int64_t quota) { |
| 202 if (!client_) | 208 if (!client_) |
| 203 return; | 209 return; |
| 204 | 210 |
| 205 web_socket_->FlowControl(quota); | 211 web_socket_->FlowControl(quota); |
| 206 } | 212 } |
| 207 | 213 |
| 208 void WebSocketHandleImpl::close(unsigned short code, const WebString& reason) { | 214 void WebSocketHandleImpl::close(unsigned short code, const WebString& reason) { |
| 209 web_socket_->Close(code, reason.utf8()); | 215 web_socket_->Close(code, reason.utf8()); |
| 210 } | 216 } |
| 211 | 217 |
| 212 void WebSocketHandleImpl::DidWriteToSendStream( | 218 void WebSocketHandleImpl::DidWriteToSendStream( |
| 213 bool fin, | 219 bool fin, |
| 214 WebSocketHandle::MessageType type, | 220 WebSocketHandle::MessageType type, |
| 215 uint32_t num_bytes, | 221 uint32_t num_bytes, |
| 216 const char* data) { | 222 const char* data) { |
| 217 web_socket_->Send(fin, ConvertTo<WebSocket::MessageType>(type), num_bytes); | 223 web_socket_->Send(fin, ConvertTo<WebSocket::MessageType>(type), num_bytes); |
| 218 } | 224 } |
| 219 | 225 |
| 220 void WebSocketHandleImpl::Disconnect() { | 226 void WebSocketHandleImpl::Disconnect() { |
| 221 did_close_ = true; | 227 did_close_ = true; |
| 222 client_.reset(); | 228 client_.reset(); |
| 223 } | 229 } |
| 224 | 230 |
| 225 } // namespace html_viewer | 231 } // namespace html_viewer |
| OLD | NEW |