Skip to content

Commit

Permalink
Add Traffic Annotation to interfaces of AdbClientSocket.
Browse files Browse the repository at this point in the history
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: Dmitry Gozman <dgozman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#523715}
  • Loading branch information
raminhalavati authored and Commit Bot committed Dec 13, 2017
1 parent f5de05f commit ec4e68e
Showing 1 changed file with 29 additions and 6 deletions.
35 changes: 29 additions & 6 deletions chrome/browser/devtools/device/adb/adb_client_socket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "net/base/net_errors.h"
#include "net/log/net_log_source.h"
#include "net/socket/tcp_client_socket.h"
#include "net/traffic_annotation/network_traffic_annotation.h"

namespace {

Expand Down Expand Up @@ -196,12 +197,34 @@ void AdbClientSocket::SendCommand(const std::string& command,
const CommandCallback& callback) {
scoped_refptr<net::StringIOBuffer> request_buffer =
new net::StringIOBuffer(EncodeMessage(command));
int result = socket_->Write(request_buffer.get(),
request_buffer->size(),
base::Bind(&AdbClientSocket::ReadResponse,
base::Unretained(this),
callback,
is_void));
net::NetworkTrafficAnnotationTag traffic_annotation =
net::DefineNetworkTrafficAnnotation("adb_client_socket", R"(
semantics {
sender: "ADB Client Socket"
description:
"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)
ReadResponse(callback, is_void, result);
}
Expand Down

0 comments on commit ec4e68e

Please sign in to comment.