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

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

Issue 597683005: GCM: D-Bus methods for wake-on-packet (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Resolved DEPS conflict Created 6 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 <map> 7 #include <map>
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/pref_names.h" 12 #include "chrome/common/pref_names.h"
13 #include "components/pref_registry/pref_registry_syncable.h" 13 #include "components/pref_registry/pref_registry_syncable.h"
14 14
15 #if defined(OS_ANDROID) 15 #if defined(OS_ANDROID)
16 #include "components/gcm_driver/gcm_driver_android.h" 16 #include "components/gcm_driver/gcm_driver_android.h"
17 #else 17 #else
18 #include "base/bind.h" 18 #include "base/bind.h"
19 #if defined(OS_CHROMEOS)
20 #include "chrome/browser/services/gcm/chromeos_gcm_connection_observer.h"
21 #endif
19 #include "base/files/file_path.h" 22 #include "base/files/file_path.h"
20 #include "base/memory/weak_ptr.h" 23 #include "base/memory/weak_ptr.h"
21 #include "chrome/browser/services/gcm/gcm_account_tracker.h" 24 #include "chrome/browser/services/gcm/gcm_account_tracker.h"
22 #include "chrome/browser/services/gcm/gcm_desktop_utils.h" 25 #include "chrome/browser/services/gcm/gcm_desktop_utils.h"
23 #include "chrome/browser/signin/profile_identity_provider.h" 26 #include "chrome/browser/signin/profile_identity_provider.h"
24 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 27 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
25 #include "chrome/browser/signin/signin_manager_factory.h" 28 #include "chrome/browser/signin/signin_manager_factory.h"
26 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" 29 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
27 #include "chrome/common/chrome_constants.h" 30 #include "chrome/common/chrome_constants.h"
28 #include "components/gcm_driver/gcm_client_factory.h" 31 #include "components/gcm_driver/gcm_client_factory.h"
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 : profile_(profile), 166 : profile_(profile),
164 push_messaging_service_(this, profile) { 167 push_messaging_service_(this, profile) {
165 DCHECK(!profile->IsOffTheRecord()); 168 DCHECK(!profile->IsOffTheRecord());
166 169
167 driver_ = CreateGCMDriverDesktop( 170 driver_ = CreateGCMDriverDesktop(
168 gcm_client_factory.Pass(), 171 gcm_client_factory.Pass(),
169 profile_->GetPrefs(), 172 profile_->GetPrefs(),
170 profile_->GetPath().Append(chrome::kGCMStoreDirname), 173 profile_->GetPath().Append(chrome::kGCMStoreDirname),
171 profile_->GetRequestContext()); 174 profile_->GetRequestContext());
172 175
176 #if defined(OS_CHROMEOS)
177 chromeos_connection_observer_.reset(new gcm::ChromeOSGCMConnectionObserver);
178 driver_->AddConnectionObserver(chromeos_connection_observer_.get());
179 #endif
180
173 identity_observer_.reset(new IdentityObserver( 181 identity_observer_.reset(new IdentityObserver(
174 profile, static_cast<gcm::GCMDriverDesktop*>(driver_.get()))); 182 profile, static_cast<gcm::GCMDriverDesktop*>(driver_.get())));
175 } 183 }
176 #endif // defined(OS_ANDROID) 184 #endif // defined(OS_ANDROID)
177 185
178 GCMProfileService::GCMProfileService() 186 GCMProfileService::GCMProfileService()
179 : profile_(NULL), 187 : profile_(NULL),
180 push_messaging_service_(this, NULL) { 188 push_messaging_service_(this, NULL) {
181 } 189 }
182 190
(...skipping 15 matching lines...) Expand all
198 const std::vector<std::string>& sender_ids, 206 const std::vector<std::string>& sender_ids,
199 const GCMDriver::RegisterCallback& callback) { 207 const GCMDriver::RegisterCallback& callback) {
200 if (driver_) 208 if (driver_)
201 driver_->Register(app_id, sender_ids, callback); 209 driver_->Register(app_id, sender_ids, callback);
202 } 210 }
203 211
204 void GCMProfileService::Shutdown() { 212 void GCMProfileService::Shutdown() {
205 #if !defined(OS_ANDROID) 213 #if !defined(OS_ANDROID)
206 identity_observer_.reset(); 214 identity_observer_.reset();
207 #endif // !defined(OS_ANDROID) 215 #endif // !defined(OS_ANDROID)
208
209 if (driver_) { 216 if (driver_) {
217 #if defined(OS_CHROMEOS)
218 driver_->RemoveConnectionObserver(chromeos_connection_observer_.get());
219 chromeos_connection_observer_.reset();
220 #endif
210 driver_->Shutdown(); 221 driver_->Shutdown();
211 driver_.reset(); 222 driver_.reset();
212 } 223 }
213 } 224 }
214 225
215 std::string GCMProfileService::SignedInUserName() const { 226 std::string GCMProfileService::SignedInUserName() const {
216 #if defined(OS_ANDROID) 227 #if defined(OS_ANDROID)
217 return std::string(); 228 return std::string();
218 #else 229 #else
219 return identity_observer_ ? identity_observer_->SignedInUserName() 230 return identity_observer_ ? identity_observer_->SignedInUserName()
220 : std::string(); 231 : std::string();
221 #endif // defined(OS_ANDROID) 232 #endif // defined(OS_ANDROID)
222 } 233 }
223 234
224 void GCMProfileService::SetDriverForTesting(GCMDriver* driver) { 235 void GCMProfileService::SetDriverForTesting(GCMDriver* driver) {
225 driver_.reset(driver); 236 driver_.reset(driver);
226 } 237 }
227 238
228 } // namespace gcm 239 } // namespace gcm
OLDNEW
« no previous file with comments | « chrome/browser/services/gcm/gcm_profile_service.h ('k') | chrome/browser/services/gcm/gcm_profile_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698