| 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 "mojo/services/network/web_socket_impl.h" | 5 #include "mojo/services/network/web_socket_impl.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "mojo/common/handle_watcher.h" | 9 #include "mojo/common/handle_watcher.h" |
| 10 #include "mojo/services/network/network_context.h" | 10 #include "mojo/services/network/network_context.h" |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 bool fin, | 170 bool fin, |
| 171 net::WebSocketFrameHeader::OpCode type, | 171 net::WebSocketFrameHeader::OpCode type, |
| 172 uint32_t num_bytes, | 172 uint32_t num_bytes, |
| 173 const char* buffer) { | 173 const char* buffer) { |
| 174 client_->DidReceiveData( | 174 client_->DidReceiveData( |
| 175 fin, ConvertTo<WebSocket::MessageType>(type), num_bytes); | 175 fin, ConvertTo<WebSocket::MessageType>(type), num_bytes); |
| 176 } | 176 } |
| 177 | 177 |
| 178 } // namespace mojo | 178 } // namespace mojo |
| 179 | 179 |
| 180 WebSocketImpl::WebSocketImpl(NetworkContext* context) : context_(context) { | 180 WebSocketImpl::WebSocketImpl( |
| 181 NetworkContext* context, |
| 182 scoped_ptr<mojo::AppRefCount> app_refcount) |
| 183 : context_(context), app_refcount_(app_refcount.Pass()) { |
| 181 } | 184 } |
| 182 | 185 |
| 183 WebSocketImpl::~WebSocketImpl() { | 186 WebSocketImpl::~WebSocketImpl() { |
| 184 } | 187 } |
| 185 | 188 |
| 186 void WebSocketImpl::Connect(const String& url, | 189 void WebSocketImpl::Connect(const String& url, |
| 187 Array<String> protocols, | 190 Array<String> protocols, |
| 188 const String& origin, | 191 const String& origin, |
| 189 ScopedDataPipeConsumerHandle send_stream, | 192 ScopedDataPipeConsumerHandle send_stream, |
| 190 WebSocketClientPtr client) { | 193 WebSocketClientPtr client) { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 uint32_t num_bytes, | 228 uint32_t num_bytes, |
| 226 const char* data) { | 229 const char* data) { |
| 227 std::vector<char> buffer(num_bytes); | 230 std::vector<char> buffer(num_bytes); |
| 228 memcpy(&buffer[0], data, num_bytes); | 231 memcpy(&buffer[0], data, num_bytes); |
| 229 DCHECK(channel_); | 232 DCHECK(channel_); |
| 230 channel_->SendFrame( | 233 channel_->SendFrame( |
| 231 fin, ConvertTo<net::WebSocketFrameHeader::OpCode>(type), buffer); | 234 fin, ConvertTo<net::WebSocketFrameHeader::OpCode>(type), buffer); |
| 232 } | 235 } |
| 233 | 236 |
| 234 } // namespace mojo | 237 } // namespace mojo |
| OLD | NEW |