Chromium Code Reviews| 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" |
| 11 #include "net/base/io_buffer.h" | |
|
Vladislav Kaznacheev
2013/10/16 11:27:04
Is this include necessary?
Dmitry Zvorygin
2013/10/17 16:19:37
Not necessary actually.
| |
| 11 #include "net/base/net_errors.h" | 12 #include "net/base/net_errors.h" |
| 12 #include "net/server/web_socket.h" | 13 #include "net/server/web_socket.h" |
| 13 | 14 |
| 14 using content::BrowserThread; | 15 using content::BrowserThread; |
| 15 using net::WebSocket; | 16 using net::WebSocket; |
| 16 | 17 |
| 17 const int kBufferSize = 16 * 1024; | 18 const int kBufferSize = 16 * 1024; |
| 18 | 19 |
| 19 static const char kWebSocketUpgradeRequest[] = "GET %s HTTP/1.1\r\n" | 20 static const char kWebSocketUpgradeRequest[] = "GET %s HTTP/1.1\r\n" |
| 20 "Upgrade: WebSocket\r\n" | 21 "Upgrade: WebSocket\r\n" |
| 21 "Connection: Upgrade\r\n" | 22 "Connection: Upgrade\r\n" |
| 22 "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\n" | 23 "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\n" |
| 23 "Sec-WebSocket-Version: 13\r\n" | 24 "Sec-WebSocket-Version: 13\r\n" |
| 24 "\r\n"; | 25 "\r\n"; |
| 25 | 26 |
| 26 AdbWebSocket::AdbWebSocket( | 27 AdbWebSocket::AdbWebSocket( |
| 27 scoped_refptr<DevToolsAdbBridge::AndroidDevice> device, | 28 scoped_refptr<AndroidDevice> device, |
| 28 const std::string& socket_name, | 29 const std::string& socket_name, |
| 29 const std::string& url, | 30 const std::string& url, |
| 30 base::MessageLoop* adb_message_loop, | 31 base::MessageLoop* adb_message_loop, |
| 31 Delegate* delegate) | 32 Delegate* delegate) |
| 32 : device_(device), | 33 : device_(device), |
| 33 socket_name_(socket_name), | 34 socket_name_(socket_name), |
| 34 url_(url), | 35 url_(url), |
| 35 adb_message_loop_(adb_message_loop), | 36 adb_message_loop_(adb_message_loop), |
| 36 delegate_(delegate) { | 37 delegate_(delegate) { |
| 37 adb_message_loop_->PostTask( | 38 adb_message_loop_->PostTask( |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 169 delegate_->OnSocketOpened(); | 170 delegate_->OnSocketOpened(); |
| 170 } | 171 } |
| 171 | 172 |
| 172 void AdbWebSocket::OnFrameRead(const std::string& message) { | 173 void AdbWebSocket::OnFrameRead(const std::string& message) { |
| 173 delegate_->OnFrameRead(message); | 174 delegate_->OnFrameRead(message); |
| 174 } | 175 } |
| 175 | 176 |
| 176 void AdbWebSocket::OnSocketClosed(bool closed_by_device) { | 177 void AdbWebSocket::OnSocketClosed(bool closed_by_device) { |
| 177 delegate_->OnSocketClosed(closed_by_device); | 178 delegate_->OnSocketClosed(closed_by_device); |
| 178 } | 179 } |
| OLD | NEW |