Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(476)

Side by Side Diff: chrome/common/net/gaia/oauth2_revocation_fetcher.h

Issue 10392192: Remove content::URLFetcherDelegate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More cleanup Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
15 #include "content/public/common/url_fetcher_delegate.h"
16 #include "googleurl/src/gurl.h" 14 #include "googleurl/src/gurl.h"
15 #include "net/url_request/url_fetcher_delegate.h"
17 16
18 class OAuth2RevocationFetcherTest; 17 class OAuth2RevocationFetcherTest;
19 18
20 namespace net { 19 namespace net {
20 class URLFetcher;
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 10 matching lines...) Expand all
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<net::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_
OLDNEW
« no previous file with comments | « chrome/common/net/gaia/oauth2_mint_token_fetcher_unittest.cc ('k') | chrome/common/net/gaia/oauth2_revocation_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698