| Index: chrome/browser/services/gcm/gcm_driver.h
|
| diff --git a/chrome/browser/services/gcm/gcm_driver.h b/chrome/browser/services/gcm/gcm_driver.h
|
| index f0ff169113313eb685af3fb4b80cc9e8ca7b59e7..9db2d66f165fd44e177645b97c6a40b9426308ea 100644
|
| --- a/chrome/browser/services/gcm/gcm_driver.h
|
| +++ b/chrome/browser/services/gcm/gcm_driver.h
|
| @@ -12,14 +12,16 @@
|
| #include "base/basictypes.h"
|
| #include "base/callback.h"
|
| #include "base/compiler_specific.h"
|
| -#include "base/files/file_path.h"
|
| -#include "base/memory/ref_counted.h"
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/memory/weak_ptr.h"
|
| #include "components/gcm_driver/default_gcm_app_handler.h"
|
| #include "google_apis/gaia/identity_provider.h"
|
| #include "google_apis/gcm/gcm_client.h"
|
|
|
| +namespace base {
|
| +class FilePath;
|
| +}
|
| +
|
| namespace extensions {
|
| class ExtensionGCMAppHandlerTest;
|
| }
|
| @@ -45,24 +47,25 @@ class GCMDriver : public IdentityProvider::Observer {
|
| typedef base::Callback<void(const GCMClient::GCMStatistics& stats)>
|
| GetGCMStatisticsCallback;
|
|
|
| - explicit GCMDriver(scoped_ptr<IdentityProvider> identity_provider);
|
| + GCMDriver(scoped_ptr<GCMClientFactory> gcm_client_factory,
|
| + scoped_ptr<IdentityProvider> identity_provider,
|
| + const base::FilePath& store_path,
|
| + const scoped_refptr<net::URLRequestContextGetter>& request_context);
|
| virtual ~GCMDriver();
|
|
|
| - void Initialize(scoped_ptr<GCMClientFactory> gcm_client_factory);
|
| -
|
| - void Start();
|
| -
|
| - void Stop();
|
| + // Enables/disables GCM service.
|
| + void Enable();
|
| + void Disable();
|
|
|
| // This method must be called before destroying the GCMDriver. Once it has
|
| // been called, no other GCMDriver methods may be used.
|
| - void ShutdownService();
|
| + virtual void Shutdown();
|
|
|
| // Adds a handler for a given app.
|
| - void AddAppHandler(const std::string& app_id, GCMAppHandler* handler);
|
| + virtual void AddAppHandler(const std::string& app_id, GCMAppHandler* handler);
|
|
|
| // Remove the handler for a given app.
|
| - void RemoveAppHandler(const std::string& app_id);
|
| + virtual void RemoveAppHandler(const std::string& app_id);
|
|
|
| // Registers |sender_id| for an app. A registration ID will be returned by
|
| // the GCM server.
|
| @@ -110,6 +113,9 @@ class GCMDriver : public IdentityProvider::Observer {
|
| void SetGCMRecording(const GetGCMStatisticsCallback& callback,
|
| bool recording);
|
|
|
| + // Returns the user name if the profile is signed in. Empty string otherwise.
|
| + std::string SignedInUserName() const;
|
| +
|
| // IdentityProvider::Observer:
|
| virtual void OnActiveAccountLogin() OVERRIDE;
|
| virtual void OnActiveAccountLogout() OVERRIDE;
|
| @@ -117,22 +123,21 @@ class GCMDriver : public IdentityProvider::Observer {
|
| const GCMAppHandlerMap& app_handlers() const { return app_handlers_; }
|
|
|
| protected:
|
| - virtual bool ShouldStartAutomatically() const = 0;
|
| -
|
| - virtual base::FilePath GetStorePath() const = 0;
|
| -
|
| - virtual scoped_refptr<net::URLRequestContextGetter>
|
| - GetURLRequestContextGetter() const = 0;
|
| -
|
| - scoped_ptr<IdentityProvider> identity_provider_;
|
| + // Used for constructing fake GCMDriver for testing purpose.
|
| + GCMDriver();
|
|
|
| private:
|
| class DelayedTaskController;
|
| class IOWorker;
|
|
|
| - // Ensures that the GCMClient is started and the GCM check-in is done if the
|
| - // |identity_provider_| is able to supply an account ID.
|
| - void EnsureStarted();
|
| + // Ensures that the GCM service starts when all of the following conditions
|
| + // satisfy:
|
| + // 1) GCM is enabled.
|
| + // 2) The identity provider is able to supply an account ID.
|
| + GCMClient::Result EnsureStarted();
|
| +
|
| + // Stops the GCM service. It can be restarted by calling EnsureStarted again.
|
| + void Stop();
|
|
|
| // Remove cached data when GCM service is stopped.
|
| void RemoveCachedData();
|
| @@ -140,9 +145,6 @@ class GCMDriver : public IdentityProvider::Observer {
|
| // Checks out of GCM and erases any cached and persisted data.
|
| void CheckOut();
|
|
|
| - // Ensures that the app is ready for GCM functions and events.
|
| - GCMClient::Result EnsureAppReady(const std::string& app_id);
|
| -
|
| // Should be called when an app with |app_id| is trying to un/register.
|
| // Checks whether another un/registration is in progress.
|
| bool IsAsyncOperationPending(const std::string& app_id) const;
|
| @@ -174,6 +176,9 @@ class GCMDriver : public IdentityProvider::Observer {
|
|
|
| void GetGCMStatisticsFinished(GCMClient::GCMStatistics stats);
|
|
|
| + // Flag to indicate if GCM is enabled.
|
| + bool gcm_enabled_;
|
| +
|
| // Flag to indicate if GCMClient is ready.
|
| bool gcm_client_ready_;
|
|
|
| @@ -181,6 +186,8 @@ class GCMDriver : public IdentityProvider::Observer {
|
| // is not running.
|
| std::string account_id_;
|
|
|
| + scoped_ptr<IdentityProvider> identity_provider_;
|
| +
|
| scoped_ptr<DelayedTaskController> delayed_task_controller_;
|
|
|
| // For all the work occurring on the IO thread. Must be destroyed on the IO
|
|
|