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

Side by Side Diff: chrome/common/net/gaia/oauth2_api_call_flow.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_API_CALL_FLOW_H_ 5 #ifndef CHROME_COMMON_NET_GAIA_OAUTH2_API_CALL_FLOW_H_
6 #define CHROME_COMMON_NET_GAIA_OAUTH2_API_CALL_FLOW_H_ 6 #define CHROME_COMMON_NET_GAIA_OAUTH2_API_CALL_FLOW_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 virtual ~OAuth2ApiCallFlow(); 50 virtual ~OAuth2ApiCallFlow();
51 51
52 // Start the flow. 52 // Start the flow.
53 virtual void Start(); 53 virtual void Start();
54 54
55 // OAuth2AccessTokenFetcher implementation. 55 // OAuth2AccessTokenFetcher implementation.
56 virtual void OnGetTokenSuccess(const std::string& access_token) OVERRIDE; 56 virtual void OnGetTokenSuccess(const std::string& access_token) OVERRIDE;
57 virtual void OnGetTokenFailure(const GoogleServiceAuthError& error) OVERRIDE; 57 virtual void OnGetTokenFailure(const GoogleServiceAuthError& error) OVERRIDE;
58 58
59 // content::URLFetcherDelegate implementation. 59 // content::URLFetcherDelegate implementation.
60 virtual void OnURLFetchComplete(const content::URLFetcher* source) OVERRIDE; 60 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
61 61
62 protected: 62 protected:
63 // Template methods for sub-classes. 63 // Template methods for sub-classes.
64 64
65 // Methods to help create HTTP request. 65 // Methods to help create HTTP request.
66 virtual GURL CreateApiCallUrl() = 0; 66 virtual GURL CreateApiCallUrl() = 0;
67 virtual std::string CreateApiCallBody() = 0; 67 virtual std::string CreateApiCallBody() = 0;
68 68
69 // Sub-classes can expose an appropriate observer interface by implementing 69 // Sub-classes can expose an appropriate observer interface by implementing
70 // these template methods. 70 // these template methods.
71 // Called when the API call finished successfully. 71 // Called when the API call finished successfully.
72 virtual void ProcessApiCallSuccess(const content::URLFetcher* source) = 0; 72 virtual void ProcessApiCallSuccess(const net::URLFetcher* source) = 0;
73 // Called when the API call failed. 73 // Called when the API call failed.
74 virtual void ProcessApiCallFailure(const content::URLFetcher* source) = 0; 74 virtual void ProcessApiCallFailure(const net::URLFetcher* source) = 0;
75 // Called when a new access token is generated. 75 // Called when a new access token is generated.
76 virtual void ProcessNewAccessToken(const std::string& access_token) = 0; 76 virtual void ProcessNewAccessToken(const std::string& access_token) = 0;
77 virtual void ProcessMintAccessTokenFailure( 77 virtual void ProcessMintAccessTokenFailure(
78 const GoogleServiceAuthError& error) = 0; 78 const GoogleServiceAuthError& error) = 0;
79 79
80 private: 80 private:
81 enum State { 81 enum State {
82 INITIAL, 82 INITIAL,
83 API_CALL_STARTED, 83 API_CALL_STARTED,
84 API_CALL_DONE, 84 API_CALL_DONE,
(...skipping 13 matching lines...) Expand all
98 // Creates an instance of URLFetcher that does not send or save cookies. 98 // Creates an instance of URLFetcher that does not send or save cookies.
99 // Template method CreateApiCallUrl is used to get the URL. 99 // Template method CreateApiCallUrl is used to get the URL.
100 // Template method CreateApiCallBody is used to get the body. 100 // Template method CreateApiCallBody is used to get the body.
101 // The URLFether's method will be GET if body is empty, POST otherwise. 101 // The URLFether's method will be GET if body is empty, POST otherwise.
102 // Caller owns the returned instance. 102 // Caller owns the returned instance.
103 // Note that this is virtual since it is mocked during unit testing. 103 // Note that this is virtual since it is mocked during unit testing.
104 virtual content::URLFetcher* CreateURLFetcher(); 104 virtual content::URLFetcher* CreateURLFetcher();
105 105
106 // Helper methods to implement the state machine for the flow. 106 // Helper methods to implement the state machine for the flow.
107 void BeginApiCall(); 107 void BeginApiCall();
108 void EndApiCall(const content::URLFetcher* source); 108 void EndApiCall(const net::URLFetcher* source);
109 void BeginMintAccessToken(); 109 void BeginMintAccessToken();
110 void EndMintAccessToken(const GoogleServiceAuthError* error); 110 void EndMintAccessToken(const GoogleServiceAuthError* error);
111 111
112 net::URLRequestContextGetter* context_; 112 net::URLRequestContextGetter* context_;
113 std::string refresh_token_; 113 std::string refresh_token_;
114 std::string access_token_; 114 std::string access_token_;
115 std::vector<std::string> scopes_; 115 std::vector<std::string> scopes_;
116 116
117 State state_; 117 State state_;
118 // Whether we have already tried minting an access token once. 118 // Whether we have already tried minting an access token once.
119 bool tried_mint_access_token_; 119 bool tried_mint_access_token_;
120 120
121 scoped_ptr<content::URLFetcher> url_fetcher_; 121 scoped_ptr<content::URLFetcher> url_fetcher_;
122 scoped_ptr<OAuth2AccessTokenFetcher> oauth2_access_token_fetcher_; 122 scoped_ptr<OAuth2AccessTokenFetcher> oauth2_access_token_fetcher_;
123 123
124 DISALLOW_COPY_AND_ASSIGN(OAuth2ApiCallFlow); 124 DISALLOW_COPY_AND_ASSIGN(OAuth2ApiCallFlow);
125 }; 125 };
126 126
127 #endif // CHROME_COMMON_NET_GAIA_OAUTH2_API_CALL_FLOW_H_ 127 #endif // CHROME_COMMON_NET_GAIA_OAUTH2_API_CALL_FLOW_H_
OLDNEW
« no previous file with comments | « chrome/common/net/gaia/oauth2_access_token_fetcher.cc ('k') | chrome/common/net/gaia/oauth2_api_call_flow.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698