Network traffic annotation added to goolge_apis/gcm/engine.

Network traffic annotation is added to network request of
google_apis/gcm/engine.

BUG=656607

Review-Url: https://codereview.chromium.org/2737433002
Cr-Original-Commit-Position: refs/heads/master@{#458270}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 19ae4d04c84aa9453c35e3aa8a470045a3f675d1
diff --git a/gcm/engine/checkin_request.cc b/gcm/engine/checkin_request.cc
index ad13923..452e284 100644
--- a/gcm/engine/checkin_request.cc
+++ b/gcm/engine/checkin_request.cc
@@ -11,6 +11,7 @@
 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h"
 #include "google_apis/gcm/protocol/checkin.pb.h"
 #include "net/base/load_flags.h"
+#include "net/traffic_annotation/network_traffic_annotation.h"
 #include "net/url_request/url_fetcher.h"
 #include "net/url_request/url_request_status.h"
 
@@ -144,9 +145,40 @@
 
   std::string upload_data;
   CHECK(request.SerializeToString(&upload_data));
-
-  url_fetcher_ =
-      net::URLFetcher::Create(checkin_url_, net::URLFetcher::POST, this);
+  net::NetworkTrafficAnnotationTag traffic_annotation =
+      net::DefineNetworkTrafficAnnotation("gcm_checkin", R"(
+        semantics {
+          sender: "GCM Driver"
+          description:
+            "Chromium interacts with Google Cloud Messaging to receive push "
+            "messages for various browser features, as well as on behalf of "
+            "websites and extensions. The check-in periodically verifies the "
+            "client's validity with Google servers, and receive updates to "
+            "configuration regarding interacting with Google services."
+          trigger:
+            "Immediately after a feature creates the first Google Cloud "
+            "Messaging registration. By default, Chromium will check in with "
+            "Google Cloud Messaging every two days. Google can adjust this "
+            "interval when it deems necessary."
+          data:
+            "The profile-bound Android ID and associated secret and account "
+            "tokens. A structure containing the Chromium version, channel, and "
+            "platform of the host operating system."
+          destination: GOOGLE_OWNED_SERVICE
+        }
+        policy {
+          cookies_allowed: false
+          setting:
+            "Support for interacting with Google Cloud Messaging is enabled by "
+            "default, and there is no configuration option to completely "
+            "disable it. Websites wishing to receive push messages must "
+            "acquire express permission from the user for the 'Notification' "
+            "permission."
+          policy_exception_justification:
+            "Not implemented, considered not useful."
+        })");
+  url_fetcher_ = net::URLFetcher::Create(checkin_url_, net::URLFetcher::POST,
+                                         this, traffic_annotation);
   url_fetcher_->SetRequestContext(request_context_getter_);
   url_fetcher_->SetUploadData(kRequestContentType, upload_data);
   url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES |
diff --git a/gcm/engine/registration_request.cc b/gcm/engine/registration_request.cc
index 386af0e..07c1c51 100644
--- a/gcm/engine/registration_request.cc
+++ b/gcm/engine/registration_request.cc
@@ -20,6 +20,7 @@
 #include "net/base/load_flags.h"
 #include "net/http/http_request_headers.h"
 #include "net/http/http_status_code.h"
+#include "net/traffic_annotation/network_traffic_annotation.h"
 #include "net/url_request/url_fetcher.h"
 #include "net/url_request/url_request_context_getter.h"
 #include "net/url_request/url_request_status.h"
@@ -144,9 +145,36 @@
 void RegistrationRequest::Start() {
   DCHECK(!callback_.is_null());
   DCHECK(!url_fetcher_.get());
-
-  url_fetcher_ =
-      net::URLFetcher::Create(registration_url_, net::URLFetcher::POST, this);
+  net::NetworkTrafficAnnotationTag traffic_annotation =
+      net::DefineNetworkTrafficAnnotation("gcm_registration", R"(
+        semantics {
+          sender: "GCM Driver"
+          description:
+            "Chromium interacts with Google Cloud Messaging to receive push "
+            "messages for various browser features, as well as on behalf of "
+            "websites and extensions. This requests Google Cloud Messaging to "
+            "create a new subscription through which messages can be sent to "
+            "the registering entity, through Chromium."
+          trigger:
+            "Immediately after a feature, website or extension creates a new "
+            "registration with the GCM Driver."
+          data:
+            "The profile-bound Android ID and associated secret, and the "
+            "identifiers for the feature, website or extension that is "
+            "creating the registration."
+          destination: GOOGLE_OWNED_SERVICE
+        }
+        policy {
+          cookies_allowed: false
+          setting:
+            "Support for interacting with Google Cloud Messaging is enabled by "
+            "default, and there is no configuration option to completely "
+            "disable it."
+          policy_exception_justification:
+            "Not implemented, considered not useful."
+        })");
+  url_fetcher_ = net::URLFetcher::Create(
+      registration_url_, net::URLFetcher::POST, this, traffic_annotation);
   url_fetcher_->SetRequestContext(request_context_getter_.get());
   url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES |
                              net::LOAD_DO_NOT_SAVE_COOKIES);
diff --git a/gcm/engine/unregistration_request.cc b/gcm/engine/unregistration_request.cc
index b7a07e4..3d0d477 100644
--- a/gcm/engine/unregistration_request.cc
+++ b/gcm/engine/unregistration_request.cc
@@ -18,6 +18,7 @@
 #include "net/base/load_flags.h"
 #include "net/http/http_request_headers.h"
 #include "net/http/http_status_code.h"
+#include "net/traffic_annotation/network_traffic_annotation.h"
 #include "net/url_request/url_fetcher.h"
 #include "net/url_request/url_request_context_getter.h"
 #include "net/url_request/url_request_status.h"
@@ -127,9 +128,36 @@
 void UnregistrationRequest::Start() {
   DCHECK(!callback_.is_null());
   DCHECK(!url_fetcher_.get());
-
-  url_fetcher_ =
-      net::URLFetcher::Create(registration_url_, net::URLFetcher::POST, this);
+  net::NetworkTrafficAnnotationTag traffic_annotation =
+      net::DefineNetworkTrafficAnnotation("gcm_unregistration", R"(
+        semantics {
+          sender: "GCM Driver"
+          description:
+            "Chromium interacts with Google Cloud Messaging to receive push "
+            "messages for various browser features, as well as on behalf of "
+            "websites and extensions. This requests Google Cloud Messaging to "
+            "invalidate the included registration so that it can no longer be "
+            "used to distribute messages to Chromium."
+          trigger:
+            "Immediately after a feature, website or extension removes a "
+            "registration they previously created with the GCM Driver."
+          data:
+            "The profile-bound Android ID and associated secret, and the "
+            "identifiers for the feature, website or extension that is "
+            "removing the registration."
+          destination: GOOGLE_OWNED_SERVICE
+        }
+        policy {
+          cookies_allowed: false
+          setting:
+            "Support for interacting with Google Cloud Messaging is enabled by "
+            "default, and there is no configuration option to completely "
+            "disable it."
+          policy_exception_justification:
+            "Not implemented, considered not useful."
+        })");
+  url_fetcher_ = net::URLFetcher::Create(
+      registration_url_, net::URLFetcher::POST, this, traffic_annotation);
   url_fetcher_->SetRequestContext(request_context_getter_.get());
   url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES |
                              net::LOAD_DO_NOT_SAVE_COOKIES);