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 GOOGLE_APIS_GAIA_OAUTH2_API_CALL_FLOW_H_ | 5 #ifndef GOOGLE_APIS_GAIA_OAUTH2_API_CALL_FLOW_H_ |
6 #define GOOGLE_APIS_GAIA_OAUTH2_API_CALL_FLOW_H_ | 6 #define GOOGLE_APIS_GAIA_OAUTH2_API_CALL_FLOW_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 // Base class for all classes that implement a flow to call OAuth2 enabled APIs, | 25 // Base class for all classes that implement a flow to call OAuth2 enabled APIs, |
26 // given an access token to the service. This class abstracts the basic steps | 26 // given an access token to the service. This class abstracts the basic steps |
27 // and exposes template methods for sub-classes to implement for API specific | 27 // and exposes template methods for sub-classes to implement for API specific |
28 // details. | 28 // details. |
29 class OAuth2ApiCallFlow | 29 class OAuth2ApiCallFlow |
30 : public net::URLFetcherDelegate, | 30 : public net::URLFetcherDelegate, |
31 public OAuth2AccessTokenConsumer { | 31 public OAuth2AccessTokenConsumer { |
32 public: | 32 public: |
33 OAuth2ApiCallFlow(); | 33 OAuth2ApiCallFlow(); |
34 | 34 |
35 virtual ~OAuth2ApiCallFlow(); | 35 ~OAuth2ApiCallFlow() override; |
36 | 36 |
37 // Start the flow. | 37 // Start the flow. |
38 virtual void Start(net::URLRequestContextGetter* context, | 38 virtual void Start(net::URLRequestContextGetter* context, |
39 const std::string& access_token); | 39 const std::string& access_token); |
40 | 40 |
41 // net::URLFetcherDelegate implementation. | 41 // net::URLFetcherDelegate implementation. |
42 virtual void OnURLFetchComplete(const net::URLFetcher* source) override; | 42 void OnURLFetchComplete(const net::URLFetcher* source) override; |
43 | 43 |
44 protected: | 44 protected: |
45 // Template methods for sub-classes. | 45 // Template methods for sub-classes. |
46 | 46 |
47 // Methods to help create the API request. | 47 // Methods to help create the API request. |
48 virtual GURL CreateApiCallUrl() = 0; | 48 virtual GURL CreateApiCallUrl() = 0; |
49 virtual std::string CreateApiCallBody() = 0; | 49 virtual std::string CreateApiCallBody() = 0; |
50 virtual std::string CreateApiCallBodyContentType(); | 50 virtual std::string CreateApiCallBodyContentType(); |
51 | 51 |
52 // Sub-classes can expose an appropriate observer interface by implementing | 52 // Sub-classes can expose an appropriate observer interface by implementing |
(...skipping 23 matching lines...) Expand all Loading... |
76 void BeginApiCall(); | 76 void BeginApiCall(); |
77 void EndApiCall(const net::URLFetcher* source); | 77 void EndApiCall(const net::URLFetcher* source); |
78 | 78 |
79 State state_; | 79 State state_; |
80 scoped_ptr<net::URLFetcher> url_fetcher_; | 80 scoped_ptr<net::URLFetcher> url_fetcher_; |
81 | 81 |
82 DISALLOW_COPY_AND_ASSIGN(OAuth2ApiCallFlow); | 82 DISALLOW_COPY_AND_ASSIGN(OAuth2ApiCallFlow); |
83 }; | 83 }; |
84 | 84 |
85 #endif // GOOGLE_APIS_GAIA_OAUTH2_API_CALL_FLOW_H_ | 85 #endif // GOOGLE_APIS_GAIA_OAUTH2_API_CALL_FLOW_H_ |
OLD | NEW |