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

Side by Side Diff: chrome/browser/printing/cloud_print/gcd_api_flow_impl.h

Issue 2742763002: Clean up Cloud Print API flow code. (Closed)
Patch Set: Created 3 years, 9 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_BROWSER_PRINTING_CLOUD_PRINT_GCD_API_FLOW_IMPL_H_ 5 #ifndef CHROME_BROWSER_PRINTING_CLOUD_PRINT_GCD_API_FLOW_IMPL_H_
6 #define CHROME_BROWSER_PRINTING_CLOUD_PRINT_GCD_API_FLOW_IMPL_H_ 6 #define CHROME_BROWSER_PRINTING_CLOUD_PRINT_GCD_API_FLOW_IMPL_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "chrome/browser/printing/cloud_print/gcd_api_flow.h" 11 #include "chrome/browser/printing/cloud_print/gcd_api_flow.h"
12 #include "net/url_request/url_fetcher.h" 12 #include "net/url_request/url_fetcher.h"
13 #include "net/url_request/url_fetcher_delegate.h" 13 #include "net/url_request/url_fetcher_delegate.h"
14 14
15 namespace cloud_print { 15 namespace cloud_print {
16 16
17 namespace {
18 const char kCloudPrintOAuthHeaderFormat[] = "Authorization: Bearer %s";
19 }
20
21 class GCDApiFlowImpl : public GCDApiFlow, 17 class GCDApiFlowImpl : public GCDApiFlow,
22 public net::URLFetcherDelegate, 18 public net::URLFetcherDelegate,
23 public OAuth2TokenService::Consumer { 19 public OAuth2TokenService::Consumer {
24 public: 20 public:
25 // Create an OAuth2-based confirmation. 21 // Create an OAuth2-based confirmation.
26 GCDApiFlowImpl(net::URLRequestContextGetter* request_context, 22 GCDApiFlowImpl(net::URLRequestContextGetter* request_context,
27 OAuth2TokenService* token_service, 23 OAuth2TokenService* token_service,
28 const std::string& account_id); 24 const std::string& account_id);
29
30 ~GCDApiFlowImpl() override; 25 ~GCDApiFlowImpl() override;
31 26
27 // GCDApiFlow implementation:
32 void Start(std::unique_ptr<Request> request) override; 28 void Start(std::unique_ptr<Request> request) override;
33 29
34 // net::URLFetcherDelegate implementation: 30 // net::URLFetcherDelegate implementation:
35 void OnURLFetchComplete(const net::URLFetcher* source) override; 31 void OnURLFetchComplete(const net::URLFetcher* source) override;
36 32
37 // OAuth2TokenService::Consumer implementation: 33 // OAuth2TokenService::Consumer implementation:
38 void OnGetTokenSuccess(const OAuth2TokenService::Request* request, 34 void OnGetTokenSuccess(const OAuth2TokenService::Request* request,
39 const std::string& access_token, 35 const std::string& access_token,
40 const base::Time& expiration_time) override; 36 const base::Time& expiration_time) override;
41 void OnGetTokenFailure(const OAuth2TokenService::Request* request, 37 void OnGetTokenFailure(const OAuth2TokenService::Request* request,
42 const GoogleServiceAuthError& error) override; 38 const GoogleServiceAuthError& error) override;
43 39
44 private: 40 private:
45 void CreateRequest(const GURL& url); 41 void CreateRequest(const GURL& url);
46 42
47 std::unique_ptr<net::URLFetcher> url_fetcher_; 43 std::unique_ptr<net::URLFetcher> url_fetcher_;
48 std::unique_ptr<OAuth2TokenService::Request> oauth_request_; 44 std::unique_ptr<OAuth2TokenService::Request> oauth_request_;
49 scoped_refptr<net::URLRequestContextGetter> request_context_; 45 scoped_refptr<net::URLRequestContextGetter> request_context_;
50 OAuth2TokenService* token_service_; 46 OAuth2TokenService* token_service_;
51 std::string account_id_; 47 std::string account_id_;
52 std::unique_ptr<Request> request_; 48 std::unique_ptr<Request> request_;
53 49
54 DISALLOW_COPY_AND_ASSIGN(GCDApiFlowImpl); 50 DISALLOW_COPY_AND_ASSIGN(GCDApiFlowImpl);
55 }; 51 };
56 52
57 } // namespace cloud_print 53 } // namespace cloud_print
58 54
59 #endif // CHROME_BROWSER_PRINTING_CLOUD_PRINT_GCD_API_FLOW_IMPL_H_ 55 #endif // CHROME_BROWSER_PRINTING_CLOUD_PRINT_GCD_API_FLOW_IMPL_H_
OLDNEW
« no previous file with comments | « chrome/browser/printing/cloud_print/gcd_api_flow.cc ('k') | chrome/browser/printing/cloud_print/gcd_api_flow_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698