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 "components/gcm_driver/gcm_profile_service.h" | 5 #include "components/gcm_driver/gcm_profile_service.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
13 #include "components/gcm_driver/gcm_driver.h" | 13 #include "components/gcm_driver/gcm_driver.h" |
14 #include "components/gcm_driver/gcm_driver_constants.h" | 14 #include "components/gcm_driver/gcm_driver_constants.h" |
15 #include "components/pref_registry/pref_registry_syncable.h" | 15 #include "components/pref_registry/pref_registry_syncable.h" |
16 #include "components/prefs/pref_service.h" | 16 #include "components/prefs/pref_service.h" |
17 | 17 |
18 #if BUILDFLAG(USE_GCM_FROM_PLATFORM) | 18 #if BUILDFLAG(USE_GCM_FROM_PLATFORM) |
19 #include "base/sequenced_task_runner.h" | 19 #include "base/sequenced_task_runner.h" |
20 #include "base/threading/sequenced_worker_pool.h" | 20 #include "base/threading/sequenced_worker_pool.h" |
21 #include "components/gcm_driver/gcm_driver_android.h" | 21 #include "components/gcm_driver/gcm_driver_android.h" |
| 22 #include "components/gcm_driver/instance_id/instance_id_factory_android.h" |
22 #else | 23 #else |
23 #include "base/bind.h" | 24 #include "base/bind.h" |
24 #include "base/files/file_path.h" | 25 #include "base/files/file_path.h" |
| 26 #include "base/memory/ptr_util.h" |
25 #include "base/memory/weak_ptr.h" | 27 #include "base/memory/weak_ptr.h" |
26 #include "components/gcm_driver/gcm_account_tracker.h" | 28 #include "components/gcm_driver/gcm_account_tracker.h" |
27 #include "components/gcm_driver/gcm_channel_status_syncer.h" | 29 #include "components/gcm_driver/gcm_channel_status_syncer.h" |
28 #include "components/gcm_driver/gcm_client_factory.h" | 30 #include "components/gcm_driver/gcm_client_factory.h" |
29 #include "components/gcm_driver/gcm_desktop_utils.h" | 31 #include "components/gcm_driver/gcm_desktop_utils.h" |
30 #include "components/gcm_driver/gcm_driver_desktop.h" | 32 #include "components/gcm_driver/gcm_driver_desktop.h" |
| 33 #include "components/gcm_driver/instance_id/instance_id_impl_factory.h" |
31 #include "components/signin/core/browser/signin_manager.h" | 34 #include "components/signin/core/browser/signin_manager.h" |
32 #include "google_apis/gaia/account_tracker.h" | 35 #include "google_apis/gaia/account_tracker.h" |
33 #include "google_apis/gaia/identity_provider.h" | 36 #include "google_apis/gaia/identity_provider.h" |
34 #include "net/url_request/url_request_context_getter.h" | 37 #include "net/url_request/url_request_context_getter.h" |
35 #endif | 38 #endif |
36 | 39 |
37 namespace gcm { | 40 namespace gcm { |
38 | 41 |
39 #if !BUILDFLAG(USE_GCM_FROM_PLATFORM) | 42 #if !BUILDFLAG(USE_GCM_FROM_PLATFORM) |
40 // 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 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 return prefs->GetBoolean(gcm::prefs::kGCMChannelStatus); | 130 return prefs->GetBoolean(gcm::prefs::kGCMChannelStatus); |
128 #endif // BUILDFLAG(USE_GCM_FROM_PLATFORM) | 131 #endif // BUILDFLAG(USE_GCM_FROM_PLATFORM) |
129 } | 132 } |
130 | 133 |
131 #if BUILDFLAG(USE_GCM_FROM_PLATFORM) | 134 #if BUILDFLAG(USE_GCM_FROM_PLATFORM) |
132 GCMProfileService::GCMProfileService( | 135 GCMProfileService::GCMProfileService( |
133 base::FilePath path, | 136 base::FilePath path, |
134 scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner) { | 137 scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner) { |
135 driver_.reset(new GCMDriverAndroid(path.Append(gcm_driver::kGCMStoreDirname), | 138 driver_.reset(new GCMDriverAndroid(path.Append(gcm_driver::kGCMStoreDirname), |
136 blocking_task_runner)); | 139 blocking_task_runner)); |
| 140 instance_id_factory_ = |
| 141 base::MakeUnique<instance_id::InstanceIDAndroidFactory>(); |
137 } | 142 } |
138 #else | 143 #else |
139 GCMProfileService::GCMProfileService( | 144 GCMProfileService::GCMProfileService( |
140 PrefService* prefs, | 145 PrefService* prefs, |
141 base::FilePath path, | 146 base::FilePath path, |
142 net::URLRequestContextGetter* request_context, | 147 net::URLRequestContextGetter* request_context, |
143 version_info::Channel channel, | 148 version_info::Channel channel, |
144 const std::string& product_category_for_subtypes, | 149 const std::string& product_category_for_subtypes, |
145 std::unique_ptr<ProfileIdentityProvider> identity_provider, | 150 std::unique_ptr<ProfileIdentityProvider> identity_provider, |
146 std::unique_ptr<GCMClientFactory> gcm_client_factory, | 151 std::unique_ptr<GCMClientFactory> gcm_client_factory, |
147 const scoped_refptr<base::SequencedTaskRunner>& ui_task_runner, | 152 const scoped_refptr<base::SequencedTaskRunner>& ui_task_runner, |
148 const scoped_refptr<base::SequencedTaskRunner>& io_task_runner, | 153 const scoped_refptr<base::SequencedTaskRunner>& io_task_runner, |
149 scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner) | 154 scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner) |
150 : profile_identity_provider_(std::move(identity_provider)), | 155 : profile_identity_provider_(std::move(identity_provider)), |
151 request_context_(request_context) { | 156 request_context_(request_context) { |
152 driver_ = CreateGCMDriverDesktop( | 157 driver_ = CreateGCMDriverDesktop( |
153 std::move(gcm_client_factory), prefs, | 158 std::move(gcm_client_factory), prefs, |
154 path.Append(gcm_driver::kGCMStoreDirname), request_context_, channel, | 159 path.Append(gcm_driver::kGCMStoreDirname), request_context_, channel, |
155 product_category_for_subtypes, ui_task_runner, io_task_runner, | 160 product_category_for_subtypes, ui_task_runner, io_task_runner, |
156 blocking_task_runner); | 161 blocking_task_runner); |
| 162 instance_id_factory_ = base::MakeUnique<instance_id::InstanceIDImplFactory>(); |
157 | 163 |
158 identity_observer_.reset(new IdentityObserver( | 164 identity_observer_.reset(new IdentityObserver( |
159 profile_identity_provider_.get(), request_context_, driver_.get())); | 165 profile_identity_provider_.get(), request_context_, driver_.get())); |
160 } | 166 } |
161 #endif // BUILDFLAG(USE_GCM_FROM_PLATFORM) | 167 #endif // BUILDFLAG(USE_GCM_FROM_PLATFORM) |
162 | 168 |
163 GCMProfileService::GCMProfileService() {} | 169 GCMProfileService::GCMProfileService() {} |
164 | 170 |
165 GCMProfileService::~GCMProfileService() {} | 171 GCMProfileService::~GCMProfileService() {} |
166 | 172 |
(...skipping 11 matching lines...) Expand all Loading... |
178 driver_.reset(driver); | 184 driver_.reset(driver); |
179 #if !BUILDFLAG(USE_GCM_FROM_PLATFORM) | 185 #if !BUILDFLAG(USE_GCM_FROM_PLATFORM) |
180 if (identity_observer_) { | 186 if (identity_observer_) { |
181 identity_observer_.reset(new IdentityObserver( | 187 identity_observer_.reset(new IdentityObserver( |
182 profile_identity_provider_.get(), request_context_, driver)); | 188 profile_identity_provider_.get(), request_context_, driver)); |
183 } | 189 } |
184 #endif // !BUILDFLAG(USE_GCM_FROM_PLATFORM) | 190 #endif // !BUILDFLAG(USE_GCM_FROM_PLATFORM) |
185 } | 191 } |
186 | 192 |
187 } // namespace gcm | 193 } // namespace gcm |
OLD | NEW |