Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1331)

Unified Diff: chrome/browser/devtools/device/android_web_socket.cc

Issue 2871573011: [DevTools] Respond with a close frame (Closed)
Patch Set: [DevTools] Respond with a close frame Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/devtools/device/android_web_socket.cc
diff --git a/chrome/browser/devtools/device/android_web_socket.cc b/chrome/browser/devtools/device/android_web_socket.cc
index 4fa23fc0f939300b729fd215ba39d18ed0a8483b..8a57aa364a6011dd4ac1474955b49853f2d48dfb 100644
--- a/chrome/browser/devtools/device/android_web_socket.cc
+++ b/chrome/browser/devtools/device/android_web_socket.cc
@@ -23,6 +23,7 @@ using net::WebSocket;
namespace {
const int kBufferSize = 16 * 1024;
+const char kCloseResponse[] = "\x88\x80\x2D\x0E\x1E\xFA";
} // namespace
@@ -61,9 +62,7 @@ class AndroidDeviceManager::AndroidWebSocket::WebSocketImpl {
int mask = base::RandInt(0, 0x7FFFFFFF);
std::string encoded_frame;
encoder_->EncodeFrame(message, mask, &encoded_frame);
- request_buffer_ += encoded_frame;
- if (request_buffer_.length() == encoded_frame.length())
- SendPendingRequests(0);
+ SendData(encoded_frame);
}
private:
@@ -102,15 +101,22 @@ class AndroidDeviceManager::AndroidWebSocket::WebSocketImpl {
parse_result = encoder_->DecodeFrame(
response_buffer_, &bytes_consumed, &output);
}
+ if (parse_result == WebSocket::FRAME_CLOSE)
+ SendData(kCloseResponse);
- if (parse_result == WebSocket::FRAME_ERROR ||
- parse_result == WebSocket::FRAME_CLOSE) {
+ if (parse_result == WebSocket::FRAME_ERROR) {
Disconnect();
return;
}
Read(io_buffer);
}
+ void SendData(const std::string& data) {
+ request_buffer_ += data;
+ if (request_buffer_.length() == data.length())
+ SendPendingRequests(0);
+ }
+
void SendPendingRequests(int result) {
DCHECK(thread_checker_.CalledOnValidThread());
if (result < 0) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698