Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_SERVICES_GCM_GCM_PROFILE_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SERVICES_GCM_GCM_PROFILE_SERVICE_H_ |
| 6 #define CHROME_BROWSER_SERVICES_GCM_GCM_PROFILE_SERVICE_H_ | 6 #define CHROME_BROWSER_SERVICES_GCM_GCM_PROFILE_SERVICE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/files/file_path.h" | |
| 11 #include "base/macros.h" | 12 #include "base/macros.h" |
| 12 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 13 #include "components/keyed_service/core/keyed_service.h" | 14 #include "components/keyed_service/core/keyed_service.h" |
| 15 #include "components/signin/core/browser/profile_oauth2_token_service.h" | |
|
droger
2015/10/27 12:23:44
Can we forward declare
ProfileOAuth2TokenService
i
Jitu( very slow this week)
2015/10/28 05:11:36
Done.
| |
| 16 #include "components/signin/core/browser/signin_manager_base.h" | |
| 17 #include "components/version_info/version_info.h" | |
| 18 #include "net/url_request/url_request_context_getter.h" | |
| 14 | 19 |
| 20 class PrefService; | |
| 15 class Profile; | 21 class Profile; |
|
droger
2015/10/27 12:23:44
Remove Profile, here and in comments below (lines
Jitu( very slow this week)
2015/10/28 05:11:36
Done.
| |
| 16 | 22 |
| 17 namespace user_prefs { | 23 namespace user_prefs { |
| 18 class PrefRegistrySyncable; | 24 class PrefRegistrySyncable; |
| 19 } | 25 } |
| 20 | 26 |
| 21 namespace gcm { | 27 namespace gcm { |
| 22 | 28 |
| 23 class GCMClientFactory; | 29 class GCMClientFactory; |
| 24 class GCMDriver; | 30 class GCMDriver; |
| 25 | 31 |
| 26 #if defined(OS_CHROMEOS) | 32 #if defined(OS_CHROMEOS) |
| 27 class GCMConnectionObserver; | 33 class GCMConnectionObserver; |
| 28 #endif | 34 #endif |
| 29 | 35 |
| 30 // Providing GCM service, via GCMDriver, to a profile. | 36 // Providing GCM service, via GCMDriver, to a profile. |
| 31 class GCMProfileService : public KeyedService { | 37 class GCMProfileService : public KeyedService { |
| 32 public: | 38 public: |
| 33 // Returns whether GCM is enabled for |profile|. | 39 // Returns whether GCM is enabled for |profile|. |
| 34 static bool IsGCMEnabled(Profile* profile); | 40 static bool IsGCMEnabled(PrefService* prefs); |
| 35 | 41 |
| 36 #if defined(OS_ANDROID) | 42 #if defined(OS_ANDROID) |
| 37 explicit GCMProfileService(Profile* profile); | 43 explicit GCMProfileService( |
| 44 base::FilePath path, | |
| 45 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner); | |
| 38 #else | 46 #else |
| 39 GCMProfileService(Profile* profile, | 47 GCMProfileService( |
| 40 scoped_ptr<GCMClientFactory> gcm_client_factory); | 48 PrefService* prefs, |
| 49 base::FilePath path, | |
| 50 net::URLRequestContextGetter* request_context, | |
| 51 version_info::Channel channel, | |
| 52 SigninManagerBase* signin_manager, | |
| 53 ProfileOAuth2TokenService* profile_o_auth_2_token_service, | |
| 54 const base::Closure& login_callback, | |
| 55 scoped_ptr<GCMClientFactory> gcm_client_factory, | |
| 56 const scoped_refptr<base::SequencedTaskRunner>& ui_task_runner, | |
| 57 const scoped_refptr<base::SequencedTaskRunner>& io_task_runner, | |
| 58 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner); | |
| 41 #endif | 59 #endif |
| 42 ~GCMProfileService() override; | 60 ~GCMProfileService() override; |
| 43 | 61 |
| 44 // KeyedService: | 62 // KeyedService: |
| 45 void Shutdown() override; | 63 void Shutdown() override; |
| 46 | 64 |
| 47 // For testing purpose. | 65 // For testing purpose. |
| 48 void SetDriverForTesting(GCMDriver* driver); | 66 void SetDriverForTesting(const base::Closure& login_callback, |
| 67 GCMDriver* driver); | |
| 49 | 68 |
| 50 GCMDriver* driver() const { return driver_.get(); } | 69 GCMDriver* driver() const { return driver_.get(); } |
| 51 | 70 |
| 52 protected: | 71 protected: |
| 53 // Used for constructing fake GCMProfileService for testing purpose. | 72 // Used for constructing fake GCMProfileService for testing purpose. |
| 54 GCMProfileService(); | 73 GCMProfileService(); |
| 55 | 74 |
| 56 private: | 75 private: |
| 57 // The profile which owns this object. | 76 SigninManagerBase* signin_manager_; |
| 58 Profile* profile_; | 77 ProfileOAuth2TokenService* profile_o_auth_2_token_service_; |
| 78 net::URLRequestContextGetter* request_context_; | |
| 59 | 79 |
| 60 scoped_ptr<GCMDriver> driver_; | 80 scoped_ptr<GCMDriver> driver_; |
| 61 | 81 |
| 62 // Used for both account tracker and GCM.UserSignedIn UMA. | 82 // Used for both account tracker and GCM.UserSignedIn UMA. |
| 63 #if !defined(OS_ANDROID) | 83 #if !defined(OS_ANDROID) |
| 64 class IdentityObserver; | 84 class IdentityObserver; |
| 65 scoped_ptr<IdentityObserver> identity_observer_; | 85 scoped_ptr<IdentityObserver> identity_observer_; |
| 66 #endif | 86 #endif |
| 67 | 87 |
| 68 DISALLOW_COPY_AND_ASSIGN(GCMProfileService); | 88 DISALLOW_COPY_AND_ASSIGN(GCMProfileService); |
| 69 }; | 89 }; |
| 70 | 90 |
| 71 } // namespace gcm | 91 } // namespace gcm |
| 72 | 92 |
| 73 #endif // CHROME_BROWSER_SERVICES_GCM_GCM_PROFILE_SERVICE_H_ | 93 #endif // CHROME_BROWSER_SERVICES_GCM_GCM_PROFILE_SERVICE_H_ |
| OLD | NEW |