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

Unified Diff: google_apis/gaia/gaia_oauth_client.cc

Issue 2796293003: Network traffic annotation added to google_apis/gaia. (Closed)
Patch Set: Moved oauth2_api_call_flow.* to CL 2888053003 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
Index: google_apis/gaia/gaia_oauth_client.cc
diff --git a/google_apis/gaia/gaia_oauth_client.cc b/google_apis/gaia/gaia_oauth_client.cc
index 8947febbc4dc270bed73f7d7ed2bf00e2be9bfd1..465f4123cb1df8b917c08ae24026e97324872f62 100644
--- a/google_apis/gaia/gaia_oauth_client.cc
+++ b/google_apis/gaia/gaia_oauth_client.cc
@@ -16,6 +16,7 @@
#include "net/base/escape.h"
#include "net/base/load_flags.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_fetcher_delegate.h"
#include "net/url_request/url_request_context_getter.h"
@@ -92,7 +93,8 @@ class GaiaOAuthClient::Core
void MakeGaiaRequest(const GURL& url,
const std::string& post_body,
int max_retries,
- GaiaOAuthClient::Delegate* delegate);
+ GaiaOAuthClient::Delegate* delegate,
+ net::NetworkTrafficAnnotationTag& traffic_annotation);
void HandleResponse(const net::URLFetcher* source,
bool* should_retry_request);
@@ -119,8 +121,28 @@ void GaiaOAuthClient::Core::GetTokensFromAuthCode(
"&redirect_uri=" +
net::EscapeUrlEncodedData(oauth_client_info.redirect_uri, true) +
"&grant_type=authorization_code";
- MakeGaiaRequest(GURL(GaiaUrls::GetInstance()->oauth2_token_url()),
- post_body, max_retries, delegate);
+ net::NetworkTrafficAnnotationTag traffic_annotation =
+ net::DefineNetworkTrafficAnnotation("...", R"(
+ semantics {
+ sender: "..."
+ description: "..."
msarda 2017/05/22 11:49:35 This request exchanges an authorization code for a
Ramin Halavati 2017/05/22 12:42:17 Done.
+ trigger: "..."
msarda 2017/05/22 11:49:35 This request is triggered at when another service
Ramin Halavati 2017/05/22 12:42:17 Done.
+ data: "..."
msarda 2017/05/22 11:49:35 The Google console client ID and client secret of
Ramin Halavati 2017/05/22 12:42:16 Done.
+ destination: WEBSITE/GOOGLE_OWNED_SERVICE/OTHER
msarda 2017/05/22 11:49:36 GOOGLE_OWNED_SERVICE
Ramin Halavati 2017/05/22 12:42:17 Done.
+ }
+ policy {
+ cookies_allowed: false
+ setting: "..."
msarda 2017/05/22 11:49:36 This feature cannot be disabled in settings. Howe
+ chrome_policy {
msarda 2017/05/22 11:49:36 I have no idea if this is gated on any policy. It
+ [POLICY_NAME] {
+ policy_options {mode: MANDATORY/RECOMMENDED/UNSET}
+ [POLICY_NAME]: ... //(value to disable it)
+ }
+ }
+ policy_exception_justification: "..."
+ })");
+ MakeGaiaRequest(GURL(GaiaUrls::GetInstance()->oauth2_token_url()), post_body,
+ max_retries, delegate, traffic_annotation);
}
void GaiaOAuthClient::Core::RefreshToken(
@@ -144,8 +166,28 @@ void GaiaOAuthClient::Core::RefreshToken(
post_body += "&scope=" + net::EscapeUrlEncodedData(scopes_string, true);
}
- MakeGaiaRequest(GURL(GaiaUrls::GetInstance()->oauth2_token_url()),
- post_body, max_retries, delegate);
+ net::NetworkTrafficAnnotationTag traffic_annotation =
+ net::DefineNetworkTrafficAnnotation("...", R"(
+ semantics {
+ sender: "..."
msarda 2017/05/22 11:49:35 Same as above
Ramin Halavati 2017/05/22 12:42:17 Done.
+ description: "..."
msarda 2017/05/22 11:49:36 This request fetches a fresh access token that can
Ramin Halavati 2017/05/22 12:42:16 Done.
+ trigger: "..."
msarda 2017/05/22 11:49:36 This is called whenever the caller needs a fresh O
Ramin Halavati 2017/05/22 12:42:17 Done.
+ data: "..."
msarda 2017/05/22 11:49:36 The OAuth 2.0 refresh token, the Google console cl
Ramin Halavati 2017/05/22 12:42:17 Done.
+ destination: WEBSITE/GOOGLE_OWNED_SERVICE/OTHER
msarda 2017/05/22 11:49:35 GOOGLE_OWNED_SERVICE
Ramin Halavati 2017/05/22 12:42:16 Done.
+ }
+ policy {
+ cookies_allowed: false
+ setting: "..."
msarda 2017/05/22 11:49:36 Same as above.
Ramin Halavati 2017/05/22 12:42:16 Done.
+ chrome_policy {
+ [POLICY_NAME] {
+ policy_options {mode: MANDATORY/RECOMMENDED/UNSET}
+ [POLICY_NAME]: ... //(value to disable it)
+ }
+ }
+ policy_exception_justification: "..."
+ })");
+ MakeGaiaRequest(GURL(GaiaUrls::GetInstance()->oauth2_token_url()), post_body,
+ max_retries, delegate, traffic_annotation);
}
void GaiaOAuthClient::Core::GetUserEmail(const std::string& oauth_access_token,
@@ -176,9 +218,29 @@ void GaiaOAuthClient::Core::GetUserInfoImpl(
request_type_ = type;
delegate_ = delegate;
num_retries_ = 0;
+ net::NetworkTrafficAnnotationTag traffic_annotation =
+ net::DefineNetworkTrafficAnnotation("gaia_core_get_user_info", R"(
+ semantics {
+ sender: "OAuth2 Client"
msarda 2017/05/22 11:49:35 I am a bit split about the sender. In the other ch
Ramin Halavati 2017/05/22 12:42:16 I am not sure, I used the latter, but if you have
+ description: "This request is used to fetch user information."
+ trigger:
+ "The main trigger for this request in the AccountTrackerService "
+ "that fetches the user info soon after the user signs in."
+ data:
+ "The OAUth2 access token of the account."
msarda 2017/05/22 11:49:35 s/OAUth2/OAuth 2.0
Ramin Halavati 2017/05/22 12:42:17 Done.
+ destination: GOOGLE_OWNED_SERVICE
+ }
+ policy {
+ cookies_allowed: false
+ setting: "This feature cannot be disabled in settings."
+ policy_exception_justification:
+ "Not implemented. Disabling this fetcher would break features that "
+ "require user information about of the account that is signed in ("
+ "e.g. the profile switcher UI, the settings UI etc)."
+ })");
request_ = net::URLFetcher::Create(
kUrlFetcherId, GURL(GaiaUrls::GetInstance()->oauth_user_info_url()),
- net::URLFetcher::GET, this);
+ net::URLFetcher::GET, this, traffic_annotation);
request_->SetRequestContext(request_context_getter_.get());
request_->AddExtraRequestHeader("Authorization: OAuth " + oauth_access_token);
request_->SetMaxRetriesOn5xx(max_retries);
@@ -203,22 +265,41 @@ void GaiaOAuthClient::Core::GetTokenInfo(const std::string& qualifier,
request_type_ = TOKEN_INFO;
std::string post_body =
qualifier + "=" + net::EscapeUrlEncodedData(query, true);
+ net::NetworkTrafficAnnotationTag traffic_annotation =
+ net::DefineNetworkTrafficAnnotation("...", R"(
+ semantics {
+ sender: "..."
msarda 2017/05/22 11:49:35 Same as above.
Ramin Halavati 2017/05/22 12:42:17 Done.
+ description: "..."
msarda 2017/05/22 11:49:36 This request fetches information about an OAuth 2.
Ramin Halavati 2017/05/22 12:42:16 Done.
+ trigger: "..."
msarda 2017/05/22 11:49:36 This is triggered after a Google account is added
Ramin Halavati 2017/05/22 12:42:17 Done.
+ data: "..."
msarda 2017/05/22 11:49:35 The OAuth 2.0 access token.
Ramin Halavati 2017/05/22 12:42:17 Done.
+ destination: WEBSITE/GOOGLE_OWNED_SERVICE/OTHER
msarda 2017/05/22 11:49:36 GOOGLE_OWNED_SERVICE
Ramin Halavati 2017/05/22 12:42:16 Done.
+ }
+ policy {
+ cookies_allowed: false
+ setting: "..."
msarda 2017/05/22 11:49:35 "This feature cannot be disabled in settings."
Ramin Halavati 2017/05/22 12:42:16 Done.
+ chrome_policy {
+ [POLICY_NAME] {
+ policy_options {mode: MANDATORY/RECOMMENDED/UNSET}
+ [POLICY_NAME]: ... //(value to disable it)
+ }
+ }
+ policy_exception_justification: "..."
+ })");
MakeGaiaRequest(GURL(GaiaUrls::GetInstance()->oauth2_token_info_url()),
- post_body,
- max_retries,
- delegate);
+ post_body, max_retries, delegate, traffic_annotation);
}
void GaiaOAuthClient::Core::MakeGaiaRequest(
const GURL& url,
const std::string& post_body,
int max_retries,
- GaiaOAuthClient::Delegate* delegate) {
+ GaiaOAuthClient::Delegate* delegate,
+ const net::NetworkTrafficAnnotationTag& traffic_annotation) {
DCHECK(!request_.get()) << "Tried to fetch two things at once!";
delegate_ = delegate;
num_retries_ = 0;
- request_ =
- net::URLFetcher::Create(kUrlFetcherId, url, net::URLFetcher::POST, this);
+ request_ = net::URLFetcher::Create(kUrlFetcherId, url, net::URLFetcher::POST,
+ this, traffic_annotation);
request_->SetRequestContext(request_context_getter_.get());
request_->SetUploadData("application/x-www-form-urlencoded", post_body);
request_->SetMaxRetriesOn5xx(max_retries);

Powered by Google App Engine
This is Rietveld 408576698