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

Side by Side Diff: google_apis/gaia/oauth2_api_call_flow.h

Issue 2888053003: Network traffic annotation added to OAuth2ApiCallFlow and its subclasses. (Closed)
Patch Set: Created 3 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
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 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 <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "net/traffic_annotation/network_traffic_annotation.h"
12 #include "net/url_request/url_fetcher.h" 13 #include "net/url_request/url_fetcher.h"
13 #include "net/url_request/url_fetcher_delegate.h" 14 #include "net/url_request/url_fetcher_delegate.h"
14 #include "url/gurl.h" 15 #include "url/gurl.h"
15 16
16 namespace net { 17 namespace net {
17 class URLFetcher; 18 class URLFetcher;
18 class URLRequestContextGetter; 19 class URLRequestContextGetter;
19 } 20 }
20 21
21 // Base class for all classes that implement a flow to call OAuth2 enabled APIs, 22 // Base class for all classes that implement a flow to call OAuth2 enabled APIs,
22 // given an access token to the service. This class abstracts the basic steps 23 // given an access token to the service. This class abstracts the basic steps
23 // and exposes template methods for sub-classes to implement for API specific 24 // and exposes template methods for sub-classes to implement for API specific
24 // details. 25 // details.
25 class OAuth2ApiCallFlow : public net::URLFetcherDelegate { 26 class OAuth2ApiCallFlow : public net::URLFetcherDelegate {
26 public: 27 public:
27 OAuth2ApiCallFlow(); 28 OAuth2ApiCallFlow();
28 29
29 ~OAuth2ApiCallFlow() override; 30 ~OAuth2ApiCallFlow() override;
30 31
31 // Start the flow. 32 // Start the flow.
32 virtual void Start(net::URLRequestContextGetter* context, 33 virtual void Start(
33 const std::string& access_token); 34 net::URLRequestContextGetter* context,
35 const std::string& access_token,
36 const net::NetworkTrafficAnnotationTag& traffic_annotation);
Roger Tawa OOO till Jul 10th 2017/05/17 19:26:12 Curious why adding an arg to Start() is better tha
Ramin Halavati 2017/05/24 13:04:41 Done.
34 37
35 // net::URLFetcherDelegate implementation. 38 // net::URLFetcherDelegate implementation.
36 void OnURLFetchComplete(const net::URLFetcher* source) override; 39 void OnURLFetchComplete(const net::URLFetcher* source) override;
37 40
38 protected: 41 protected:
39 // Template methods for sub-classes. 42 // Template methods for sub-classes.
40 43
41 // Methods to help create the API request. 44 // Methods to help create the API request.
42 virtual GURL CreateApiCallUrl() = 0; 45 virtual GURL CreateApiCallUrl() = 0;
43 virtual std::string CreateApiCallBody() = 0; 46 virtual std::string CreateApiCallBody() = 0;
(...skipping 18 matching lines...) Expand all
62 API_CALL_DONE, 65 API_CALL_DONE,
63 ERROR_STATE 66 ERROR_STATE
64 }; 67 };
65 68
66 // Creates an instance of URLFetcher that does not send or save cookies. 69 // Creates an instance of URLFetcher that does not send or save cookies.
67 // Template method CreateApiCallUrl is used to get the URL. 70 // Template method CreateApiCallUrl is used to get the URL.
68 // Template method CreateApiCallBody is used to get the body. 71 // Template method CreateApiCallBody is used to get the body.
69 // The URLFether's method will be GET if body is empty, POST otherwise. 72 // The URLFether's method will be GET if body is empty, POST otherwise.
70 std::unique_ptr<net::URLFetcher> CreateURLFetcher( 73 std::unique_ptr<net::URLFetcher> CreateURLFetcher(
71 net::URLRequestContextGetter* context, 74 net::URLRequestContextGetter* context,
72 const std::string& access_token); 75 const std::string& access_token,
76 const net::NetworkTrafficAnnotationTag& traffic_annotation);
73 77
74 // Helper methods to implement the state machine for the flow. 78 // Helper methods to implement the state machine for the flow.
75 void BeginApiCall(); 79 void BeginApiCall();
76 void EndApiCall(const net::URLFetcher* source); 80 void EndApiCall(const net::URLFetcher* source);
77 81
78 State state_; 82 State state_;
79 std::unique_ptr<net::URLFetcher> url_fetcher_; 83 std::unique_ptr<net::URLFetcher> url_fetcher_;
80 84
81 DISALLOW_COPY_AND_ASSIGN(OAuth2ApiCallFlow); 85 DISALLOW_COPY_AND_ASSIGN(OAuth2ApiCallFlow);
82 }; 86 };
83 87
84 #endif // GOOGLE_APIS_GAIA_OAUTH2_API_CALL_FLOW_H_ 88 #endif // GOOGLE_APIS_GAIA_OAUTH2_API_CALL_FLOW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698