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

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

Issue 10386063: Move URLFetcherDelegate to net/ and split URLFetcher between net/ and content/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync to head, fix win component build 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_MINT_TOKEN_FETCHER_H_ 5 #ifndef CHROME_COMMON_NET_GAIA_OAUTH2_MINT_TOKEN_FETCHER_H_
6 #define CHROME_COMMON_NET_GAIA_OAUTH2_MINT_TOKEN_FETCHER_H_ 6 #define CHROME_COMMON_NET_GAIA_OAUTH2_MINT_TOKEN_FETCHER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 48
49 // Start the flow. 49 // Start the flow.
50 virtual void Start(const std::string& oauth_login_access_token, 50 virtual void Start(const std::string& oauth_login_access_token,
51 const std::string& client_id, 51 const std::string& client_id,
52 const std::vector<std::string>& scopes, 52 const std::vector<std::string>& scopes,
53 const std::string& origin); 53 const std::string& origin);
54 54
55 void CancelRequest(); 55 void CancelRequest();
56 56
57 // Implementation of content::URLFetcherDelegate 57 // Implementation of content::URLFetcherDelegate
58 virtual void OnURLFetchComplete(const content::URLFetcher* source) OVERRIDE; 58 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
59 59
60 private: 60 private:
61 enum State { 61 enum State {
62 INITIAL, 62 INITIAL,
63 MINT_TOKEN_STARTED, 63 MINT_TOKEN_STARTED,
64 MINT_TOKEN_DONE, 64 MINT_TOKEN_DONE,
65 ERROR_STATE, 65 ERROR_STATE,
66 }; 66 };
67 67
68 // Helper methods for the flow. 68 // Helper methods for the flow.
69 void StartMintToken(); 69 void StartMintToken();
70 void EndMintToken(const content::URLFetcher* source); 70 void EndMintToken(const net::URLFetcher* source);
71 71
72 // Helper methods for reporting back results. 72 // Helper methods for reporting back results.
73 void OnMintTokenSuccess(const std::string& access_token); 73 void OnMintTokenSuccess(const std::string& access_token);
74 void OnMintTokenFailure(const GoogleServiceAuthError& error); 74 void OnMintTokenFailure(const GoogleServiceAuthError& error);
75 75
76 // Other helpers. 76 // Other helpers.
77 static GURL MakeMintTokenUrl(); 77 static GURL MakeMintTokenUrl();
78 static std::string MakeMintTokenHeader(const std::string& access_token); 78 static std::string MakeMintTokenHeader(const std::string& access_token);
79 static std::string MakeMintTokenBody(const std::string& client_id, 79 static std::string MakeMintTokenBody(const std::string& client_id,
80 const std::vector<std::string>& scopes, 80 const std::vector<std::string>& scopes,
81 const std::string& origin); 81 const std::string& origin);
82 static bool ParseMintTokenResponse(const content::URLFetcher* source, 82 static bool ParseMintTokenResponse(const net::URLFetcher* source,
83 std::string* access_token); 83 std::string* access_token);
84 84
85 // State that is set during construction. 85 // State that is set during construction.
86 OAuth2MintTokenConsumer* const consumer_; 86 OAuth2MintTokenConsumer* const consumer_;
87 net::URLRequestContextGetter* const getter_; 87 net::URLRequestContextGetter* const getter_;
88 std::string source_; 88 std::string source_;
89 State state_; 89 State state_;
90 90
91 // While a fetch is in progress. 91 // While a fetch is in progress.
92 scoped_ptr<content::URLFetcher> fetcher_; 92 scoped_ptr<content::URLFetcher> fetcher_;
93 std::string oauth_login_access_token_; 93 std::string oauth_login_access_token_;
94 std::string client_id_; 94 std::string client_id_;
95 std::vector<std::string> scopes_; 95 std::vector<std::string> scopes_;
96 std::string origin_; 96 std::string origin_;
97 97
98 friend class OAuth2MintTokenFetcherTest; 98 friend class OAuth2MintTokenFetcherTest;
99 FRIEND_TEST_ALL_PREFIXES(OAuth2MintTokenFetcherTest, 99 FRIEND_TEST_ALL_PREFIXES(OAuth2MintTokenFetcherTest,
100 ParseMintTokenResponse); 100 ParseMintTokenResponse);
101 101
102 DISALLOW_COPY_AND_ASSIGN(OAuth2MintTokenFetcher); 102 DISALLOW_COPY_AND_ASSIGN(OAuth2MintTokenFetcher);
103 }; 103 };
104 104
105 #endif // CHROME_COMMON_NET_GAIA_OAUTH2_MINT_TOKEN_FETCHER_H_ 105 #endif // CHROME_COMMON_NET_GAIA_OAUTH2_MINT_TOKEN_FETCHER_H_
OLDNEW
« no previous file with comments | « chrome/common/net/gaia/oauth2_api_call_flow_unittest.cc ('k') | chrome/common/net/gaia/oauth2_mint_token_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698