| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef REMOTING_TEST_ACCESS_TOKEN_FETCHER_H_ | 5 #ifndef REMOTING_TEST_ACCESS_TOKEN_FETCHER_H_ |
| 6 #define REMOTING_TEST_ACCESS_TOKEN_FETCHER_H_ | 6 #define REMOTING_TEST_ACCESS_TOKEN_FETCHER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "google_apis/gaia/gaia_oauth_client.h" | 13 #include "google_apis/gaia/gaia_oauth_client.h" |
| 14 | 14 |
| 15 namespace remoting { | 15 namespace remoting { |
| 16 namespace test { | 16 namespace test { |
| 17 | 17 |
| 18 // Supplied by the client for each request to GAIA and returns valid tokens on | 18 // Supplied by the client for each request to GAIA and returns valid tokens on |
| 19 // success or empty tokens on failure. | 19 // success or empty tokens on failure. |
| 20 typedef base::Callback<void( | 20 typedef base::Callback<void(const std::string& access_token, |
| 21 const std::string& access_token, | 21 const std::string& refresh_token)> |
| 22 const std::string& refresh_token)> AccessTokenCallback; | 22 AccessTokenCallback; |
| 23 | 23 |
| 24 // Retrieves an access token from either an authorization code or a refresh | 24 // Retrieves an access token from either an authorization code or a refresh |
| 25 // token. Destroying the AccessTokenFetcher while a request is outstanding will | 25 // token. Destroying the AccessTokenFetcher while a request is outstanding will |
| 26 // cancel the request. It is safe to delete the fetcher from within a completion | 26 // cancel the request. It is safe to delete the fetcher from within a completion |
| 27 // callback. Must be used from a thread running an IO message loop. | 27 // callback. Must be used from a thread running an IO message loop. |
| 28 // The public methods are virtual to allow for mocking and fakes. | 28 // The public methods are virtual to allow for mocking and fakes. |
| 29 class AccessTokenFetcher : public gaia::GaiaOAuthClient::Delegate { | 29 class AccessTokenFetcher : public gaia::GaiaOAuthClient::Delegate { |
| 30 public: | 30 public: |
| 31 AccessTokenFetcher(); | 31 AccessTokenFetcher(); |
| 32 ~AccessTokenFetcher() override; | 32 ~AccessTokenFetcher() override; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 // Used to make token requests to GAIA. | 79 // Used to make token requests to GAIA. |
| 80 scoped_ptr<gaia::GaiaOAuthClient> auth_client_; | 80 scoped_ptr<gaia::GaiaOAuthClient> auth_client_; |
| 81 | 81 |
| 82 DISALLOW_COPY_AND_ASSIGN(AccessTokenFetcher); | 82 DISALLOW_COPY_AND_ASSIGN(AccessTokenFetcher); |
| 83 }; | 83 }; |
| 84 | 84 |
| 85 } // namespace test | 85 } // namespace test |
| 86 } // namespace remoting | 86 } // namespace remoting |
| 87 | 87 |
| 88 #endif // REMOTING_TEST_ACCESS_TOKEN_FETCHER_H_ | 88 #endif // REMOTING_TEST_ACCESS_TOKEN_FETCHER_H_ |
| OLD | NEW |