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

Side by Side Diff: components/signin/core/browser/refresh_token_annotation_request.cc

Issue 2908263003: Replace deprecated base::NonThreadSafe in components/signin in favor of SequenceChecker. (Closed)
Patch Set: Created 3 years, 6 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 unified diff | Download patch
« no previous file with comments | « components/signin/core/browser/refresh_token_annotation_request.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/signin/core/browser/refresh_token_annotation_request.h" 5 #include "components/signin/core/browser/refresh_token_annotation_request.h"
6 6
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "base/metrics/histogram_macros.h" 8 #include "base/metrics/histogram_macros.h"
9 #include "base/rand_util.h" 9 #include "base/rand_util.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 23 matching lines...) Expand all
34 const base::Closure& request_callback) 34 const base::Closure& request_callback)
35 : OAuth2TokenService::Consumer("refresh_token_annotation"), 35 : OAuth2TokenService::Consumer("refresh_token_annotation"),
36 request_context_getter_(request_context_getter), 36 request_context_getter_(request_context_getter),
37 product_version_(product_version), 37 product_version_(product_version),
38 device_id_(device_id), 38 device_id_(device_id),
39 client_id_(client_id), 39 client_id_(client_id),
40 request_callback_(request_callback) { 40 request_callback_(request_callback) {
41 } 41 }
42 42
43 RefreshTokenAnnotationRequest::~RefreshTokenAnnotationRequest() { 43 RefreshTokenAnnotationRequest::~RefreshTokenAnnotationRequest() {
44 DCHECK(CalledOnValidThread()); 44 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
45 } 45 }
46 46
47 // static 47 // static
48 std::unique_ptr<RefreshTokenAnnotationRequest> 48 std::unique_ptr<RefreshTokenAnnotationRequest>
49 RefreshTokenAnnotationRequest::SendIfNeeded( 49 RefreshTokenAnnotationRequest::SendIfNeeded(
50 PrefService* pref_service, 50 PrefService* pref_service,
51 OAuth2TokenService* token_service, 51 OAuth2TokenService* token_service,
52 SigninClient* signin_client, 52 SigninClient* signin_client,
53 const scoped_refptr<net::URLRequestContextGetter>& request_context_getter, 53 const scoped_refptr<net::URLRequestContextGetter>& request_context_getter,
54 const std::string& account_id, 54 const std::string& account_id,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 pref_service->SetInt64( 95 pref_service->SetInt64(
96 prefs::kGoogleServicesRefreshTokenAnnotateScheduledTime, 96 prefs::kGoogleServicesRefreshTokenAnnotateScheduledTime,
97 scheduled_time.ToInternalValue()); 97 scheduled_time.ToInternalValue());
98 } 98 }
99 return should_send_now; 99 return should_send_now;
100 } 100 }
101 101
102 void RefreshTokenAnnotationRequest::RequestAccessToken( 102 void RefreshTokenAnnotationRequest::RequestAccessToken(
103 OAuth2TokenService* token_service, 103 OAuth2TokenService* token_service,
104 const std::string& account_id) { 104 const std::string& account_id) {
105 DCHECK(CalledOnValidThread()); 105 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
106 OAuth2TokenService::ScopeSet scopes; 106 OAuth2TokenService::ScopeSet scopes;
107 scopes.insert(GaiaConstants::kOAuth1LoginScope); 107 scopes.insert(GaiaConstants::kOAuth1LoginScope);
108 access_token_request_ = token_service->StartRequest(account_id, scopes, this); 108 access_token_request_ = token_service->StartRequest(account_id, scopes, this);
109 } 109 }
110 110
111 void RefreshTokenAnnotationRequest::OnGetTokenSuccess( 111 void RefreshTokenAnnotationRequest::OnGetTokenSuccess(
112 const OAuth2TokenService::Request* request, 112 const OAuth2TokenService::Request* request,
113 const std::string& access_token, 113 const std::string& access_token,
114 const base::Time& expiration_time) { 114 const base::Time& expiration_time) {
115 DCHECK(CalledOnValidThread()); 115 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
116 DVLOG(2) << "Got access token"; 116 DVLOG(2) << "Got access token";
117 Start(request_context_getter_.get(), access_token); 117 Start(request_context_getter_.get(), access_token);
118 } 118 }
119 119
120 void RefreshTokenAnnotationRequest::OnGetTokenFailure( 120 void RefreshTokenAnnotationRequest::OnGetTokenFailure(
121 const OAuth2TokenService::Request* request, 121 const OAuth2TokenService::Request* request,
122 const GoogleServiceAuthError& error) { 122 const GoogleServiceAuthError& error) {
123 DCHECK(CalledOnValidThread()); 123 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
124 DVLOG(2) << "Failed to get access token"; 124 DVLOG(2) << "Failed to get access token";
125 RecordRequestStatusHistogram(false); 125 RecordRequestStatusHistogram(false);
126 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, request_callback_); 126 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, request_callback_);
127 request_callback_.Reset(); 127 request_callback_.Reset();
128 } 128 }
129 129
130 GURL RefreshTokenAnnotationRequest::CreateApiCallUrl() { 130 GURL RefreshTokenAnnotationRequest::CreateApiCallUrl() {
131 return GaiaUrls::GetInstance()->oauth2_issue_token_url(); 131 return GaiaUrls::GetInstance()->oauth2_issue_token_url();
132 } 132 }
133 133
(...skipping 15 matching lines...) Expand all
149 kIssueTokenBodyFormat, 149 kIssueTokenBodyFormat,
150 net::EscapeUrlEncodedData(GaiaConstants::kGoogleUserInfoEmail, true) 150 net::EscapeUrlEncodedData(GaiaConstants::kGoogleUserInfoEmail, true)
151 .c_str(), 151 .c_str(),
152 net::EscapeUrlEncodedData(client_id_, true).c_str(), 152 net::EscapeUrlEncodedData(client_id_, true).c_str(),
153 net::EscapeUrlEncodedData(device_id_, true).c_str(), 153 net::EscapeUrlEncodedData(device_id_, true).c_str(),
154 net::EscapeUrlEncodedData(product_version_, true).c_str()); 154 net::EscapeUrlEncodedData(product_version_, true).c_str());
155 } 155 }
156 156
157 void RefreshTokenAnnotationRequest::ProcessApiCallSuccess( 157 void RefreshTokenAnnotationRequest::ProcessApiCallSuccess(
158 const net::URLFetcher* source) { 158 const net::URLFetcher* source) {
159 DCHECK(CalledOnValidThread()); 159 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
160 DVLOG(2) << "Request succeeded"; 160 DVLOG(2) << "Request succeeded";
161 RecordRequestStatusHistogram(true); 161 RecordRequestStatusHistogram(true);
162 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, request_callback_); 162 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, request_callback_);
163 request_callback_.Reset(); 163 request_callback_.Reset();
164 } 164 }
165 165
166 void RefreshTokenAnnotationRequest::ProcessApiCallFailure( 166 void RefreshTokenAnnotationRequest::ProcessApiCallFailure(
167 const net::URLFetcher* source) { 167 const net::URLFetcher* source) {
168 DCHECK(CalledOnValidThread()); 168 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
169 DVLOG(2) << "Request failed"; 169 DVLOG(2) << "Request failed";
170 RecordRequestStatusHistogram(false); 170 RecordRequestStatusHistogram(false);
171 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, request_callback_); 171 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, request_callback_);
172 request_callback_.Reset(); 172 request_callback_.Reset();
173 } 173 }
OLDNEW
« no previous file with comments | « components/signin/core/browser/refresh_token_annotation_request.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698