| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chrome/browser/devtools/adb_web_socket.h" | 5 #include "chrome/browser/devtools/adb_web_socket.h" |
| 6 | 6 |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/rand_util.h" | 8 #include "base/rand_util.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 int mask = base::RandInt(0, 0x7FFFFFFF); | 56 int mask = base::RandInt(0, 0x7FFFFFFF); |
| 57 std::string encoded_frame = WebSocket::EncodeFrameHybi17(message, mask); | 57 std::string encoded_frame = WebSocket::EncodeFrameHybi17(message, mask); |
| 58 request_buffer_ += encoded_frame; | 58 request_buffer_ += encoded_frame; |
| 59 if (request_buffer_.length() == encoded_frame.length()) | 59 if (request_buffer_.length() == encoded_frame.length()) |
| 60 SendPendingRequests(0); | 60 SendPendingRequests(0); |
| 61 } | 61 } |
| 62 | 62 |
| 63 AdbWebSocket::~AdbWebSocket() {} | 63 AdbWebSocket::~AdbWebSocket() {} |
| 64 | 64 |
| 65 void AdbWebSocket::ConnectOnHandlerThread() { | 65 void AdbWebSocket::ConnectOnHandlerThread() { |
| 66 device_->HttpQuery( | 66 device_->HttpUpgrade( |
| 67 socket_name_, | 67 socket_name_, |
| 68 base::StringPrintf(kWebSocketUpgradeRequest, url_.c_str()), | 68 base::StringPrintf(kWebSocketUpgradeRequest, url_.c_str()), |
| 69 base::Bind(&AdbWebSocket::ConnectedOnHandlerThread, this)); | 69 base::Bind(&AdbWebSocket::ConnectedOnHandlerThread, this)); |
| 70 } | 70 } |
| 71 | 71 |
| 72 void AdbWebSocket::ConnectedOnHandlerThread( | 72 void AdbWebSocket::ConnectedOnHandlerThread( |
| 73 int result, net::StreamSocket* socket) { | 73 int result, net::StreamSocket* socket) { |
| 74 if (result != net::OK || socket == NULL) { | 74 if (result != net::OK || socket == NULL) { |
| 75 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 75 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 76 base::Bind(&AdbWebSocket::OnSocketClosed, this, true)); | 76 base::Bind(&AdbWebSocket::OnSocketClosed, this, true)); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 delegate_->OnSocketOpened(); | 169 delegate_->OnSocketOpened(); |
| 170 } | 170 } |
| 171 | 171 |
| 172 void AdbWebSocket::OnFrameRead(const std::string& message) { | 172 void AdbWebSocket::OnFrameRead(const std::string& message) { |
| 173 delegate_->OnFrameRead(message); | 173 delegate_->OnFrameRead(message); |
| 174 } | 174 } |
| 175 | 175 |
| 176 void AdbWebSocket::OnSocketClosed(bool closed_by_device) { | 176 void AdbWebSocket::OnSocketClosed(bool closed_by_device) { |
| 177 delegate_->OnSocketClosed(closed_by_device); | 177 delegate_->OnSocketClosed(closed_by_device); |
| 178 } | 178 } |
| OLD | NEW |