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 #include "chrome/browser/services/gcm/gcm_profile_service.h" | 5 #include "chrome/browser/services/gcm/gcm_profile_service.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/services/gcm/gcm_utils.h" | 12 #include "chrome/browser/services/gcm/gcm_utils.h" |
| 13 #include "chrome/browser/signin/profile_identity_provider.h" | 13 #include "chrome/browser/signin/profile_identity_provider.h" |
| 14 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 14 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 15 #include "chrome/browser/signin/signin_manager_factory.h" | 15 #include "chrome/browser/signin/signin_manager_factory.h" |
| 16 #include "chrome/common/chrome_constants.h" | 16 #include "chrome/common/chrome_constants.h" |
| 17 #include "chrome/common/chrome_version_info.h" | 17 #include "chrome/common/chrome_version_info.h" |
| 18 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
| 19 #include "components/gcm/gcm_client_factory.h" | 19 #include "components/gcm/gcm_client_factory.h" |
| 20 #include "components/gcm/gcm_driver.h" | 20 #include "components/gcm/gcm_driver_desktop.h" |
| 21 #include "components/signin/core/browser/signin_manager.h" | 21 #include "components/signin/core/browser/signin_manager.h" |
| 22 #include "components/user_prefs/pref_registry_syncable.h" | 22 #include "components/user_prefs/pref_registry_syncable.h" |
| 23 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
| 24 #include "google_apis/gaia/identity_provider.h" | 24 #include "google_apis/gaia/identity_provider.h" |
| 25 #include "net/url_request/url_request_context_getter.h" | 25 #include "net/url_request/url_request_context_getter.h" |
| 26 | 26 |
| 27 #if !defined(OS_ANDROID) | 27 #if !defined(OS_ANDROID) |
| 28 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" | 28 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
| 29 #endif | 29 #endif |
| 30 | 30 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 72 on_by_default = true; | 72 on_by_default = true; |
| 73 } | 73 } |
| 74 registry->RegisterBooleanPref( | 74 registry->RegisterBooleanPref( |
| 75 prefs::kGCMChannelEnabled, | 75 prefs::kGCMChannelEnabled, |
| 76 on_by_default, | 76 on_by_default, |
| 77 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 77 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 78 } | 78 } |
| 79 | 79 |
| 80 GCMProfileService::GCMProfileService(Profile* profile) | 80 GCMProfileService::GCMProfileService(Profile* profile) |
| 81 : profile_(profile) { | 81 : profile_(profile) { |
| 82 DCHECK(!profile->IsOffTheRecord()); | 82 DCHECK(!profile->IsOffTheRecord()); |
|
fgorski
2014/05/07 18:50:14
There might be a few more headers to ifdef I think
johnme
2014/05/08 16:08:02
Done. Also removed a bunch of unused headers from
| |
| 83 } | 83 } |
| 84 | 84 |
| 85 GCMProfileService::~GCMProfileService() { | 85 GCMProfileService::~GCMProfileService() { |
| 86 } | 86 } |
| 87 | 87 |
| 88 void GCMProfileService::Initialize( | 88 void GCMProfileService::Initialize( |
| 89 scoped_ptr<GCMClientFactory> gcm_client_factory) { | 89 scoped_ptr<GCMClientFactory> gcm_client_factory) { |
| 90 DCHECK(!driver_); | 90 DCHECK(!driver_); |
| 91 | 91 |
| 92 #if defined(OS_ANDROID) | |
| 93 driver_.reset(new GCMDriverAndroid( | |
| 94 content::BrowserThread::GetMessageLoopProxyForThread( | |
| 95 content::BrowserThread::UI))); | |
| 96 #else | |
| 92 scoped_refptr<base::SequencedWorkerPool> worker_pool( | 97 scoped_refptr<base::SequencedWorkerPool> worker_pool( |
| 93 content::BrowserThread::GetBlockingPool()); | 98 content::BrowserThread::GetBlockingPool()); |
| 94 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner( | 99 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner( |
| 95 worker_pool->GetSequencedTaskRunnerWithShutdownBehavior( | 100 worker_pool->GetSequencedTaskRunnerWithShutdownBehavior( |
| 96 worker_pool->GetSequenceToken(), | 101 worker_pool->GetSequenceToken(), |
| 97 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); | 102 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); |
| 98 | 103 |
| 99 driver_.reset(new GCMDriver( | 104 driver_.reset(new GCMDriverDesktop( |
| 100 GetChromeBuildInfo(), | 105 GetChromeBuildInfo(), |
| 101 gcm_client_factory.Pass(), | 106 gcm_client_factory.Pass(), |
| 102 scoped_ptr<IdentityProvider>(new ProfileIdentityProvider( | 107 scoped_ptr<IdentityProvider>(new ProfileIdentityProvider( |
| 103 SigninManagerFactory::GetForProfile(profile_), | 108 SigninManagerFactory::GetForProfile(profile_), |
| 104 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_), | 109 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_), |
| 105 #if defined(OS_ANDROID) | |
| 106 NULL)), | |
| 107 #else | |
| 108 LoginUIServiceFactory::GetForProfile(profile_))), | 110 LoginUIServiceFactory::GetForProfile(profile_))), |
| 109 #endif | |
| 110 profile_->GetPath().Append(chrome::kGCMStoreDirname), | 111 profile_->GetPath().Append(chrome::kGCMStoreDirname), |
| 111 profile_->GetRequestContext(), | 112 profile_->GetRequestContext(), |
| 112 blocking_task_runner, | 113 blocking_task_runner, |
| 113 content::BrowserThread::GetMessageLoopProxyForThread( | 114 content::BrowserThread::GetMessageLoopProxyForThread( |
| 114 content::BrowserThread::UI), | 115 content::BrowserThread::UI), |
| 115 content::BrowserThread::GetMessageLoopProxyForThread( | 116 content::BrowserThread::GetMessageLoopProxyForThread( |
| 116 content::BrowserThread::IO))); | 117 content::BrowserThread::IO))); |
| 118 #endif | |
| 117 } | 119 } |
| 118 | 120 |
| 119 void GCMProfileService::Shutdown() { | 121 void GCMProfileService::Shutdown() { |
| 120 if (driver_) | 122 if (driver_) |
| 121 driver_->Shutdown(); | 123 driver_->Shutdown(); |
| 122 } | 124 } |
| 123 | 125 |
| 124 } // namespace gcm | 126 } // namespace gcm |
| OLD | NEW |