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

Side by Side Diff: chrome/browser/chrome_to_mobile_service.h

Issue 10808068: Store ChromeToMobile device list and timestamp prefs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add GetMobiles ownership/lifetime comment. Created 8 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/chrome_to_mobile_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 10 matching lines...) Expand all
21 #include "chrome/common/net/gaia/oauth2_access_token_consumer.h" 21 #include "chrome/common/net/gaia/oauth2_access_token_consumer.h"
22 #include "content/public/browser/notification_observer.h" 22 #include "content/public/browser/notification_observer.h"
23 #include "content/public/browser/notification_registrar.h" 23 #include "content/public/browser/notification_registrar.h"
24 #include "googleurl/src/gurl.h" 24 #include "googleurl/src/gurl.h"
25 #include "net/url_request/url_fetcher_delegate.h" 25 #include "net/url_request/url_fetcher_delegate.h"
26 26
27 class OAuth2AccessTokenFetcher; 27 class OAuth2AccessTokenFetcher;
28 class Browser; 28 class Browser;
29 class CloudPrintURL; 29 class CloudPrintURL;
30 class MockChromeToMobileService; 30 class MockChromeToMobileService;
31 class PrefService;
31 class Profile; 32 class Profile;
32 33
33 namespace net { 34 namespace net {
34 class URLFetcher; 35 class URLFetcher;
35 } 36 }
36 37
37 // ChromeToMobileService connects to the cloud print service to enumerate 38 // ChromeToMobileService connects to the cloud print service to enumerate
38 // compatible mobiles owned by its profile and send URLs and MHTML snapshots. 39 // compatible mobiles owned by its profile and send URLs and MHTML snapshots.
39 class ChromeToMobileService : public ProfileKeyedService, 40 class ChromeToMobileService : public ProfileKeyedService,
40 public net::URLFetcherDelegate, 41 public net::URLFetcherDelegate,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 string16 title; 91 string16 title;
91 FilePath snapshot; 92 FilePath snapshot;
92 std::string snapshot_id; 93 std::string snapshot_id;
93 JobType type; 94 JobType type;
94 }; 95 };
95 96
96 // Returns whether Chrome To Mobile is enabled. Check for the 'disable' or 97 // Returns whether Chrome To Mobile is enabled. Check for the 'disable' or
97 // 'enable' command line switches, otherwise relay the default enabled state. 98 // 'enable' command line switches, otherwise relay the default enabled state.
98 static bool IsChromeToMobileEnabled(); 99 static bool IsChromeToMobileEnabled();
99 100
101 // Register the user prefs associated with this service.
102 static void RegisterUserPrefs(PrefService* prefs);
103
100 explicit ChromeToMobileService(Profile* profile); 104 explicit ChromeToMobileService(Profile* profile);
101 virtual ~ChromeToMobileService(); 105 virtual ~ChromeToMobileService();
102 106
103 // Returns true if the service has found any registered mobile devices. 107 // Returns true if the service has found any registered mobile devices.
104 bool HasDevices(); 108 bool HasMobiles();
105 109
106 // Get the list of mobile devices, a ListValue of DictionaryValues. 110 // Get the non-NULL ListValue of mobile devices from the cloud print service.
107 const base::ListValue& mobiles() const { return mobiles_; } 111 // The list is owned by PrefService, which outlives ChromeToMobileService.
112 // Each device DictionaryValue contains strings "type", "name", and "id".
113 // Virtual for unit test mocking.
114 virtual const base::ListValue* GetMobiles() const;
108 115
109 // Request an updated mobile device list, request auth first if needed. 116 // Request an updated mobile device list, request auth first if needed.
110 // Virtual for unit test mocking. 117 // Virtual for unit test mocking.
111 virtual void RequestMobileListUpdate(); 118 virtual void RequestMobileListUpdate();
112 119
113 // Callback with an MHTML snapshot of the browser's selected WebContents. 120 // Callback with an MHTML snapshot of the browser's selected WebContents.
114 // Virtual for unit test mocking. 121 // Virtual for unit test mocking.
115 virtual void GenerateSnapshot(Browser* browser, 122 virtual void GenerateSnapshot(Browser* browser,
116 base::WeakPtr<Observer> observer); 123 base::WeakPtr<Observer> observer);
117 124
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 190
184 Profile* profile_; 191 Profile* profile_;
185 192
186 // Used to recieve TokenService notifications for GaiaOAuth2LoginRefreshToken. 193 // Used to recieve TokenService notifications for GaiaOAuth2LoginRefreshToken.
187 content::NotificationRegistrar registrar_; 194 content::NotificationRegistrar registrar_;
188 195
189 // Cloud print helper class and auth token. 196 // Cloud print helper class and auth token.
190 scoped_ptr<CloudPrintURL> cloud_print_url_; 197 scoped_ptr<CloudPrintURL> cloud_print_url_;
191 std::string access_token_; 198 std::string access_token_;
192 199
193 // The list of mobile devices retrieved from the cloud print service.
194 // Each mobile DictionaryValue contains strings "type", "name", and "id".
195 base::ListValue mobiles_;
196
197 // The set of snapshots currently available. 200 // The set of snapshots currently available.
198 std::set<FilePath> snapshots_; 201 std::set<FilePath> snapshots_;
199 202
200 // Map URLFetchers to observers for reporting OnSendComplete. 203 // Map URLFetchers to observers for reporting OnSendComplete.
201 typedef std::map<const net::URLFetcher*, base::WeakPtr<Observer> > 204 typedef std::map<const net::URLFetcher*, base::WeakPtr<Observer> >
202 RequestObserverMap; 205 RequestObserverMap;
203 RequestObserverMap request_observer_map_; 206 RequestObserverMap request_observer_map_;
204 207
205 // The pending OAuth access token request and a timer for retrying on failure. 208 // The pending OAuth access token request and a timer for retrying on failure.
206 scoped_ptr<OAuth2AccessTokenFetcher> access_token_fetcher_; 209 scoped_ptr<OAuth2AccessTokenFetcher> access_token_fetcher_;
207 base::OneShotTimer<ChromeToMobileService> auth_retry_timer_; 210 base::OneShotTimer<ChromeToMobileService> auth_retry_timer_;
208 211
209 // The pending account information request and the cloud print access flag. 212 // The pending account information request and the cloud print access flag.
210 scoped_ptr<net::URLFetcher> account_info_request_; 213 scoped_ptr<net::URLFetcher> account_info_request_;
211 bool cloud_print_accessible_; 214 bool cloud_print_accessible_;
212 215
213 // The pending mobile device search request; and the time of the last request. 216 // The pending mobile device search request.
214 scoped_ptr<net::URLFetcher> search_request_; 217 scoped_ptr<net::URLFetcher> search_request_;
215 base::TimeTicks previous_search_time_;
216 218
217 DISALLOW_COPY_AND_ASSIGN(ChromeToMobileService); 219 DISALLOW_COPY_AND_ASSIGN(ChromeToMobileService);
218 }; 220 };
219 221
220 #endif // CHROME_BROWSER_CHROME_TO_MOBILE_SERVICE_H_ 222 #endif // CHROME_BROWSER_CHROME_TO_MOBILE_SERVICE_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chrome_to_mobile_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698