OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/signin/oauth2_token_service_test_util.h" |
| 6 |
| 7 const char kValidTokenResponse[] = |
| 8 "{" |
| 9 " \"access_token\": \"%s\"," |
| 10 " \"expires_in\": %d," |
| 11 " \"token_type\": \"Bearer\"" |
| 12 "}"; |
| 13 |
| 14 std::string GetValidTokenResponse(std::string token, int expiration) { |
| 15 return base::StringPrintf(kValidTokenResponse, token.c_str(), expiration); |
| 16 } |
| 17 |
| 18 TestingOAuth2TokenServiceConsumer::TestingOAuth2TokenServiceConsumer() |
| 19 : number_of_successful_tokens_(0), |
| 20 last_error_(GoogleServiceAuthError::AuthErrorNone()), |
| 21 number_of_errors_(0) { |
| 22 } |
| 23 |
| 24 TestingOAuth2TokenServiceConsumer::~TestingOAuth2TokenServiceConsumer() { |
| 25 } |
| 26 |
| 27 void TestingOAuth2TokenServiceConsumer::OnGetTokenSuccess( |
| 28 const OAuth2TokenService::Request* request, |
| 29 const std::string& token, |
| 30 const base::Time& expiration_date) { |
| 31 last_token_ = token; |
| 32 ++number_of_successful_tokens_; |
| 33 } |
| 34 |
| 35 void TestingOAuth2TokenServiceConsumer::OnGetTokenFailure( |
| 36 const OAuth2TokenService::Request* request, |
| 37 const GoogleServiceAuthError& error) { |
| 38 last_error_ = error; |
| 39 ++number_of_errors_; |
| 40 } |
OLD | NEW |