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

Side by Side Diff: blimp/client/core/session/identity_source.h

Issue 2406403003: Clean up Assignment Create in BlimpClientContextImpl. (Closed)
Patch Set: Addresses dtrainor's #8 comments. Created 4 years, 2 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 BLIMP_CLIENT_CORE_SESSION_IDENTITY_SOURCE_H_ 5 #ifndef BLIMP_CLIENT_CORE_SESSION_IDENTITY_SOURCE_H_
6 #define BLIMP_CLIENT_CORE_SESSION_IDENTITY_SOURCE_H_ 6 #define BLIMP_CLIENT_CORE_SESSION_IDENTITY_SOURCE_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "blimp/client/public/blimp_client_context_delegate.h" 13 #include "blimp/client/public/blimp_client_context_delegate.h"
14 #include "google_apis/gaia/identity_provider.h" 14 #include "google_apis/gaia/identity_provider.h"
15 #include "google_apis/gaia/oauth2_token_service.h" 15 #include "google_apis/gaia/oauth2_token_service.h"
16 16
17 namespace blimp { 17 namespace blimp {
18 namespace client { 18 namespace client {
19 19
20 // IdentitySource handles OAuth2 token request and forward user sign in state 20 // IdentitySource handles OAuth2 token request and forward user sign in state
21 // change to Blimp with ProfileIdentityProvider. 21 // change to Blimp with ProfileIdentityProvider.
22 class IdentitySource : public OAuth2TokenService::Consumer, 22 class IdentitySource : public OAuth2TokenService::Consumer,
23 public OAuth2TokenService::Observer, 23 public OAuth2TokenService::Observer,
24 public IdentityProvider::Observer { 24 public IdentityProvider::Observer {
25 public: 25 public:
26 typedef base::Callback<void(const std::string&)> TokenCallback; 26 using TokenCallback = base::Callback<void(const std::string&)>;
27 using TokenErrorCallback =
28 base::Callback<void(const GoogleServiceAuthError&)>;
27 29
28 explicit IdentitySource(BlimpClientContextDelegate* delegate, 30 explicit IdentitySource(std::unique_ptr<IdentityProvider> identity_provider,
31 TokenErrorCallback error_callback,
David Trainor- moved to gerrit 2016/10/25 03:14:27 const &?
CJ 2016/10/25 20:38:01 Done.
29 const TokenCallback& callback); 32 const TokenCallback& callback);
30 ~IdentitySource() override; 33 ~IdentitySource() override;
31 34
32 // Start Blimp authentication by requesting OAuth2 token from Google. 35 // Start Blimp authentication by requesting OAuth2 token from Google.
33 // Duplicate connect calls during token fetching will be ignored. 36 // Duplicate connect calls during token fetching will be ignored.
34 void Connect(); 37 void Connect();
35 38
36 // Add sign in state observer. 39 // Add sign in state observer.
37 void AddObserver(IdentityProvider::Observer* observer); 40 void AddObserver(IdentityProvider::Observer* observer);
38 41
(...skipping 17 matching lines...) Expand all
56 59
57 private: 60 private:
58 // Fetch OAuth token. 61 // Fetch OAuth token.
59 void FetchAuthToken(); 62 void FetchAuthToken();
60 63
61 // OAuth2 token request. The request is created when we start to fetch the 64 // OAuth2 token request. The request is created when we start to fetch the
62 // access token in OAuth2TokenService::StartRequest, and destroyed when 65 // access token in OAuth2TokenService::StartRequest, and destroyed when
63 // OAuth2TokenService::Consumer callback get called. 66 // OAuth2TokenService::Consumer callback get called.
64 std::unique_ptr<OAuth2TokenService::Request> token_request_; 67 std::unique_ptr<OAuth2TokenService::Request> token_request_;
65 68
69 TokenErrorCallback error_callback_;
70
66 // Callback after OAuth2 token is fetched. 71 // Callback after OAuth2 token is fetched.
67 TokenCallback token_callback_; 72 TokenCallback token_callback_;
68 73
69 // If we are fetching OAuth2 token. Connect call during token fetching will 74 // If we are fetching OAuth2 token. Connect call during token fetching will
70 // be ignored. 75 // be ignored.
71 bool is_fetching_token_; 76 bool is_fetching_token_;
72 77
73 // Account id of current active user, used during token request. 78 // Account id of current active user, used during token request.
74 std::string account_id_; 79 std::string account_id_;
75 80
76 // Current retry count due to request cancellation. 81 // Current retry count due to request cancellation.
77 int retry_times_; 82 int retry_times_;
78 83
79 BlimpClientContextDelegate* delegate_;
80
81 DISALLOW_COPY_AND_ASSIGN(IdentitySource); 84 DISALLOW_COPY_AND_ASSIGN(IdentitySource);
82 }; 85 };
83 86
84 } // namespace client 87 } // namespace client
85 } // namespace blimp 88 } // namespace blimp
86 89
87 #endif // BLIMP_CLIENT_CORE_SESSION_IDENTITY_SOURCE_H_ 90 #endif // BLIMP_CLIENT_CORE_SESSION_IDENTITY_SOURCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698