Commit ec4e68e9 authored by rhalavati@google.com's avatar rhalavati@google.com Committed by Commit Bot

Add Traffic Annotation to interfaces of AdbClientSocket.

Network Traffic Annotation is added to the socket write of the
AdbClientSocket class.

Bug: 656607
Change-Id: I1e05fc201290e0c55b78b8b03aee79284ffd7b4d
Reviewed-on: https://chromium-review.googlesource.com/813757
Commit-Queue: Ramin Halavati <rhalavati@chromium.org>
Reviewed-by: default avatarDmitry Gozman <dgozman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#523715}
parent f5de05f6
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "net/base/net_errors.h" #include "net/base/net_errors.h"
#include "net/log/net_log_source.h" #include "net/log/net_log_source.h"
#include "net/socket/tcp_client_socket.h" #include "net/socket/tcp_client_socket.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
namespace { namespace {
...@@ -196,12 +197,34 @@ void AdbClientSocket::SendCommand(const std::string& command, ...@@ -196,12 +197,34 @@ void AdbClientSocket::SendCommand(const std::string& command,
const CommandCallback& callback) { const CommandCallback& callback) {
scoped_refptr<net::StringIOBuffer> request_buffer = scoped_refptr<net::StringIOBuffer> request_buffer =
new net::StringIOBuffer(EncodeMessage(command)); new net::StringIOBuffer(EncodeMessage(command));
int result = socket_->Write(request_buffer.get(), net::NetworkTrafficAnnotationTag traffic_annotation =
request_buffer->size(), net::DefineNetworkTrafficAnnotation("adb_client_socket", R"(
base::Bind(&AdbClientSocket::ReadResponse, semantics {
base::Unretained(this), sender: "ADB Client Socket"
callback, description:
is_void)); "Remote debugging is supported over existing ADB (Android Debug "
"Bridge) connection, in addition to raw USB connection. This "
"socket talks to the local ADB daemon which routes debugging "
"traffic to a remote device."
trigger:
"A user connects to an Android device using remote debugging."
data: "Any data required for remote debugging."
destination: LOCAL
}
policy {
cookies_allowed: false
setting:
"To use adb with a device connected over USB, you must enable USB "
"debugging in the device system settings, under Developer options."
policy_exception_justification:
"This is not a network request and is only used for remote "
"debugging."
})");
int result =
socket_->Write(request_buffer.get(), request_buffer->size(),
base::Bind(&AdbClientSocket::ReadResponse,
base::Unretained(this), callback, is_void),
traffic_annotation);
if (result != net::ERR_IO_PENDING) if (result != net::ERR_IO_PENDING)
ReadResponse(callback, is_void, result); ReadResponse(callback, is_void, result);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment