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_driver.h" | 12 #include "chrome/browser/services/gcm/gcm_driver.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_driver/gcm_client_factory.h" | 19 #include "components/gcm_driver/gcm_client_factory.h" |
20 #include "components/pref_registry/pref_registry_syncable.h" | 20 #include "components/pref_registry/pref_registry_syncable.h" |
21 #include "components/signin/core/browser/signin_manager.h" | 21 #include "components/signin/core/browser/signin_manager.h" |
| 22 #include "content/public/browser/browser_thread.h" |
22 #include "google_apis/gaia/identity_provider.h" | 23 #include "google_apis/gaia/identity_provider.h" |
23 #include "net/url_request/url_request_context_getter.h" | 24 #include "net/url_request/url_request_context_getter.h" |
24 | 25 |
25 #if !defined(OS_ANDROID) | 26 #if !defined(OS_ANDROID) |
26 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" | 27 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
27 #endif | 28 #endif |
28 | 29 |
29 namespace gcm { | 30 namespace gcm { |
30 | 31 |
31 // static | 32 // static |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 on_by_default, | 75 on_by_default, |
75 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 76 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
76 } | 77 } |
77 | 78 |
78 GCMProfileService::GCMProfileService( | 79 GCMProfileService::GCMProfileService( |
79 Profile* profile, | 80 Profile* profile, |
80 scoped_ptr<GCMClientFactory> gcm_client_factory) | 81 scoped_ptr<GCMClientFactory> gcm_client_factory) |
81 : profile_(profile) { | 82 : profile_(profile) { |
82 DCHECK(!profile->IsOffTheRecord()); | 83 DCHECK(!profile->IsOffTheRecord()); |
83 | 84 |
| 85 scoped_refptr<base::SequencedWorkerPool> worker_pool( |
| 86 content::BrowserThread::GetBlockingPool()); |
| 87 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner( |
| 88 worker_pool->GetSequencedTaskRunnerWithShutdownBehavior( |
| 89 worker_pool->GetSequenceToken(), |
| 90 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); |
| 91 |
84 #if defined(OS_ANDROID) | 92 #if defined(OS_ANDROID) |
85 LoginUIService* login_ui_service = NULL; | 93 LoginUIService* login_ui_service = NULL; |
86 #else | 94 #else |
87 LoginUIService* login_ui_service = | 95 LoginUIService* login_ui_service = |
88 LoginUIServiceFactory::GetForProfile(profile_); | 96 LoginUIServiceFactory::GetForProfile(profile_); |
89 #endif | 97 #endif |
90 driver_.reset(new GCMDriver( | 98 driver_.reset(new GCMDriver( |
91 gcm_client_factory.Pass(), | 99 gcm_client_factory.Pass(), |
92 scoped_ptr<IdentityProvider>(new ProfileIdentityProvider( | 100 scoped_ptr<IdentityProvider>(new ProfileIdentityProvider( |
93 SigninManagerFactory::GetForProfile(profile_), | 101 SigninManagerFactory::GetForProfile(profile_), |
94 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_), | 102 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_), |
95 login_ui_service)), | 103 login_ui_service)), |
96 profile_->GetPath().Append(chrome::kGCMStoreDirname), | 104 profile_->GetPath().Append(chrome::kGCMStoreDirname), |
97 profile_->GetRequestContext())); | 105 profile_->GetRequestContext(), |
| 106 content::BrowserThread::GetMessageLoopProxyForThread( |
| 107 content::BrowserThread::UI), |
| 108 content::BrowserThread::GetMessageLoopProxyForThread( |
| 109 content::BrowserThread::IO), |
| 110 blocking_task_runner)); |
98 } | 111 } |
99 | 112 |
100 GCMProfileService::GCMProfileService() : profile_(NULL) { | 113 GCMProfileService::GCMProfileService() : profile_(NULL) { |
101 } | 114 } |
102 | 115 |
103 GCMProfileService::~GCMProfileService() { | 116 GCMProfileService::~GCMProfileService() { |
104 } | 117 } |
105 | 118 |
106 void GCMProfileService::AddAppHandler(const std::string& app_id, | 119 void GCMProfileService::AddAppHandler(const std::string& app_id, |
107 GCMAppHandler* handler) { | 120 GCMAppHandler* handler) { |
(...skipping 18 matching lines...) Expand all Loading... |
126 driver_->Shutdown(); | 139 driver_->Shutdown(); |
127 driver_.reset(); | 140 driver_.reset(); |
128 } | 141 } |
129 } | 142 } |
130 | 143 |
131 void GCMProfileService::SetDriverForTesting(GCMDriver* driver) { | 144 void GCMProfileService::SetDriverForTesting(GCMDriver* driver) { |
132 driver_.reset(driver); | 145 driver_.reset(driver); |
133 } | 146 } |
134 | 147 |
135 } // namespace gcm | 148 } // namespace gcm |
OLD | NEW |