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" | |
13 #include "components/gcm_driver/gcm_driver.h" | 12 #include "components/gcm_driver/gcm_driver.h" |
14 #include "components/pref_registry/pref_registry_syncable.h" | 13 #include "components/pref_registry/pref_registry_syncable.h" |
15 | 14 |
16 #if defined(OS_ANDROID) | 15 #if defined(OS_ANDROID) |
17 #include "base/sequenced_task_runner.h" | |
18 #include "base/threading/sequenced_worker_pool.h" | |
19 #include "components/gcm_driver/gcm_driver_android.h" | 16 #include "components/gcm_driver/gcm_driver_android.h" |
20 #include "content/public/browser/browser_thread.h" | |
21 #else | 17 #else |
22 #include "base/bind.h" | 18 #include "base/bind.h" |
23 #include "base/files/file_path.h" | 19 #include "base/files/file_path.h" |
24 #include "base/memory/weak_ptr.h" | 20 #include "base/memory/weak_ptr.h" |
25 #include "chrome/browser/services/gcm/gcm_account_tracker.h" | 21 #include "chrome/browser/services/gcm/gcm_account_tracker.h" |
26 #include "chrome/browser/services/gcm/gcm_desktop_utils.h" | 22 #include "chrome/browser/services/gcm/gcm_desktop_utils.h" |
27 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 23 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
28 #include "chrome/browser/signin/signin_manager_factory.h" | 24 #include "chrome/browser/signin/signin_manager_factory.h" |
29 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" | 25 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
| 26 #include "chrome/common/chrome_constants.h" |
30 #include "components/gcm_driver/gcm_channel_status_syncer.h" | 27 #include "components/gcm_driver/gcm_channel_status_syncer.h" |
31 #include "components/gcm_driver/gcm_client_factory.h" | 28 #include "components/gcm_driver/gcm_client_factory.h" |
32 #include "components/gcm_driver/gcm_driver_desktop.h" | 29 #include "components/gcm_driver/gcm_driver_desktop.h" |
33 #include "components/signin/core/browser/profile_identity_provider.h" | 30 #include "components/signin/core/browser/profile_identity_provider.h" |
34 #include "components/signin/core/browser/signin_manager.h" | 31 #include "components/signin/core/browser/signin_manager.h" |
35 #include "google_apis/gaia/account_tracker.h" | 32 #include "google_apis/gaia/account_tracker.h" |
36 #include "google_apis/gaia/identity_provider.h" | 33 #include "google_apis/gaia/identity_provider.h" |
37 #include "net/url_request/url_request_context_getter.h" | 34 #include "net/url_request/url_request_context_getter.h" |
38 #endif | 35 #endif |
39 | 36 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 << debug_instance->profile_->GetStartTime().ToInternalValue() | 146 << debug_instance->profile_->GetStartTime().ToInternalValue() |
150 << ", new profile: " << profile << " " | 147 << ", new profile: " << profile << " " |
151 << profile->GetDebugName() << " " | 148 << profile->GetDebugName() << " " |
152 << profile->GetProfileType() << " " | 149 << profile->GetProfileType() << " " |
153 << profile->IsSupervised() << " " | 150 << profile->IsSupervised() << " " |
154 << profile->IsNewProfile() << " " | 151 << profile->IsNewProfile() << " " |
155 << profile->GetStartTime().ToInternalValue(); | 152 << profile->GetStartTime().ToInternalValue(); |
156 } | 153 } |
157 debug_instance = this; | 154 debug_instance = this; |
158 | 155 |
159 scoped_refptr<base::SequencedWorkerPool> worker_pool( | 156 driver_.reset(new GCMDriverAndroid); |
160 content::BrowserThread::GetBlockingPool()); | |
161 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner( | |
162 worker_pool->GetSequencedTaskRunnerWithShutdownBehavior( | |
163 worker_pool->GetSequenceToken(), | |
164 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); | |
165 | |
166 driver_.reset(new GCMDriverAndroid( | |
167 profile_->GetPath().Append(chrome::kGCMStoreDirname), | |
168 blocking_task_runner)); | |
169 } | 157 } |
170 #else | 158 #else |
171 GCMProfileService::GCMProfileService( | 159 GCMProfileService::GCMProfileService( |
172 Profile* profile, | 160 Profile* profile, |
173 scoped_ptr<GCMClientFactory> gcm_client_factory) | 161 scoped_ptr<GCMClientFactory> gcm_client_factory) |
174 : profile_(profile) { | 162 : profile_(profile) { |
175 DCHECK(!profile->IsOffTheRecord()); | 163 DCHECK(!profile->IsOffTheRecord()); |
176 | 164 |
177 driver_ = CreateGCMDriverDesktop( | 165 driver_ = CreateGCMDriverDesktop( |
178 gcm_client_factory.Pass(), | 166 gcm_client_factory.Pass(), |
(...skipping 27 matching lines...) Expand all Loading... |
206 | 194 |
207 void GCMProfileService::SetDriverForTesting(GCMDriver* driver) { | 195 void GCMProfileService::SetDriverForTesting(GCMDriver* driver) { |
208 driver_.reset(driver); | 196 driver_.reset(driver); |
209 #if !defined(OS_ANDROID) | 197 #if !defined(OS_ANDROID) |
210 if (identity_observer_) | 198 if (identity_observer_) |
211 identity_observer_.reset(new IdentityObserver(profile_, driver)); | 199 identity_observer_.reset(new IdentityObserver(profile_, driver)); |
212 #endif // !defined(OS_ANDROID) | 200 #endif // !defined(OS_ANDROID) |
213 } | 201 } |
214 | 202 |
215 } // namespace gcm | 203 } // namespace gcm |
OLD | NEW |