| 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 "base/memory/weak_ptr.h" | 5 #include "base/memory/weak_ptr.h" |
| 6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
| 7 #include "base/rand_util.h" | 7 #include "base/rand_util.h" |
| 8 #include "chrome/browser/devtools/device/android_device_manager.h" | 8 #include "chrome/browser/devtools/device/android_device_manager.h" |
| 9 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
| 10 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 } | 192 } |
| 193 | 193 |
| 194 void WebSocketImpl::OnBytesRead(scoped_refptr<net::IOBuffer> response_buffer, | 194 void WebSocketImpl::OnBytesRead(scoped_refptr<net::IOBuffer> response_buffer, |
| 195 int result) { | 195 int result) { |
| 196 DCHECK(thread_checker_.CalledOnValidThread()); | 196 DCHECK(thread_checker_.CalledOnValidThread()); |
| 197 if (result <= 0) { | 197 if (result <= 0) { |
| 198 Disconnect(); | 198 Disconnect(); |
| 199 return; | 199 return; |
| 200 } | 200 } |
| 201 | 201 |
| 202 std::string data = std::string(response_buffer->data(), result); | 202 response_buffer_.append(response_buffer->data(), result); |
| 203 response_buffer_ += data; | |
| 204 | 203 |
| 205 int bytes_consumed; | 204 int bytes_consumed; |
| 206 std::string output; | 205 std::string output; |
| 207 WebSocket::ParseResult parse_result = WebSocket::DecodeFrameHybi17( | 206 WebSocket::ParseResult parse_result = WebSocket::DecodeFrameHybi17( |
| 208 response_buffer_, false, &bytes_consumed, &output); | 207 response_buffer_, false, &bytes_consumed, &output); |
| 209 | 208 |
| 210 while (parse_result == WebSocket::FRAME_OK) { | 209 while (parse_result == WebSocket::FRAME_OK) { |
| 211 response_buffer_ = response_buffer_.substr(bytes_consumed); | 210 response_buffer_ = response_buffer_.substr(bytes_consumed); |
| 212 delegate_->OnFrameRead(output); | 211 delegate_->OnFrameRead(output); |
| 213 parse_result = WebSocket::DecodeFrameHybi17( | 212 parse_result = WebSocket::DecodeFrameHybi17( |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 } // namespace | 271 } // namespace |
| 273 | 272 |
| 274 AndroidDeviceManager::AndroidWebSocket* | 273 AndroidDeviceManager::AndroidWebSocket* |
| 275 AndroidDeviceManager::Device::CreateWebSocket( | 274 AndroidDeviceManager::Device::CreateWebSocket( |
| 276 const std::string& socket, | 275 const std::string& socket, |
| 277 const std::string& url, | 276 const std::string& url, |
| 278 AndroidDeviceManager::AndroidWebSocket::Delegate* delegate) { | 277 AndroidDeviceManager::AndroidWebSocket::Delegate* delegate) { |
| 279 return new AndroidWebSocketImpl( | 278 return new AndroidWebSocketImpl( |
| 280 device_message_loop_, this, socket, url, delegate); | 279 device_message_loop_, this, socket, url, delegate); |
| 281 } | 280 } |
| OLD | NEW |