OLD | NEW |
---|---|
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_SERVICES_GCM_GCM_ACCOUNT_TRACKER_H_ | 5 #ifndef CHROME_BROWSER_SERVICES_GCM_GCM_ACCOUNT_TRACKER_H_ |
6 #define CHROME_BROWSER_SERVICES_GCM_GCM_ACCOUNT_TRACKER_H_ | 6 #define CHROME_BROWSER_SERVICES_GCM_GCM_ACCOUNT_TRACKER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/memory/scoped_vector.h" | 11 #include "base/memory/scoped_vector.h" |
12 #include "components/gcm_driver/gcm_client.h" | |
fgorski
2014/07/15 17:46:37
remove
fgorski
2014/07/17 03:35:34
Done.
| |
12 #include "google_apis/gaia/account_tracker.h" | 13 #include "google_apis/gaia/account_tracker.h" |
13 #include "google_apis/gaia/oauth2_token_service.h" | 14 #include "google_apis/gaia/oauth2_token_service.h" |
14 | 15 |
15 namespace gcm { | 16 namespace gcm { |
16 | 17 |
17 // Class for reporting back which accounts are signed into. It is only meant to | 18 // Class for reporting back which accounts are signed into. It is only meant to |
18 // be used when the user is signed into sync. | 19 // be used when the user is signed into sync. |
19 class GCMAccountTracker : public gaia::AccountTracker::Observer, | 20 class GCMAccountTracker : public gaia::AccountTracker::Observer, |
20 public OAuth2TokenService::Consumer { | 21 public OAuth2TokenService::Consumer { |
21 public: | 22 public: |
(...skipping 21 matching lines...) Expand all Loading... | |
43 | 44 |
44 // Email address of the tracked account. | 45 // Email address of the tracked account. |
45 std::string email; | 46 std::string email; |
46 // OAuth2 access token, when |state| is TOKEN_PRESENT. | 47 // OAuth2 access token, when |state| is TOKEN_PRESENT. |
47 std::string access_token; | 48 std::string access_token; |
48 // Status of the token fetching. | 49 // Status of the token fetching. |
49 AccountState state; | 50 AccountState state; |
50 }; | 51 }; |
51 | 52 |
52 // Callback for the GetAccountsForCheckin call. |account_tokens| maps email | 53 // Callback for the GetAccountsForCheckin call. |account_tokens| maps email |
53 // addresses to OAuth2 access tokens. |account_removed| indicates whether an | 54 // addresses to OAuth2 access tokens. |
54 // account has been removed since the last time the callback was called. | 55 typedef base::Callback<void(const std::map<std::string, std::string>& |
55 typedef base::Callback< | 56 account_tokens)> UpdateAccountsCallback; |
56 void(const std::map<std::string, std::string>& account_tokens, | |
57 bool account_removed)> UpdateAccountsCallback; | |
58 | 57 |
59 // Creates an instance of GCMAccountTracker. |account_tracker| is used to | 58 // Creates an instance of GCMAccountTracker. |account_tracker| is used to |
60 // deliver information about the account, while |callback| will be called | 59 // deliver information about the account, while |callback| will be called |
61 // once all of the accounts have been fetched a necessary OAuth2 token, as | 60 // once all of the accounts have been fetched a necessary OAuth2 token, as |
62 // many times as the list of accounts is stable, meaning that all accounts | 61 // many times as the list of accounts is stable, meaning that all accounts |
63 // are known and there is no related activity in progress for them, like | 62 // are known and there is no related activity in progress for them, like |
64 // fetching OAuth2 tokens. | 63 // fetching OAuth2 tokens. |
65 GCMAccountTracker(scoped_ptr<gaia::AccountTracker> account_tracker, | 64 GCMAccountTracker(scoped_ptr<gaia::AccountTracker> account_tracker, |
66 const UpdateAccountsCallback& callback); | 65 const UpdateAccountsCallback& callback); |
67 virtual ~GCMAccountTracker(); | 66 virtual ~GCMAccountTracker(); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
126 bool shutdown_called_; | 125 bool shutdown_called_; |
127 | 126 |
128 ScopedVector<OAuth2TokenService::Request> pending_token_requests_; | 127 ScopedVector<OAuth2TokenService::Request> pending_token_requests_; |
129 | 128 |
130 DISALLOW_COPY_AND_ASSIGN(GCMAccountTracker); | 129 DISALLOW_COPY_AND_ASSIGN(GCMAccountTracker); |
131 }; | 130 }; |
132 | 131 |
133 } // namespace gcm | 132 } // namespace gcm |
134 | 133 |
135 #endif // CHROME_BROWSER_SERVICES_GCM_GCM_ACCOUNT_TRACKER_H_ | 134 #endif // CHROME_BROWSER_SERVICES_GCM_GCM_ACCOUNT_TRACKER_H_ |
OLD | NEW |