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