| 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_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" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "chrome/common/net/gaia/oauth2_revocation_consumer.h" | 13 #include "chrome/common/net/gaia/oauth2_revocation_consumer.h" |
| 14 #include "content/public/common/url_fetcher.h" | 14 #include "content/public/common/url_fetcher.h" |
| 15 #include "content/public/common/url_fetcher_delegate.h" | |
| 16 #include "googleurl/src/gurl.h" | 15 #include "googleurl/src/gurl.h" |
| 16 #include "net/url_request/url_fetcher_delegate.h" |
| 17 | 17 |
| 18 class OAuth2RevocationFetcherTest; | 18 class OAuth2RevocationFetcherTest; |
| 19 | 19 |
| 20 namespace net { | 20 namespace net { |
| 21 class URLRequestContextGetter; | 21 class URLRequestContextGetter; |
| 22 class URLRequestStatus; | 22 class URLRequestStatus; |
| 23 } | 23 } |
| 24 | 24 |
| 25 // Abstracts the details to perform OAuth2 grant revocation. | 25 // Abstracts the details to perform OAuth2 grant revocation. |
| 26 // | 26 // |
| 27 // This class should be used on a single thread, but it can be whichever thread | 27 // This class should be used on a single thread, but it can be whichever thread |
| 28 // that you like. | 28 // that you like. |
| 29 // Also, do not reuse the same instance. Once Start() is called, the instance | 29 // Also, do not reuse the same instance. Once Start() is called, the instance |
| 30 // should not be reused. | 30 // should not be reused. |
| 31 // | 31 // |
| 32 // Usage: | 32 // Usage: |
| 33 // * Create an instance with a consumer. | 33 // * Create an instance with a consumer. |
| 34 // * Call Start() | 34 // * Call Start() |
| 35 // * The consumer passed in the constructor will be called on the same | 35 // * The consumer passed in the constructor will be called on the same |
| 36 // thread Start was called with the results. | 36 // thread Start was called with the results. |
| 37 // | 37 // |
| 38 // This class can handle one request at a time. To parallelize requests, | 38 // This class can handle one request at a time. To parallelize requests, |
| 39 // create multiple instances. | 39 // create multiple instances. |
| 40 class OAuth2RevocationFetcher : public content::URLFetcherDelegate { | 40 class OAuth2RevocationFetcher : public net::URLFetcherDelegate { |
| 41 public: | 41 public: |
| 42 OAuth2RevocationFetcher(OAuth2RevocationConsumer* consumer, | 42 OAuth2RevocationFetcher(OAuth2RevocationConsumer* consumer, |
| 43 net::URLRequestContextGetter* getter); | 43 net::URLRequestContextGetter* getter); |
| 44 virtual ~OAuth2RevocationFetcher(); | 44 virtual ~OAuth2RevocationFetcher(); |
| 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 net::URLFetcherDelegate |
| 55 virtual void OnURLFetchComplete(const net::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 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 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 |