| 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/message_loop/message_loop.h" | 5 #include "base/message_loop/message_loop.h" |
| 6 #include "base/rand_util.h" | 6 #include "base/rand_util.h" |
| 7 #include "chrome/browser/devtools/device/android_device_manager.h" | 7 #include "chrome/browser/devtools/device/android_device_manager.h" |
| 8 #include "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
| 9 #include "net/base/io_buffer.h" | 9 #include "net/base/io_buffer.h" |
| 10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 scoped_refptr<net::IOBuffer> response_buffer, int result) { | 137 scoped_refptr<net::IOBuffer> response_buffer, int result) { |
| 138 DCHECK_EQ(device_message_loop_, base::MessageLoopProxy::current()); | 138 DCHECK_EQ(device_message_loop_, base::MessageLoopProxy::current()); |
| 139 if (!socket_) | 139 if (!socket_) |
| 140 return; | 140 return; |
| 141 | 141 |
| 142 if (result <= 0) { | 142 if (result <= 0) { |
| 143 DisconnectOnHandlerThread(true); | 143 DisconnectOnHandlerThread(true); |
| 144 return; | 144 return; |
| 145 } | 145 } |
| 146 | 146 |
| 147 std::string data = std::string(response_buffer->data(), result); | 147 response_buffer_.append(response_buffer->data(), result); |
| 148 response_buffer_ += data; | |
| 149 | 148 |
| 150 int bytes_consumed; | 149 int bytes_consumed; |
| 151 std::string output; | 150 std::string output; |
| 152 WebSocket::ParseResult parse_result = WebSocket::DecodeFrameHybi17( | 151 WebSocket::ParseResult parse_result = WebSocket::DecodeFrameHybi17( |
| 153 response_buffer_, false, &bytes_consumed, &output); | 152 response_buffer_, false, &bytes_consumed, &output); |
| 154 | 153 |
| 155 while (parse_result == WebSocket::FRAME_OK) { | 154 while (parse_result == WebSocket::FRAME_OK) { |
| 156 response_buffer_ = response_buffer_.substr(bytes_consumed); | 155 response_buffer_ = response_buffer_.substr(bytes_consumed); |
| 157 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 156 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 158 base::Bind(&WebSocketImpl::OnFrameRead, this, output)); | 157 base::Bind(&WebSocketImpl::OnFrameRead, this, output)); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 | 222 |
| 224 } // namespace | 223 } // namespace |
| 225 | 224 |
| 226 scoped_refptr<AndroidDeviceManager::AndroidWebSocket> | 225 scoped_refptr<AndroidDeviceManager::AndroidWebSocket> |
| 227 AndroidDeviceManager::Device::CreateWebSocket( | 226 AndroidDeviceManager::Device::CreateWebSocket( |
| 228 const std::string& socket, | 227 const std::string& socket, |
| 229 const std::string& url, | 228 const std::string& url, |
| 230 AndroidDeviceManager::AndroidWebSocket::Delegate* delegate) { | 229 AndroidDeviceManager::AndroidWebSocket::Delegate* delegate) { |
| 231 return new WebSocketImpl(device_message_loop_, this, socket, url, delegate); | 230 return new WebSocketImpl(device_message_loop_, this, socket, url, delegate); |
| 232 } | 231 } |
| OLD | NEW |