Chromium Code Reviews| Index: chrome/browser/chrome_to_mobile_service.h |
| diff --git a/chrome/browser/chrome_to_mobile_service.h b/chrome/browser/chrome_to_mobile_service.h |
| index 3613396d7f4647fd995eb3cbdb28bbabf3c8ef79..d908dcc485e580ffad04db410f51962a43f987a8 100644 |
| --- a/chrome/browser/chrome_to_mobile_service.h |
| +++ b/chrome/browser/chrome_to_mobile_service.h |
| @@ -7,6 +7,7 @@ |
| #include <map> |
| #include <set> |
| +#include <queue> |
| #include <string> |
| #include <vector> |
| @@ -17,11 +18,13 @@ |
| #include "base/values.h" |
| #include "chrome/browser/profiles/profile_keyed_service.h" |
| #include "chrome/browser/sessions/session_id.h" |
| +#include "chrome/browser/sync/profile_sync_service_observer.h" |
| #include "chrome/common/net/gaia/oauth2_access_token_consumer.h" |
| #include "content/public/browser/notification_observer.h" |
| #include "content/public/browser/notification_registrar.h" |
| #include "googleurl/src/gurl.h" |
| #include "net/url_request/url_fetcher_delegate.h" |
| +#include "sync/notifier/sync_notifier_observer.h" |
| class OAuth2AccessTokenFetcher; |
| class Browser; |
| @@ -39,7 +42,9 @@ class URLFetcher; |
| class ChromeToMobileService : public ProfileKeyedService, |
| public net::URLFetcherDelegate, |
| public content::NotificationObserver, |
| - public OAuth2AccessTokenConsumer { |
| + public OAuth2AccessTokenConsumer, |
| + public ProfileSyncServiceObserver, |
| + public syncer::SyncNotifierObserver { |
| public: |
| class Observer { |
| public: |
| @@ -112,10 +117,6 @@ class ChromeToMobileService : public ProfileKeyedService, |
| // Virtual for unit test mocking. |
| virtual const base::ListValue* GetMobiles() const; |
| - // Request an updated mobile device list, request auth first if needed. |
| - // Virtual for unit test mocking. |
| - virtual void RequestMobileListUpdate(); |
| - |
| // Callback with an MHTML snapshot of the browser's selected WebContents. |
| // Virtual for unit test mocking. |
| virtual void GenerateSnapshot(Browser* browser, |
| @@ -123,7 +124,7 @@ class ChromeToMobileService : public ProfileKeyedService, |
| // Send the browser's selected WebContents to the specified mobile device. |
| // Virtual for unit test mocking. |
| - virtual void SendToMobile(const base::DictionaryValue& mobile, |
| + virtual void SendToMobile(const base::DictionaryValue* mobile, |
| const FilePath& snapshot, |
| Browser* browser, |
| base::WeakPtr<Observer> observer); |
| @@ -152,6 +153,21 @@ class ChromeToMobileService : public ProfileKeyedService, |
| const base::Time& expiration_time) OVERRIDE; |
| virtual void OnGetTokenFailure(const GoogleServiceAuthError& error) OVERRIDE; |
| + // ProfileSyncServiceObserver implementation. |
| + virtual void OnStateChanged() OVERRIDE; |
|
akalin
2012/08/20 20:50:17
include compiler_specific.h for OVERRIDE
msw
2012/08/20 21:56:15
Done.
|
| + |
| + // syncer::SyncNotifierObserver implementation. |
| + virtual void OnNotificationsEnabled() OVERRIDE; |
| + virtual void OnNotificationsDisabled( |
| + syncer::NotificationsDisabledReason reason) OVERRIDE; |
| + virtual void OnIncomingNotification( |
| + const syncer::ObjectIdPayloadMap& id_payloads, |
| + syncer::IncomingNotificationSource source) OVERRIDE; |
| + |
| + // Expose access token accessors for test purposes. |
| + const std::string& GetAccessTokenForTest() const; |
| + void SetAccessTokenForTest(const std::string& access_token); |
| + |
| private: |
| friend class MockChromeToMobileService; |
| @@ -179,13 +195,10 @@ class ChromeToMobileService : public ProfileKeyedService, |
| // Virtual for unit test mocking. |
| virtual void RequestAccessToken(); |
| - // Request account information to limit cloud print access to existing users. |
| - void RequestAccountInfo(); |
| - |
| // Send the cloud print URLFetcher device search request. |
| - void RequestDeviceSearch(); |
| + // Virtual for unit test mocking. |
| + virtual void RequestDeviceSearch(); |
| - void HandleAccountInfoResponse(); |
| void HandleSearchResponse(); |
| void HandleSubmitResponse(const net::URLFetcher* source); |
| @@ -193,6 +206,11 @@ class ChromeToMobileService : public ProfileKeyedService, |
| Profile* profile_; |
| + // Sync service states. Profile Sync Service and Sync Invalidations are needed |
| + // to keep the mobile device list up to date and prevent page send failures. |
| + bool profile_sync_service_enabled_; |
| + bool sync_invalidation_enabled_; |
| + |
| // Used to recieve TokenService notifications for GaiaOAuth2LoginRefreshToken. |
| content::NotificationRegistrar registrar_; |
| @@ -212,13 +230,12 @@ class ChromeToMobileService : public ProfileKeyedService, |
| scoped_ptr<OAuth2AccessTokenFetcher> access_token_fetcher_; |
| base::OneShotTimer<ChromeToMobileService> auth_retry_timer_; |
| - // The pending account information request and the cloud print access flag. |
| - scoped_ptr<net::URLFetcher> account_info_request_; |
| - bool cloud_print_accessible_; |
| - |
| // The pending mobile device search request. |
| scoped_ptr<net::URLFetcher> search_request_; |
| + // A queue of tasks to perform after an access token is lazily initialized. |
| + std::queue<base::Closure> task_queue_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(ChromeToMobileService); |
| }; |