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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/common/chrome_constants.h" | 12 #include "chrome/common/chrome_constants.h" |
13 #include "components/gcm_driver/gcm_driver.h" | 13 #include "components/gcm_driver/gcm_driver.h" |
14 #include "components/pref_registry/pref_registry_syncable.h" | 14 #include "components/pref_registry/pref_registry_syncable.h" |
15 | 15 |
16 #if defined(OS_ANDROID) | 16 #if defined(OS_ANDROID) |
17 #include "base/sequenced_task_runner.h" | 17 #include "base/sequenced_task_runner.h" |
18 #include "base/threading/sequenced_worker_pool.h" | 18 #include "base/threading/sequenced_worker_pool.h" |
19 #include "components/gcm_driver/gcm_driver_android.h" | 19 #include "components/gcm_driver/gcm_driver_android.h" |
20 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
21 #else | 21 #else |
22 #include "base/bind.h" | 22 #include "base/bind.h" |
23 #include "base/files/file_path.h" | 23 #include "base/files/file_path.h" |
24 #include "base/memory/weak_ptr.h" | 24 #include "base/memory/weak_ptr.h" |
| 25 #include "chrome/browser/services/gcm/gcm_desktop_utils.h" |
25 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 26 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
26 #include "chrome/browser/signin/signin_manager_factory.h" | 27 #include "chrome/browser/signin/signin_manager_factory.h" |
27 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" | 28 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
28 #include "chrome/common/channel_info.h" | |
29 #include "components/gcm_driver/gcm_account_tracker.h" | 29 #include "components/gcm_driver/gcm_account_tracker.h" |
30 #include "components/gcm_driver/gcm_channel_status_syncer.h" | 30 #include "components/gcm_driver/gcm_channel_status_syncer.h" |
31 #include "components/gcm_driver/gcm_client_factory.h" | 31 #include "components/gcm_driver/gcm_client_factory.h" |
32 #include "components/gcm_driver/gcm_desktop_utils.h" | |
33 #include "components/gcm_driver/gcm_driver_desktop.h" | 32 #include "components/gcm_driver/gcm_driver_desktop.h" |
34 #include "components/signin/core/browser/profile_identity_provider.h" | 33 #include "components/signin/core/browser/profile_identity_provider.h" |
35 #include "components/signin/core/browser/signin_manager.h" | 34 #include "components/signin/core/browser/signin_manager.h" |
36 #include "content/public/browser/browser_thread.h" | |
37 #include "google_apis/gaia/account_tracker.h" | 35 #include "google_apis/gaia/account_tracker.h" |
38 #include "google_apis/gaia/identity_provider.h" | 36 #include "google_apis/gaia/identity_provider.h" |
39 #include "net/url_request/url_request_context_getter.h" | 37 #include "net/url_request/url_request_context_getter.h" |
40 #endif | 38 #endif |
41 | 39 |
42 namespace gcm { | 40 namespace gcm { |
43 | 41 |
44 #if !defined(OS_ANDROID) | 42 #if !defined(OS_ANDROID) |
45 // Identity observer only has actual work to do when the user is actually signed | 43 // Identity observer only has actual work to do when the user is actually signed |
46 // in. It ensures that account tracker is taking | 44 // in. It ensures that account tracker is taking |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 profile_->GetPath().Append(chrome::kGCMStoreDirname), | 167 profile_->GetPath().Append(chrome::kGCMStoreDirname), |
170 blocking_task_runner)); | 168 blocking_task_runner)); |
171 } | 169 } |
172 #else | 170 #else |
173 GCMProfileService::GCMProfileService( | 171 GCMProfileService::GCMProfileService( |
174 Profile* profile, | 172 Profile* profile, |
175 scoped_ptr<GCMClientFactory> gcm_client_factory) | 173 scoped_ptr<GCMClientFactory> gcm_client_factory) |
176 : profile_(profile) { | 174 : profile_(profile) { |
177 DCHECK(!profile->IsOffTheRecord()); | 175 DCHECK(!profile->IsOffTheRecord()); |
178 | 176 |
179 base::SequencedWorkerPool* worker_pool = | |
180 content::BrowserThread::GetBlockingPool(); | |
181 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner( | |
182 worker_pool->GetSequencedTaskRunnerWithShutdownBehavior( | |
183 worker_pool->GetSequenceToken(), | |
184 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); | |
185 | |
186 driver_ = CreateGCMDriverDesktop( | 177 driver_ = CreateGCMDriverDesktop( |
187 gcm_client_factory.Pass(), | 178 gcm_client_factory.Pass(), |
188 profile_->GetPrefs(), | 179 profile_->GetPrefs(), |
189 profile_->GetPath().Append(chrome::kGCMStoreDirname), | 180 profile_->GetPath().Append(chrome::kGCMStoreDirname), |
190 profile_->GetRequestContext(), | 181 profile_->GetRequestContext()); |
191 chrome::GetChannel(), | |
192 content::BrowserThread::GetMessageLoopProxyForThread( | |
193 content::BrowserThread::UI), | |
194 content::BrowserThread::GetMessageLoopProxyForThread( | |
195 content::BrowserThread::IO), | |
196 blocking_task_runner); | |
197 | 182 |
198 identity_observer_.reset(new IdentityObserver(profile, driver_.get())); | 183 identity_observer_.reset(new IdentityObserver(profile, driver_.get())); |
199 } | 184 } |
200 #endif // defined(OS_ANDROID) | 185 #endif // defined(OS_ANDROID) |
201 | 186 |
202 GCMProfileService::GCMProfileService() | 187 GCMProfileService::GCMProfileService() |
203 : profile_(NULL) { | 188 : profile_(NULL) { |
204 } | 189 } |
205 | 190 |
206 GCMProfileService::~GCMProfileService() { | 191 GCMProfileService::~GCMProfileService() { |
(...skipping 14 matching lines...) Expand all Loading... |
221 | 206 |
222 void GCMProfileService::SetDriverForTesting(GCMDriver* driver) { | 207 void GCMProfileService::SetDriverForTesting(GCMDriver* driver) { |
223 driver_.reset(driver); | 208 driver_.reset(driver); |
224 #if !defined(OS_ANDROID) | 209 #if !defined(OS_ANDROID) |
225 if (identity_observer_) | 210 if (identity_observer_) |
226 identity_observer_.reset(new IdentityObserver(profile_, driver)); | 211 identity_observer_.reset(new IdentityObserver(profile_, driver)); |
227 #endif // !defined(OS_ANDROID) | 212 #endif // !defined(OS_ANDROID) |
228 } | 213 } |
229 | 214 |
230 } // namespace gcm | 215 } // namespace gcm |
OLD | NEW |