OLD | NEW |
1 // Copyright (c) 2011 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_COMMON_NET_GAIA_OAUTH2_REVOCATION_FETCHER_H_ | 5 #ifndef CHROME_COMMON_NET_GAIA_OAUTH2_REVOCATION_FETCHER_H_ |
6 #define CHROME_COMMON_NET_GAIA_OAUTH2_REVOCATION_FETCHER_H_ | 6 #define CHROME_COMMON_NET_GAIA_OAUTH2_REVOCATION_FETCHER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 | 45 |
46 // Starts the flow with the given parameters. | 46 // Starts the flow with the given parameters. |
47 // |access_token| should be an OAuth2 login scoped access token. | 47 // |access_token| should be an OAuth2 login scoped access token. |
48 void Start(const std::string& access_token, | 48 void Start(const std::string& access_token, |
49 const std::string& client_id, | 49 const std::string& client_id, |
50 const std::string& origin); | 50 const std::string& origin); |
51 | 51 |
52 void CancelRequest(); | 52 void CancelRequest(); |
53 | 53 |
54 // Implementation of content::URLFetcherDelegate | 54 // Implementation of content::URLFetcherDelegate |
55 virtual void OnURLFetchComplete(const content::URLFetcher* source) OVERRIDE; | 55 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
56 | 56 |
57 private: | 57 private: |
58 enum State { | 58 enum State { |
59 INITIAL, | 59 INITIAL, |
60 REVOCATION_STARTED, | 60 REVOCATION_STARTED, |
61 REVOCATION_DONE, | 61 REVOCATION_DONE, |
62 ERROR_STATE, | 62 ERROR_STATE, |
63 }; | 63 }; |
64 | 64 |
65 // Helper methods for the flow. | 65 // Helper methods for the flow. |
66 void StartRevocation(); | 66 void StartRevocation(); |
67 void EndRevocation(const content::URLFetcher* source); | 67 void EndRevocation(const net::URLFetcher* source); |
68 | 68 |
69 // Helper mehtods for reporting back results. | 69 // Helper mehtods for reporting back results. |
70 void OnRevocationSuccess(); | 70 void OnRevocationSuccess(); |
71 void OnRevocationFailure(const GoogleServiceAuthError& error); | 71 void OnRevocationFailure(const GoogleServiceAuthError& error); |
72 | 72 |
73 // Other helpers. | 73 // Other helpers. |
74 static GURL MakeRevocationUrl(); | 74 static GURL MakeRevocationUrl(); |
75 static std::string MakeRevocationHeader(const std::string& access_token); | 75 static std::string MakeRevocationHeader(const std::string& access_token); |
76 static std::string MakeRevocationBody(const std::string& client_id, | 76 static std::string MakeRevocationBody(const std::string& client_id, |
77 const std::string& origin); | 77 const std::string& origin); |
78 | 78 |
79 // State that is set during construction. | 79 // State that is set during construction. |
80 OAuth2RevocationConsumer* const consumer_; | 80 OAuth2RevocationConsumer* const consumer_; |
81 net::URLRequestContextGetter* const getter_; | 81 net::URLRequestContextGetter* const getter_; |
82 State state_; | 82 State state_; |
83 | 83 |
84 // While a fetch is in progress. | 84 // While a fetch is in progress. |
85 scoped_ptr<content::URLFetcher> fetcher_; | 85 scoped_ptr<content::URLFetcher> fetcher_; |
86 std::string access_token_; | 86 std::string access_token_; |
87 std::string client_id_; | 87 std::string client_id_; |
88 std::string origin_; | 88 std::string origin_; |
89 | 89 |
90 friend class OAuth2RevocationFetcherTest; | 90 friend class OAuth2RevocationFetcherTest; |
91 | 91 |
92 DISALLOW_COPY_AND_ASSIGN(OAuth2RevocationFetcher); | 92 DISALLOW_COPY_AND_ASSIGN(OAuth2RevocationFetcher); |
93 }; | 93 }; |
94 | 94 |
95 #endif // CHROME_COMMON_NET_GAIA_OAUTH2_REVOCATION_FETCHER_H_ | 95 #endif // CHROME_COMMON_NET_GAIA_OAUTH2_REVOCATION_FETCHER_H_ |
OLD | NEW |