| 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 GOOGLE_APIS_GAIA_MERGE_SESSION_HELPER_H_ | 5 #ifndef GOOGLE_APIS_GAIA_MERGE_SESSION_HELPER_H_ |
| 6 #define GOOGLE_APIS_GAIA_MERGE_SESSION_HELPER_H_ | 6 #define GOOGLE_APIS_GAIA_MERGE_SESSION_HELPER_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 | 9 |
| 10 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 URLToTokenAndFetcher get_fetcher_map_for_testing() { | 73 URLToTokenAndFetcher get_fetcher_map_for_testing() { |
| 74 return fetchers_; | 74 return fetchers_; |
| 75 } | 75 } |
| 76 | 76 |
| 77 // Simulate a timeout for tests. | 77 // Simulate a timeout for tests. |
| 78 void TimeoutForTests(); | 78 void TimeoutForTests(); |
| 79 | 79 |
| 80 private: | 80 private: |
| 81 // Overridden from GaiaAuthConsumer. | 81 // Overridden from GaiaAuthConsumer. |
| 82 virtual void OnGetCheckConnectionInfoSuccess( | 82 virtual void OnGetCheckConnectionInfoSuccess( |
| 83 const std::string& data) OVERRIDE; | 83 const std::string& data) override; |
| 84 | 84 |
| 85 // Creates and initializes a URL fetcher for doing a connection check. | 85 // Creates and initializes a URL fetcher for doing a connection check. |
| 86 net::URLFetcher* CreateFetcher(const GURL& url); | 86 net::URLFetcher* CreateFetcher(const GURL& url); |
| 87 | 87 |
| 88 // Overridden from URLFetcherDelgate. | 88 // Overridden from URLFetcherDelgate. |
| 89 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | 89 virtual void OnURLFetchComplete(const net::URLFetcher* source) override; |
| 90 | 90 |
| 91 // Any fetches still ongoing after this call are considered timed out. | 91 // Any fetches still ongoing after this call are considered timed out. |
| 92 void Timeout(); | 92 void Timeout(); |
| 93 | 93 |
| 94 void CleanupTransientState(); | 94 void CleanupTransientState(); |
| 95 | 95 |
| 96 MergeSessionHelper* helper_; | 96 MergeSessionHelper* helper_; |
| 97 base::OneShotTimer<ExternalCcResultFetcher> timer_; | 97 base::OneShotTimer<ExternalCcResultFetcher> timer_; |
| 98 scoped_ptr<GaiaAuthFetcher> gaia_auth_fetcher_; | 98 scoped_ptr<GaiaAuthFetcher> gaia_auth_fetcher_; |
| 99 URLToTokenAndFetcher fetchers_; | 99 URLToTokenAndFetcher fetchers_; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 void StartFetchingExternalCcResult(); | 141 void StartFetchingExternalCcResult(); |
| 142 | 142 |
| 143 // Returns true if the helper is still fetching external check connection | 143 // Returns true if the helper is still fetching external check connection |
| 144 // results. | 144 // results. |
| 145 bool StillFetchingExternalCcResult(); | 145 bool StillFetchingExternalCcResult(); |
| 146 | 146 |
| 147 private: | 147 private: |
| 148 net::URLRequestContextGetter* request_context() { return request_context_; } | 148 net::URLRequestContextGetter* request_context() { return request_context_; } |
| 149 | 149 |
| 150 // Overridden from UbertokenConsumer. | 150 // Overridden from UbertokenConsumer. |
| 151 virtual void OnUbertokenSuccess(const std::string& token) OVERRIDE; | 151 virtual void OnUbertokenSuccess(const std::string& token) override; |
| 152 virtual void OnUbertokenFailure(const GoogleServiceAuthError& error) OVERRIDE; | 152 virtual void OnUbertokenFailure(const GoogleServiceAuthError& error) override; |
| 153 | 153 |
| 154 // Overridden from GaiaAuthConsumer. | 154 // Overridden from GaiaAuthConsumer. |
| 155 virtual void OnMergeSessionSuccess(const std::string& data) OVERRIDE; | 155 virtual void OnMergeSessionSuccess(const std::string& data) override; |
| 156 virtual void OnMergeSessionFailure(const GoogleServiceAuthError& error) | 156 virtual void OnMergeSessionFailure(const GoogleServiceAuthError& error) |
| 157 OVERRIDE; | 157 override; |
| 158 | 158 |
| 159 void LogOutInternal(const std::string& account_id, | 159 void LogOutInternal(const std::string& account_id, |
| 160 const std::vector<std::string>& accounts); | 160 const std::vector<std::string>& accounts); |
| 161 | 161 |
| 162 // Starts the proess of fetching the uber token and performing a merge session | 162 // Starts the proess of fetching the uber token and performing a merge session |
| 163 // for the next account. Virtual so that it can be overriden in tests. | 163 // for the next account. Virtual so that it can be overriden in tests. |
| 164 virtual void StartFetching(); | 164 virtual void StartFetching(); |
| 165 | 165 |
| 166 // Virtual for testing purpose. | 166 // Virtual for testing purpose. |
| 167 virtual void StartLogOutUrlFetch(); | 167 virtual void StartLogOutUrlFetch(); |
| 168 | 168 |
| 169 // Start the next merge session, if needed. | 169 // Start the next merge session, if needed. |
| 170 void HandleNextAccount(); | 170 void HandleNextAccount(); |
| 171 | 171 |
| 172 // Overridden from URLFetcherDelgate. | 172 // Overridden from URLFetcherDelgate. |
| 173 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | 173 virtual void OnURLFetchComplete(const net::URLFetcher* source) override; |
| 174 | 174 |
| 175 OAuth2TokenService* token_service_; | 175 OAuth2TokenService* token_service_; |
| 176 net::URLRequestContextGetter* request_context_; | 176 net::URLRequestContextGetter* request_context_; |
| 177 scoped_ptr<GaiaAuthFetcher> gaia_auth_fetcher_; | 177 scoped_ptr<GaiaAuthFetcher> gaia_auth_fetcher_; |
| 178 scoped_ptr<UbertokenFetcher> uber_token_fetcher_; | 178 scoped_ptr<UbertokenFetcher> uber_token_fetcher_; |
| 179 ExternalCcResultFetcher result_fetcher_; | 179 ExternalCcResultFetcher result_fetcher_; |
| 180 | 180 |
| 181 // A worklist for this class. Accounts names are stored here if | 181 // A worklist for this class. Accounts names are stored here if |
| 182 // we are pending a signin action for that account. Empty strings | 182 // we are pending a signin action for that account. Empty strings |
| 183 // represent a signout request. | 183 // represent a signout request. |
| 184 std::deque<std::string> accounts_; | 184 std::deque<std::string> accounts_; |
| 185 | 185 |
| 186 // List of observers to notify when merge session completes. | 186 // List of observers to notify when merge session completes. |
| 187 // Makes sure list is empty on destruction. | 187 // Makes sure list is empty on destruction. |
| 188 ObserverList<Observer, true> observer_list_; | 188 ObserverList<Observer, true> observer_list_; |
| 189 | 189 |
| 190 // Source to use with GAIA endpoints for accounting. | 190 // Source to use with GAIA endpoints for accounting. |
| 191 std::string source_; | 191 std::string source_; |
| 192 | 192 |
| 193 DISALLOW_COPY_AND_ASSIGN(MergeSessionHelper); | 193 DISALLOW_COPY_AND_ASSIGN(MergeSessionHelper); |
| 194 }; | 194 }; |
| 195 | 195 |
| 196 #endif // GOOGLE_APIS_GAIA_MERGE_SESSION_HELPER_H_ | 196 #endif // GOOGLE_APIS_GAIA_MERGE_SESSION_HELPER_H_ |
| OLD | NEW |