| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/common/net/gaia/gaia_oauth_client.h" | 5 #include "chrome/common/net/gaia/gaia_oauth_client.h" |
| 6 | 6 |
| 7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 : public base::RefCountedThreadSafe<GaiaOAuthClient::Core>, | 27 : public base::RefCountedThreadSafe<GaiaOAuthClient::Core>, |
| 28 public content::URLFetcherDelegate { | 28 public content::URLFetcherDelegate { |
| 29 public: | 29 public: |
| 30 Core(const std::string& gaia_url, | 30 Core(const std::string& gaia_url, |
| 31 net::URLRequestContextGetter* request_context_getter) | 31 net::URLRequestContextGetter* request_context_getter) |
| 32 : gaia_url_(gaia_url), | 32 : gaia_url_(gaia_url), |
| 33 num_retries_(0), | 33 num_retries_(0), |
| 34 request_context_getter_(request_context_getter), | 34 request_context_getter_(request_context_getter), |
| 35 delegate_(NULL) {} | 35 delegate_(NULL) {} |
| 36 | 36 |
| 37 virtual ~Core() { } | |
| 38 | |
| 39 void GetTokensFromAuthCode(const OAuthClientInfo& oauth_client_info, | 37 void GetTokensFromAuthCode(const OAuthClientInfo& oauth_client_info, |
| 40 const std::string& auth_code, | 38 const std::string& auth_code, |
| 41 int max_retries, | 39 int max_retries, |
| 42 GaiaOAuthClient::Delegate* delegate); | 40 GaiaOAuthClient::Delegate* delegate); |
| 43 void RefreshToken(const OAuthClientInfo& oauth_client_info, | 41 void RefreshToken(const OAuthClientInfo& oauth_client_info, |
| 44 const std::string& refresh_token, | 42 const std::string& refresh_token, |
| 45 int max_retries, | 43 int max_retries, |
| 46 GaiaOAuthClient::Delegate* delegate); | 44 GaiaOAuthClient::Delegate* delegate); |
| 47 | 45 |
| 48 // content::URLFetcherDelegate implementation. | 46 // content::URLFetcherDelegate implementation. |
| 49 virtual void OnURLFetchComplete(const content::URLFetcher* source); | 47 virtual void OnURLFetchComplete(const content::URLFetcher* source); |
| 50 | 48 |
| 51 private: | 49 private: |
| 50 friend class base::RefCountedThreadSafe<Core>; |
| 51 virtual ~Core() {} |
| 52 |
| 52 void MakeGaiaRequest(std::string post_body, | 53 void MakeGaiaRequest(std::string post_body, |
| 53 int max_retries, | 54 int max_retries, |
| 54 GaiaOAuthClient::Delegate* delegate); | 55 GaiaOAuthClient::Delegate* delegate); |
| 55 void HandleResponse(const content::URLFetcher* source, | 56 void HandleResponse(const content::URLFetcher* source, |
| 56 bool* should_retry_request); | 57 bool* should_retry_request); |
| 57 | 58 |
| 58 GURL gaia_url_; | 59 GURL gaia_url_; |
| 59 int num_retries_; | 60 int num_retries_; |
| 60 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; | 61 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; |
| 61 GaiaOAuthClient::Delegate* delegate_; | 62 GaiaOAuthClient::Delegate* delegate_; |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 const std::string& refresh_token, | 199 const std::string& refresh_token, |
| 199 int max_retries, | 200 int max_retries, |
| 200 Delegate* delegate) { | 201 Delegate* delegate) { |
| 201 return core_->RefreshToken(oauth_client_info, | 202 return core_->RefreshToken(oauth_client_info, |
| 202 refresh_token, | 203 refresh_token, |
| 203 max_retries, | 204 max_retries, |
| 204 delegate); | 205 delegate); |
| 205 } | 206 } |
| 206 | 207 |
| 207 } // namespace gaia | 208 } // namespace gaia |
| OLD | NEW |