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

Unified Diff: chrome/browser/services/gcm/gcm_driver.h

Issue 286213003: Make GCMProfileService own GCMDriver, instead of deriving from it (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync Created 6 years, 7 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/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..2ae6616e1535b66c6dee45978f1748b4a366a74a 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,18 +47,19 @@ 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();
+ void Shutdown();
// Adds a handler for a given app.
void AddAppHandler(const std::string& app_id, GCMAppHandler* handler);
@@ -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.
+ std::string SignedInUserName() const;
+
// IdentityProvider::Observer:
virtual void OnActiveAccountLogin() OVERRIDE;
virtual void OnActiveAccountLogout() OVERRIDE;
@@ -117,14 +123,8 @@ 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;
@@ -134,6 +134,9 @@ class GCMDriver : public IdentityProvider::Observer {
// |identity_provider_| is able to supply an account ID.
void 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();
@@ -174,6 +177,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 +187,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

Powered by Google App Engine
This is Rietveld 408576698