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

Unified 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: Rebase, add RegisterForDeviceListInvalidations util function. 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 side-by-side diff with in-line comments
Download patch
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..5ed2a4774aac44779225f28d96698dbb93a6063a 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>
@@ -22,6 +23,7 @@
#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 +41,8 @@ class URLFetcher;
class ChromeToMobileService : public ProfileKeyedService,
public net::URLFetcherDelegate,
public content::NotificationObserver,
- public OAuth2AccessTokenConsumer {
+ public OAuth2AccessTokenConsumer,
+ public syncer::SyncNotifierObserver {
public:
class Observer {
public:
@@ -112,10 +115,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 +122,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 +151,14 @@ class ChromeToMobileService : public ProfileKeyedService,
const base::Time& expiration_time) OVERRIDE;
virtual void OnGetTokenFailure(const GoogleServiceAuthError& error) OVERRIDE;
+ // 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;
+
private:
friend class MockChromeToMobileService;
@@ -175,17 +182,17 @@ class ChromeToMobileService : public ProfileKeyedService,
// Submit a cloud print job request with the requisite data.
void SendRequest(net::URLFetcher* request, const JobData& data);
+ // Register to handle cloud print device list invalidations.
+ virtual void RegisterForDeviceListInvalidations();
+
// Send the OAuth2AccessTokenFetcher request.
// 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 +200,10 @@ class ChromeToMobileService : public ProfileKeyedService,
Profile* profile_;
+ // Sync invalidation service state. Chrome To Mobile requires this service to
+ // keep its mobile device list up to date and prevent page send failures.
+ bool sync_invalidation_enabled_;
+
// Used to recieve TokenService notifications for GaiaOAuth2LoginRefreshToken.
content::NotificationRegistrar registrar_;
@@ -212,13 +223,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);
};

Powered by Google App Engine
This is Rietveld 408576698