Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: chrome/browser/services/gcm/gcm_profile_service.cc

Issue 1325063002: Componentizing chrome/browser/services/gcm/gcm_desktop_utils.cc. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: exclude for android build Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
26 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 25 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
27 #include "chrome/browser/signin/signin_manager_factory.h" 26 #include "chrome/browser/signin/signin_manager_factory.h"
28 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" 27 #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"
32 #include "components/gcm_driver/gcm_driver_desktop.h" 33 #include "components/gcm_driver/gcm_driver_desktop.h"
33 #include "components/signin/core/browser/profile_identity_provider.h" 34 #include "components/signin/core/browser/profile_identity_provider.h"
34 #include "components/signin/core/browser/signin_manager.h" 35 #include "components/signin/core/browser/signin_manager.h"
36 #include "content/public/browser/browser_thread.h"
35 #include "google_apis/gaia/account_tracker.h" 37 #include "google_apis/gaia/account_tracker.h"
36 #include "google_apis/gaia/identity_provider.h" 38 #include "google_apis/gaia/identity_provider.h"
37 #include "net/url_request/url_request_context_getter.h" 39 #include "net/url_request/url_request_context_getter.h"
38 #endif 40 #endif
39 41
40 namespace gcm { 42 namespace gcm {
41 43
42 #if !defined(OS_ANDROID) 44 #if !defined(OS_ANDROID)
43 // Identity observer only has actual work to do when the user is actually signed 45 // Identity observer only has actual work to do when the user is actually signed
44 // in. It ensures that account tracker is taking 46 // in. It ensures that account tracker is taking
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 profile_->GetPath().Append(chrome::kGCMStoreDirname), 169 profile_->GetPath().Append(chrome::kGCMStoreDirname),
168 blocking_task_runner)); 170 blocking_task_runner));
169 } 171 }
170 #else 172 #else
171 GCMProfileService::GCMProfileService( 173 GCMProfileService::GCMProfileService(
172 Profile* profile, 174 Profile* profile,
173 scoped_ptr<GCMClientFactory> gcm_client_factory) 175 scoped_ptr<GCMClientFactory> gcm_client_factory)
174 : profile_(profile) { 176 : profile_(profile) {
175 DCHECK(!profile->IsOffTheRecord()); 177 DCHECK(!profile->IsOffTheRecord());
176 178
179 scoped_refptr<base::SequencedWorkerPool> worker_pool(
Lei Zhang 2015/09/03 04:53:27 Same.
Jitu( very slow this week) 2015/09/03 05:31:36 Done.
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
177 driver_ = CreateGCMDriverDesktop( 186 driver_ = CreateGCMDriverDesktop(
178 gcm_client_factory.Pass(), 187 gcm_client_factory.Pass(),
179 profile_->GetPrefs(), 188 profile_->GetPrefs(),
180 profile_->GetPath().Append(chrome::kGCMStoreDirname), 189 profile_->GetPath().Append(chrome::kGCMStoreDirname),
181 profile_->GetRequestContext()); 190 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);
182 197
183 identity_observer_.reset(new IdentityObserver(profile, driver_.get())); 198 identity_observer_.reset(new IdentityObserver(profile, driver_.get()));
184 } 199 }
185 #endif // defined(OS_ANDROID) 200 #endif // defined(OS_ANDROID)
186 201
187 GCMProfileService::GCMProfileService() 202 GCMProfileService::GCMProfileService()
188 : profile_(NULL) { 203 : profile_(NULL) {
189 } 204 }
190 205
191 GCMProfileService::~GCMProfileService() { 206 GCMProfileService::~GCMProfileService() {
(...skipping 14 matching lines...) Expand all
206 221
207 void GCMProfileService::SetDriverForTesting(GCMDriver* driver) { 222 void GCMProfileService::SetDriverForTesting(GCMDriver* driver) {
208 driver_.reset(driver); 223 driver_.reset(driver);
209 #if !defined(OS_ANDROID) 224 #if !defined(OS_ANDROID)
210 if (identity_observer_) 225 if (identity_observer_)
211 identity_observer_.reset(new IdentityObserver(profile_, driver)); 226 identity_observer_.reset(new IdentityObserver(profile_, driver));
212 #endif // !defined(OS_ANDROID) 227 #endif // !defined(OS_ANDROID)
213 } 228 }
214 229
215 } // namespace gcm 230 } // namespace gcm
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698