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

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

Issue 10834203: Integrate invalidation API into ChromeToMobileService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync and merge; consume ipc::invalidation::ObjectSource::CHROME_COMPONENTS. Created 8 years, 4 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
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>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/file_path.h" 13 #include "base/file_path.h"
14 #include "base/memory/scoped_vector.h" 14 #include "base/memory/scoped_vector.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "base/string16.h" 16 #include "base/string16.h"
17 #include "base/timer.h" 17 #include "base/timer.h"
18 #include "base/values.h" 18 #include "base/values.h"
19 #include "chrome/browser/profiles/profile_keyed_service.h" 19 #include "chrome/browser/profiles/profile_keyed_service.h"
20 #include "chrome/browser/sessions/session_id.h" 20 #include "chrome/browser/sessions/session_id.h"
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 #include "sync/notifier/chrome_invalidation_client.h"
akalin 2012/08/08 23:06:27 chrome_invalidation_client shouldn't be included.
msw 2012/08/10 22:05:05 Done.
27 #include "sync/notifier/invalidation_util.h"
28 #include "sync/notifier/notifications_disabled_reason.h"
29 #include "sync/notifier/sync_notifier_observer.h"
26 30
27 class OAuth2AccessTokenFetcher; 31 class OAuth2AccessTokenFetcher;
28 class Browser; 32 class Browser;
29 class CloudPrintURL; 33 class CloudPrintURL;
30 class MockChromeToMobileService; 34 class MockChromeToMobileService;
31 class PrefService; 35 class PrefService;
32 class Profile; 36 class Profile;
33 37
34 namespace net { 38 namespace net {
35 class URLFetcher; 39 class URLFetcher;
36 } 40 }
37 41
38 // ChromeToMobileService connects to the cloud print service to enumerate 42 // ChromeToMobileService connects to the cloud print service to enumerate
39 // compatible mobiles owned by its profile and send URLs and MHTML snapshots. 43 // compatible mobiles owned by its profile and send URLs and MHTML snapshots.
40 class ChromeToMobileService : public ProfileKeyedService, 44 class ChromeToMobileService : public ProfileKeyedService,
41 public net::URLFetcherDelegate, 45 public net::URLFetcherDelegate,
42 public content::NotificationObserver, 46 public content::NotificationObserver,
43 public OAuth2AccessTokenConsumer { 47 public OAuth2AccessTokenConsumer,
48 public syncer::SyncNotifierObserver {
44 public: 49 public:
45 class Observer { 50 class Observer {
46 public: 51 public:
47 virtual ~Observer(); 52 virtual ~Observer();
48 53
49 // Called on generation of the page's MHTML snapshot. 54 // Called on generation of the page's MHTML snapshot.
50 virtual void SnapshotGenerated(const FilePath& path, int64 bytes) = 0; 55 virtual void SnapshotGenerated(const FilePath& path, int64 bytes) = 0;
51 56
52 // Called after URLFetcher responses from sending the URL (and snapshot). 57 // Called after URLFetcher responses from sending the URL (and snapshot).
53 virtual void OnSendComplete(bool success) = 0; 58 virtual void OnSendComplete(bool success) = 0;
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 // content::NotificationObserver method. 151 // content::NotificationObserver method.
147 virtual void Observe(int type, 152 virtual void Observe(int type,
148 const content::NotificationSource& source, 153 const content::NotificationSource& source,
149 const content::NotificationDetails& details) OVERRIDE; 154 const content::NotificationDetails& details) OVERRIDE;
150 155
151 // OAuth2AccessTokenConsumer methods. 156 // OAuth2AccessTokenConsumer methods.
152 virtual void OnGetTokenSuccess(const std::string& access_token, 157 virtual void OnGetTokenSuccess(const std::string& access_token,
153 const base::Time& expiration_time) OVERRIDE; 158 const base::Time& expiration_time) OVERRIDE;
154 virtual void OnGetTokenFailure(const GoogleServiceAuthError& error) OVERRIDE; 159 virtual void OnGetTokenFailure(const GoogleServiceAuthError& error) OVERRIDE;
155 160
161 // syncer::SyncNotifierObserver implementation.
162 virtual void OnNotificationsEnabled() OVERRIDE;
163 virtual void OnNotificationsDisabled(
164 syncer::NotificationsDisabledReason reason) OVERRIDE;
165 virtual void OnIncomingNotification(
166 const syncer::ObjectIdPayloadMap& id_payloads,
167 syncer::IncomingNotificationSource source) OVERRIDE;
168
156 private: 169 private:
157 friend class MockChromeToMobileService; 170 friend class MockChromeToMobileService;
158 171
159 // Handle the attempted creation of a temporary file for snapshot generation. 172 // Handle the attempted creation of a temporary file for snapshot generation.
160 // Alert the observer of failure or generate MHTML with an observer callback. 173 // Alert the observer of failure or generate MHTML with an observer callback.
161 void SnapshotFileCreated(base::WeakPtr<Observer> observer, 174 void SnapshotFileCreated(base::WeakPtr<Observer> observer,
162 SessionID::id_type browser_id, 175 SessionID::id_type browser_id,
163 const FilePath& path, 176 const FilePath& path,
164 bool success); 177 bool success);
165 178
(...skipping 17 matching lines...) Expand all
183 void RequestSearch(); 196 void RequestSearch();
184 197
185 void HandleAccountInfoResponse(); 198 void HandleAccountInfoResponse();
186 void HandleSearchResponse(); 199 void HandleSearchResponse();
187 void HandleSubmitResponse(const net::URLFetcher* source); 200 void HandleSubmitResponse(const net::URLFetcher* source);
188 201
189 base::WeakPtrFactory<ChromeToMobileService> weak_ptr_factory_; 202 base::WeakPtrFactory<ChromeToMobileService> weak_ptr_factory_;
190 203
191 Profile* profile_; 204 Profile* profile_;
192 205
206 // TODO(msw): The Sync object id set...
207 invalidation::ObjectId mobile_list_id_;
208 syncer::ObjectIdSet sync_objects_;
209 bool sync_invalidation_enabled_;
210
193 // Used to recieve TokenService notifications for GaiaOAuth2LoginRefreshToken. 211 // Used to recieve TokenService notifications for GaiaOAuth2LoginRefreshToken.
194 content::NotificationRegistrar registrar_; 212 content::NotificationRegistrar registrar_;
195 213
196 // Cloud print helper class and auth token. 214 // Cloud print helper class and auth token.
197 scoped_ptr<CloudPrintURL> cloud_print_url_; 215 scoped_ptr<CloudPrintURL> cloud_print_url_;
198 std::string access_token_; 216 std::string access_token_;
199 217
200 // The set of snapshots currently available. 218 // The set of snapshots currently available.
201 std::set<FilePath> snapshots_; 219 std::set<FilePath> snapshots_;
202 220
(...skipping 10 matching lines...) Expand all
213 scoped_ptr<net::URLFetcher> account_info_request_; 231 scoped_ptr<net::URLFetcher> account_info_request_;
214 bool cloud_print_accessible_; 232 bool cloud_print_accessible_;
215 233
216 // The pending mobile device search request. 234 // The pending mobile device search request.
217 scoped_ptr<net::URLFetcher> search_request_; 235 scoped_ptr<net::URLFetcher> search_request_;
218 236
219 DISALLOW_COPY_AND_ASSIGN(ChromeToMobileService); 237 DISALLOW_COPY_AND_ASSIGN(ChromeToMobileService);
220 }; 238 };
221 239
222 #endif // CHROME_BROWSER_CHROME_TO_MOBILE_SERVICE_H_ 240 #endif // CHROME_BROWSER_CHROME_TO_MOBILE_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698