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

Issue 9937004: Create an abstract flow class that abstracts the following logical steps of calling an OAuth2 enabl… (Closed)

Created:
8 years, 8 months ago by Munjal (Google)
Modified:
8 years, 8 months ago
CC:
chromium-reviews, cbentzel+watch_chromium.org, darin-cc_chromium.org, jstritar, msw
Visibility:
Public.

Description

Create an abstract flow class that abstracts the following logical steps of calling an OAuth2 enabled API: - Try existing access token to call the API. - If that does not work, generate a new one. - Try the new access token This abstract class should be used by any code that calls OAuth2 APIs. Examples: - Getting profile picture - Cloud print - App notifications Future CLs coming to replace existing duplicate code in individual places to use this class. Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=129970

Patch Set 1 #

Total comments: 11

Patch Set 2 : #

Total comments: 2

Patch Set 3 : #

Total comments: 40
Unified diffs Side-by-side diffs Delta from patch set Stats (+544 lines, -0 lines) Patch
M chrome/chrome_common.gypi View 1 2 1 chunk +2 lines, -0 lines 0 comments Download
M chrome/chrome_tests.gypi View 1 2 1 chunk +1 line, -0 lines 0 comments Download
A chrome/common/net/gaia/oauth2_api_call_flow.h View 1 2 1 chunk +126 lines, -0 lines 20 comments Download
A chrome/common/net/gaia/oauth2_api_call_flow.cc View 1 chunk +152 lines, -0 lines 12 comments Download
chrome/common/net/gaia/oauth2_api_call_flow_unittest.cc View 1 chunk +263 lines, -0 lines 8 comments Download

Messages

Total messages: 11 (0 generated)
Munjal (Google)
8 years, 8 months ago (2012-03-30 00:44:09 UTC) #1
sail
Hi Munjal, I like the overall design. Just one suggestion. Could we minimize the number ...
8 years, 8 months ago (2012-03-30 17:41:42 UTC) #2
Munjal (Google)
https://chromiumcodereview.appspot.com/9937004/diff/1/chrome/common/net/gaia/oauth2_api_call_flow.h File chrome/common/net/gaia/oauth2_api_call_flow.h (right): https://chromiumcodereview.appspot.com/9937004/diff/1/chrome/common/net/gaia/oauth2_api_call_flow.h#newcode56 chrome/common/net/gaia/oauth2_api_call_flow.h:56: virtual void OnGetTokenSuccess(const std::string& access_token); On 2012/03/30 17:41:42, sail ...
8 years, 8 months ago (2012-03-30 18:05:41 UTC) #3
sail
https://chromiumcodereview.appspot.com/9937004/diff/1/chrome/common/net/gaia/oauth2_api_call_flow.h File chrome/common/net/gaia/oauth2_api_call_flow.h (right): https://chromiumcodereview.appspot.com/9937004/diff/1/chrome/common/net/gaia/oauth2_api_call_flow.h#newcode56 chrome/common/net/gaia/oauth2_api_call_flow.h:56: virtual void OnGetTokenSuccess(const std::string& access_token); On 2012/03/30 18:05:41, munjal ...
8 years, 8 months ago (2012-03-30 18:08:56 UTC) #4
Munjal (Google)
https://chromiumcodereview.appspot.com/9937004/diff/1/chrome/common/net/gaia/oauth2_api_call_flow.h File chrome/common/net/gaia/oauth2_api_call_flow.h (right): https://chromiumcodereview.appspot.com/9937004/diff/1/chrome/common/net/gaia/oauth2_api_call_flow.h#newcode56 chrome/common/net/gaia/oauth2_api_call_flow.h:56: virtual void OnGetTokenSuccess(const std::string& access_token); On 2012/03/30 18:08:56, sail ...
8 years, 8 months ago (2012-03-30 19:01:28 UTC) #5
sail
LGTM! Can't wait to start using this!
8 years, 8 months ago (2012-03-30 19:08:18 UTC) #6
asargent_no_longer_on_chrome
LGTM https://chromiumcodereview.appspot.com/9937004/diff/4003/chrome/common/net/gaia/oauth2_api_call_flow.h File chrome/common/net/gaia/oauth2_api_call_flow.h (right): https://chromiumcodereview.appspot.com/9937004/diff/4003/chrome/common/net/gaia/oauth2_api_call_flow.h#newcode28 chrome/common/net/gaia/oauth2_api_call_flow.h:28: // Given: refresh token, access token, list of ...
8 years, 8 months ago (2012-03-30 20:15:52 UTC) #7
Munjal (Google)
https://chromiumcodereview.appspot.com/9937004/diff/4003/chrome/common/net/gaia/oauth2_api_call_flow.h File chrome/common/net/gaia/oauth2_api_call_flow.h (right): https://chromiumcodereview.appspot.com/9937004/diff/4003/chrome/common/net/gaia/oauth2_api_call_flow.h#newcode28 chrome/common/net/gaia/oauth2_api_call_flow.h:28: // Given: refresh token, access token, list of scopes ...
8 years, 8 months ago (2012-03-30 20:30:13 UTC) #8
Ryan Sleevi
drive by typo nits: https://chromiumcodereview.appspot.com/9937004/diff/5003/chrome/common/net/gaia/oauth2_api_call_flow.h File chrome/common/net/gaia/oauth2_api_call_flow.h (right): https://chromiumcodereview.appspot.com/9937004/diff/5003/chrome/common/net/gaia/oauth2_api_call_flow.h#newcode96 chrome/common/net/gaia/oauth2_api_call_flow.h:96: // Helper to create an ...
8 years, 8 months ago (2012-03-30 22:54:17 UTC) #9
msw
Interesting, I'm curious to see how much this simplifies the code of its clients. I'll ...
8 years, 8 months ago (2012-03-30 23:56:32 UTC) #10
Munjal (Google)
8 years, 8 months ago (2012-04-04 19:24:38 UTC) #11
Comments addressed in
https://chromiumcodereview.appspot.com/9982015

Please take a look.

https://chromiumcodereview.appspot.com/9937004/diff/5003/chrome/common/net/ga...
File chrome/common/net/gaia/oauth2_api_call_flow.cc (right):

https://chromiumcodereview.appspot.com/9937004/diff/5003/chrome/common/net/ga...
chrome/common/net/gaia/oauth2_api_call_flow.cc:18: using content::URLFetcher;
On 2012/03/30 23:56:32, msw wrote:
> The Google C++ style guide discourages use of 'using'.
> (here through line 22)

I thought that using is fine in .cc files. Not in .h files.

https://chromiumcodereview.appspot.com/9937004/diff/5003/chrome/common/net/ga...
chrome/common/net/gaia/oauth2_api_call_flow.cc:37:
OAuth2ApiCallFlow::~OAuth2ApiCallFlow() { }
On 2012/03/30 23:56:32, msw wrote:
> The Google C++ style guide says "No spaces inside empty braces."

Done.

https://chromiumcodereview.appspot.com/9937004/diff/5003/chrome/common/net/ga...
chrome/common/net/gaia/oauth2_api_call_flow.cc:49: return;
On 2012/03/30 23:56:32, msw wrote:
> nit: either return here and move the else-case to top level code or drop the
> superfluous return statement.

Done.

https://chromiumcodereview.appspot.com/9937004/diff/5003/chrome/common/net/ga...
chrome/common/net/gaia/oauth2_api_call_flow.cc:64:
ProcessApiCallFailure(source);
On 2012/03/30 23:56:32, msw wrote:
> Should you set "state_ = ERROR_STATE;"?

Done.

https://chromiumcodereview.appspot.com/9937004/diff/5003/chrome/common/net/ga...
chrome/common/net/gaia/oauth2_api_call_flow.cc:73:
ProcessApiCallFailure(source);
On 2012/03/30 23:56:32, msw wrote:
> Should you set "state_ = ERROR_STATE;"?

Done.

https://chromiumcodereview.appspot.com/9937004/diff/5003/chrome/common/net/ga...
chrome/common/net/gaia/oauth2_api_call_flow.cc:81:
ProcessApiCallFailure(source);
On 2012/03/30 23:56:32, msw wrote:
> Should you set "state_ = ERROR_STATE;"?

Done.

https://chromiumcodereview.appspot.com/9937004/diff/5003/chrome/common/net/ga...
File chrome/common/net/gaia/oauth2_api_call_flow.h (right):

https://chromiumcodereview.appspot.com/9937004/diff/5003/chrome/common/net/ga...
chrome/common/net/gaia/oauth2_api_call_flow.h:25: // Base calss for all classes
that implement a flow to call OAuth2
On 2012/03/30 23:56:32, msw wrote:
> nit spelling: "class".

Done.

https://chromiumcodereview.appspot.com/9937004/diff/5003/chrome/common/net/ga...
chrome/common/net/gaia/oauth2_api_call_flow.h:42: // Note that access_token can
be empty. In that case, the flow will skip
On 2012/03/30 23:56:32, msw wrote:
> optional nit: vertical bars around |access_token|.

Done.

https://chromiumcodereview.appspot.com/9937004/diff/5003/chrome/common/net/ga...
chrome/common/net/gaia/oauth2_api_call_flow.h:69: // Sub-classes can expose
appropriate observer interface by implementing
On 2012/03/30 23:56:32, msw wrote:
> nit grammar: "can expose *an* appropriate".

Done.

https://chromiumcodereview.appspot.com/9937004/diff/5003/chrome/common/net/ga...
chrome/common/net/gaia/oauth2_api_call_flow.h:81: // The steps this class
performs are:
On 2012/03/30 23:56:32, msw wrote:
> This is a duplicated but less informative version of the comments at lines
> 28-33. Please remove or relate these steps to the State enum type/values.

Done.

https://chromiumcodereview.appspot.com/9937004/diff/5003/chrome/common/net/ga...
chrome/common/net/gaia/oauth2_api_call_flow.h:96: // Helper to create an
instnace of access token fetcher.
On 2012/03/30 22:54:17, Ryan Sleevi wrote:
> nit typo: instnace -> instance

Done.

https://chromiumcodereview.appspot.com/9937004/diff/5003/chrome/common/net/ga...
chrome/common/net/gaia/oauth2_api_call_flow.h:98: virtual
OAuth2AccessTokenFetcher* CreateAccessTokenFetcher();
On 2012/03/30 23:56:32, msw wrote:
> nit: Mention that this is virtual just for unit test mocking.

Done.

https://chromiumcodereview.appspot.com/9937004/diff/5003/chrome/common/net/ga...
chrome/common/net/gaia/oauth2_api_call_flow.h:101: // The URLFether's method
will be GET if body is empty, POST otherwise.
On 2012/03/30 23:56:32, msw wrote:
> nit: perhaps rephrase or mention that "body" indicates the value returned by
the
> pure virtual CreateApiCallBody.

Done.

https://chromiumcodereview.appspot.com/9937004/diff/5003/chrome/common/net/ga...
chrome/common/net/gaia/oauth2_api_call_flow.h:103: virtual content::URLFetcher*
CreateURLFetcher();
On 2012/03/30 23:56:32, msw wrote:
> nit: Mention that this is virtual just for unit test mocking.

Done.

https://chromiumcodereview.appspot.com/9937004/diff/5003/chrome/common/net/ga...
chrome/common/net/gaia/oauth2_api_call_flow.h:105: // Helper methods to
implement the state machien for the flow.
On 2012/03/30 22:54:17, Ryan Sleevi wrote:
> nit typo: machien -> machine

Done.

https://chromiumcodereview.appspot.com/9937004/diff/5003/chrome/common/net/ga...
chrome/common/net/gaia/oauth2_api_call_flow.h:117: // Whether we have already
tried minting access token once.
On 2012/03/30 22:54:17, Ryan Sleevi wrote:
> nit grammar: minting access token once. -> minting an access token.

Done.

https://chromiumcodereview.appspot.com/9937004/diff/5003/chrome/common/net/ga...
File chrome/common/net/gaia/oauth2_api_call_flow_unittest.cc (right):

https://chromiumcodereview.appspot.com/9937004/diff/5003/chrome/common/net/ga...
chrome/common/net/gaia/oauth2_api_call_flow_unittest.cc:27: using
content::URLFetcher;
On 2012/03/30 23:56:32, msw wrote:
> nit: using (i think this is usually ok in test files)

Done.

https://chromiumcodereview.appspot.com/9937004/diff/5003/chrome/common/net/ga...
chrome/common/net/gaia/oauth2_api_call_flow_unittest.cc:35: static GURL
CreateApiUrl() {
On 2012/03/30 23:56:32, msw wrote:
> nit: add a blank line above.

Done.

https://chromiumcodereview.appspot.com/9937004/diff/5003/chrome/common/net/ga...
chrome/common/net/gaia/oauth2_api_call_flow_unittest.cc:45: }
On 2012/03/30 23:56:32, msw wrote:
> nit: "}  // namespace" and add a blank line above.

Done.

https://chromiumcodereview.appspot.com/9937004/diff/5003/chrome/common/net/ga...
chrome/common/net/gaia/oauth2_api_call_flow_unittest.cc:97: //
MOCK_METHOD0(CreateURLFetcher, URLFetcher* ());
On 2012/03/30 23:56:32, msw wrote:
> Did you intend to remove this?

Done.

Powered by Google App Engine
This is Rietveld 408576698