| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 RetryingTestingOAuth2TokenServiceConsumer( | 29 RetryingTestingOAuth2TokenServiceConsumer( |
| 30 OAuth2TokenService* oauth2_service, | 30 OAuth2TokenService* oauth2_service, |
| 31 const std::string& account_id) | 31 const std::string& account_id) |
| 32 : oauth2_service_(oauth2_service), | 32 : oauth2_service_(oauth2_service), |
| 33 account_id_(account_id) {} | 33 account_id_(account_id) {} |
| 34 ~RetryingTestingOAuth2TokenServiceConsumer() override {} | 34 ~RetryingTestingOAuth2TokenServiceConsumer() override {} |
| 35 | 35 |
| 36 void OnGetTokenFailure(const OAuth2TokenService::Request* request, | 36 void OnGetTokenFailure(const OAuth2TokenService::Request* request, |
| 37 const GoogleServiceAuthError& error) override { | 37 const GoogleServiceAuthError& error) override { |
| 38 TestingOAuth2TokenServiceConsumer::OnGetTokenFailure(request, error); | 38 TestingOAuth2TokenServiceConsumer::OnGetTokenFailure(request, error); |
| 39 request_.reset(oauth2_service_->StartRequest( | 39 request_ = oauth2_service_->StartRequest( |
| 40 account_id_, OAuth2TokenService::ScopeSet(), this).release()); | 40 account_id_, OAuth2TokenService::ScopeSet(), this); |
| 41 } | 41 } |
| 42 | 42 |
| 43 OAuth2TokenService* oauth2_service_; | 43 OAuth2TokenService* oauth2_service_; |
| 44 std::string account_id_; | 44 std::string account_id_; |
| 45 std::unique_ptr<OAuth2TokenService::Request> request_; | 45 std::unique_ptr<OAuth2TokenService::Request> request_; |
| 46 }; | 46 }; |
| 47 | 47 |
| 48 class TestOAuth2TokenService : public OAuth2TokenService { | 48 class TestOAuth2TokenService : public OAuth2TokenService { |
| 49 public: | 49 public: |
| 50 explicit TestOAuth2TokenService( | 50 explicit TestOAuth2TokenService( |
| (...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 662 fetcher = factory_.GetFetcherByID(0); | 662 fetcher = factory_.GetFetcherByID(0); |
| 663 // ASSERT_TRUE(fetcher); | 663 // ASSERT_TRUE(fetcher); |
| 664 fetcher->set_response_code(net::HTTP_OK); | 664 fetcher->set_response_code(net::HTTP_OK); |
| 665 fetcher->SetResponseString(GetValidTokenResponse("another token", 3600)); | 665 fetcher->SetResponseString(GetValidTokenResponse("another token", 3600)); |
| 666 fetcher->delegate()->OnURLFetchComplete(fetcher); | 666 fetcher->delegate()->OnURLFetchComplete(fetcher); |
| 667 EXPECT_EQ(2, consumer_.number_of_successful_tokens_); | 667 EXPECT_EQ(2, consumer_.number_of_successful_tokens_); |
| 668 EXPECT_EQ(0, consumer_.number_of_errors_); | 668 EXPECT_EQ(0, consumer_.number_of_errors_); |
| 669 EXPECT_EQ("another token", consumer_.last_token_); | 669 EXPECT_EQ("another token", consumer_.last_token_); |
| 670 EXPECT_EQ(1, (int)oauth2_service_->token_cache_.size()); | 670 EXPECT_EQ(1, (int)oauth2_service_->token_cache_.size()); |
| 671 } | 671 } |
| OLD | NEW |