OLD | NEW |
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 CHROME_BROWSER_CHROME_TO_MOBILE_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_CHROME_TO_MOBILE_SERVICE_H_ |
6 #define CHROME_BROWSER_CHROME_TO_MOBILE_SERVICE_H_ | 6 #define CHROME_BROWSER_CHROME_TO_MOBILE_SERVICE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 | 113 |
114 // Delete the snapshot file (should be called on observer destruction). | 114 // Delete the snapshot file (should be called on observer destruction). |
115 // Virtual for unit test mocking. | 115 // Virtual for unit test mocking. |
116 virtual void DeleteSnapshot(const FilePath& snapshot); | 116 virtual void DeleteSnapshot(const FilePath& snapshot); |
117 | 117 |
118 // Log a metric for the "ChromeToMobile.Service" histogram. | 118 // Log a metric for the "ChromeToMobile.Service" histogram. |
119 // Virtual for unit test mocking. | 119 // Virtual for unit test mocking. |
120 virtual void LogMetric(Metric metric); | 120 virtual void LogMetric(Metric metric); |
121 | 121 |
122 // content::URLFetcherDelegate method. | 122 // content::URLFetcherDelegate method. |
123 virtual void OnURLFetchComplete(const content::URLFetcher* source) OVERRIDE; | 123 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
124 | 124 |
125 // content::NotificationObserver method. | 125 // content::NotificationObserver method. |
126 virtual void Observe(int type, | 126 virtual void Observe(int type, |
127 const content::NotificationSource& source, | 127 const content::NotificationSource& source, |
128 const content::NotificationDetails& details) OVERRIDE; | 128 const content::NotificationDetails& details) OVERRIDE; |
129 | 129 |
130 // OAuth2AccessTokenConsumer methods. | 130 // OAuth2AccessTokenConsumer methods. |
131 virtual void OnGetTokenSuccess(const std::string& access_token) OVERRIDE; | 131 virtual void OnGetTokenSuccess(const std::string& access_token) OVERRIDE; |
132 virtual void OnGetTokenFailure(const GoogleServiceAuthError& error) OVERRIDE; | 132 virtual void OnGetTokenFailure(const GoogleServiceAuthError& error) OVERRIDE; |
133 | 133 |
(...skipping 14 matching lines...) Expand all Loading... |
148 virtual void RefreshAccessToken(); | 148 virtual void RefreshAccessToken(); |
149 | 149 |
150 // Request account information to limit cloud print access to existing users. | 150 // Request account information to limit cloud print access to existing users. |
151 void RequestAccountInfo(); | 151 void RequestAccountInfo(); |
152 | 152 |
153 // Send the cloud print URLFetcher search request. | 153 // Send the cloud print URLFetcher search request. |
154 void RequestSearch(); | 154 void RequestSearch(); |
155 | 155 |
156 void HandleAccountInfoResponse(); | 156 void HandleAccountInfoResponse(); |
157 void HandleSearchResponse(); | 157 void HandleSearchResponse(); |
158 void HandleSubmitResponse(const content::URLFetcher* source); | 158 void HandleSubmitResponse(const net::URLFetcher* source); |
159 | 159 |
160 base::WeakPtrFactory<ChromeToMobileService> weak_ptr_factory_; | 160 base::WeakPtrFactory<ChromeToMobileService> weak_ptr_factory_; |
161 | 161 |
162 Profile* profile_; | 162 Profile* profile_; |
163 | 163 |
164 // Used to recieve TokenService notifications for GaiaOAuth2LoginRefreshToken. | 164 // Used to recieve TokenService notifications for GaiaOAuth2LoginRefreshToken. |
165 content::NotificationRegistrar registrar_; | 165 content::NotificationRegistrar registrar_; |
166 | 166 |
167 // Cloud print helper class and auth token. | 167 // Cloud print helper class and auth token. |
168 scoped_ptr<CloudPrintURL> cloud_print_url_; | 168 scoped_ptr<CloudPrintURL> cloud_print_url_; |
169 std::string access_token_; | 169 std::string access_token_; |
170 | 170 |
171 // The list of mobile devices retrieved from the cloud print service. | 171 // The list of mobile devices retrieved from the cloud print service. |
172 ScopedVector<base::DictionaryValue> mobiles_; | 172 ScopedVector<base::DictionaryValue> mobiles_; |
173 | 173 |
174 // The set of snapshots currently available. | 174 // The set of snapshots currently available. |
175 std::set<FilePath> snapshots_; | 175 std::set<FilePath> snapshots_; |
176 | 176 |
177 // Map URLFetchers to observers for reporting OnSendComplete. | 177 // Map URLFetchers to observers for reporting OnSendComplete. |
178 typedef std::map<const content::URLFetcher*, base::WeakPtr<Observer> > | 178 typedef std::map<const net::URLFetcher*, base::WeakPtr<Observer> > |
179 RequestObserverMap; | 179 RequestObserverMap; |
180 RequestObserverMap request_observer_map_; | 180 RequestObserverMap request_observer_map_; |
181 | 181 |
182 // The pending OAuth access token request and a timer for retrying on failure. | 182 // The pending OAuth access token request and a timer for retrying on failure. |
183 scoped_ptr<OAuth2AccessTokenFetcher> access_token_fetcher_; | 183 scoped_ptr<OAuth2AccessTokenFetcher> access_token_fetcher_; |
184 base::OneShotTimer<ChromeToMobileService> auth_retry_timer_; | 184 base::OneShotTimer<ChromeToMobileService> auth_retry_timer_; |
185 | 185 |
186 // The pending account information request and the cloud print access flag. | 186 // The pending account information request and the cloud print access flag. |
187 scoped_ptr<content::URLFetcher> account_info_request_; | 187 scoped_ptr<content::URLFetcher> account_info_request_; |
188 bool cloud_print_accessible_; | 188 bool cloud_print_accessible_; |
189 | 189 |
190 // The pending mobile device search request; and the time of the last request. | 190 // The pending mobile device search request; and the time of the last request. |
191 scoped_ptr<content::URLFetcher> search_request_; | 191 scoped_ptr<content::URLFetcher> search_request_; |
192 base::TimeTicks previous_search_time_; | 192 base::TimeTicks previous_search_time_; |
193 | 193 |
194 DISALLOW_COPY_AND_ASSIGN(ChromeToMobileService); | 194 DISALLOW_COPY_AND_ASSIGN(ChromeToMobileService); |
195 }; | 195 }; |
196 | 196 |
197 #endif // CHROME_BROWSER_CHROME_TO_MOBILE_SERVICE_H_ | 197 #endif // CHROME_BROWSER_CHROME_TO_MOBILE_SERVICE_H_ |
OLD | NEW |