| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2010 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 #ifndef CHROME_SERVICE_GAIA_SERVICE_GAIA_AUTHENTICATOR_H_ |
| 6 #define CHROME_SERVICE_GAIA_SERVICE_GAIA_AUTHENTICATOR_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/ref_counted.h" |
| 11 #include "base/waitable_event.h" |
| 12 #include "chrome/common/net/url_fetcher.h" |
| 13 #include "chrome/common/net/gaia/gaia_authenticator.h" |
| 14 |
| 15 namespace base { |
| 16 class MessageLoopProxy; |
| 17 } |
| 18 |
| 19 // A GaiaAuthenticator implementation to be used in the service process (where |
| 20 // we cannot rely on the existence of a Profile) |
| 21 class ServiceGaiaAuthenticator |
| 22 : public base::RefCountedThreadSafe<ServiceGaiaAuthenticator>, |
| 23 public URLFetcher::Delegate, |
| 24 public gaia::GaiaAuthenticator { |
| 25 public: |
| 26 ServiceGaiaAuthenticator(const std::string& user_agent, |
| 27 const std::string& service_id, |
| 28 const std::string& gaia_url, |
| 29 base::MessageLoopProxy* io_message_loop_proxy); |
| 30 ~ServiceGaiaAuthenticator(); |
| 31 |
| 32 // URLFetcher::Delegate implementation. |
| 33 void OnURLFetchComplete(const URLFetcher *source, const GURL &url, |
| 34 const URLRequestStatus &status, int response_code, |
| 35 const ResponseCookies &cookies, |
| 36 const std::string &data); |
| 37 |
| 38 protected: |
| 39 // GaiaAuthenticator overrides. |
| 40 virtual bool Post(const GURL& url, const std::string& post_body, |
| 41 unsigned long* response_code, std::string* response_body); |
| 42 virtual int GetBackoffDelaySeconds(int current_backoff_delay); |
| 43 |
| 44 private: |
| 45 void DoPost(const GURL& post_url, const std::string& post_body); |
| 46 |
| 47 base::WaitableEvent http_post_completed_; |
| 48 scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_; |
| 49 int http_response_code_; |
| 50 std::string response_data_; |
| 51 scoped_ptr<URLFetcher> request_; |
| 52 |
| 53 DISALLOW_COPY_AND_ASSIGN(ServiceGaiaAuthenticator); |
| 54 }; |
| 55 |
| 56 #endif // CHROME_SERVICE_GAIA_SERVICE_GAIA_AUTHENTICATOR_H_ |
| 57 |
| OLD | NEW |