Commit b0663bc7 authored by Renjie Liu's avatar Renjie Liu Committed by Commit Bot

Add partial traffic annotation to network_location_request

This is for
https://docs.google.com/document/d/1oSQM3GEMTL1raWLYv8S6_Yyt93FF2zQbANI4bKJ6LDs/edit?pli=1#heading=h.2st2zzoz32x8
and that we plan to reuse NetworkLocationRequest from there,
and a different "setting" and/or "chrome_policy" field will be
appropriate depending on the caller.

Bug: 718694,769158
Change-Id: Ie966a1ec6139f1d613ba2e0c5f83d02b9dc42ace
Reviewed-on: https://chromium-review.googlesource.com/717596Reviewed-by: default avatarMiguel Casas <mcasas@chromium.org>
Commit-Queue: Renjie Liu <renjieliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#509632}
parent 97367b77
......@@ -12,6 +12,7 @@
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "net/url_request/url_request_context_getter.h"
namespace device {
......@@ -227,7 +228,25 @@ void NetworkLocationProvider::RequestPosition() {
"with new data. Wifi APs: "
<< wifi_data_.access_point_data.size();
request_->MakeRequest(wifi_data_, wifi_timestamp_);
net::PartialNetworkTrafficAnnotationTag partial_traffic_annotation =
net::DefinePartialNetworkTrafficAnnotation("network_location_provider",
"device_geolocation_request",
R"(
semantics {
sender: "Network Location Provider"
}
policy {
setting:
"Users can control this feature via the Location setting under "
"'Privacy', 'Content Settings', 'Location'."
chrome_policy {
DefaultGeolocationSetting {
DefaultGeolocationSetting: 2
}
}
})");
request_->MakeRequest(wifi_data_, wifi_timestamp_,
partial_traffic_annotation);
}
bool NetworkLocationProvider::IsStarted() const {
......
......@@ -116,8 +116,10 @@ NetworkLocationRequest::NetworkLocationRequest(
NetworkLocationRequest::~NetworkLocationRequest() {}
bool NetworkLocationRequest::MakeRequest(const WifiData& wifi_data,
const base::Time& wifi_timestamp) {
bool NetworkLocationRequest::MakeRequest(
const WifiData& wifi_data,
const base::Time& wifi_timestamp,
const net::PartialNetworkTrafficAnnotationTag& partial_traffic_annotation) {
RecordUmaEvent(NETWORK_LOCATION_REQUEST_EVENT_REQUEST_START);
RecordUmaAccessPoints(wifi_data.access_point_data.size());
if (url_fetcher_ != NULL) {
......@@ -129,9 +131,10 @@ bool NetworkLocationRequest::MakeRequest(const WifiData& wifi_data,
wifi_timestamp_ = wifi_timestamp;
net::NetworkTrafficAnnotationTag traffic_annotation =
net::DefineNetworkTrafficAnnotation("device_geolocation_request", R"(
net::CompleteNetworkTrafficAnnotation("device_geolocation_request",
partial_traffic_annotation,
R"(
semantics {
sender: "Network Location Provider"
description:
"Obtains geo position based on current IP address."
trigger:
......@@ -142,16 +145,7 @@ bool NetworkLocationRequest::MakeRequest(const WifiData& wifi_data,
}
policy {
cookies_allowed: NO
setting:
"Users can control this feature via the Location setting under "
"'Privacy', 'Content Settings...'."
chrome_policy {
DefaultGeolocationSetting {
policy_options {mode: MANDATORY}
DefaultGeolocationSetting: 2
}
}
})");
})");
const GURL request_url = FormRequestURL(api_key_);
DCHECK(request_url.is_valid());
url_fetcher_ =
......
......@@ -19,6 +19,8 @@
namespace net {
class URLFetcher;
class URLRequestContextGetter;
struct PartialNetworkTrafficAnnotationTag;
}
namespace device {
......@@ -46,7 +48,10 @@ class NetworkLocationRequest : private net::URLFetcherDelegate {
// Makes a new request. Returns true if the new request was successfully
// started. In all cases, any currently pending request will be canceled.
bool MakeRequest(const WifiData& wifi_data, const base::Time& wifi_timestamp);
bool MakeRequest(const WifiData& wifi_data,
const base::Time& wifi_timestamp,
const net::PartialNetworkTrafficAnnotationTag&
partial_traffic_annotation);
bool is_request_pending() const { return url_fetcher_ != NULL; }
......
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