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

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

Issue 409883006: GCM: D-Bus methods for wake-on-packet (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: don't break windows build 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 | Annotate | Revision Log
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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 scoped_ptr<GCMClientFactory> gcm_client_factory) 163 scoped_ptr<GCMClientFactory> gcm_client_factory)
161 : profile_(profile), 164 : profile_(profile),
162 push_messaging_service_(this, profile) { 165 push_messaging_service_(this, profile) {
163 DCHECK(!profile->IsOffTheRecord()); 166 DCHECK(!profile->IsOffTheRecord());
164 167
165 driver_ = CreateGCMDriverDesktop( 168 driver_ = CreateGCMDriverDesktop(
166 gcm_client_factory.Pass(), 169 gcm_client_factory.Pass(),
167 profile_->GetPath().Append(chrome::kGCMStoreDirname), 170 profile_->GetPath().Append(chrome::kGCMStoreDirname),
168 profile_->GetRequestContext()); 171 profile_->GetRequestContext());
169 172
173 #ifdef CHROMEOS
174 chromeos_connection_observer_.reset(new gcm::ChromeOSGCMConnectionObserver);
175 driver_->AddConnectionObserver(chromeos_connection_observer_.get());
176 #endif
177
170 identity_observer_.reset(new IdentityObserver( 178 identity_observer_.reset(new IdentityObserver(
171 profile, static_cast<gcm::GCMDriverDesktop*>(driver_.get()))); 179 profile, static_cast<gcm::GCMDriverDesktop*>(driver_.get())));
172 } 180 }
173 #endif // defined(OS_ANDROID) 181 #endif // defined(OS_ANDROID)
174 182
175 GCMProfileService::GCMProfileService() 183 GCMProfileService::GCMProfileService()
176 : profile_(NULL), 184 : profile_(NULL),
177 push_messaging_service_(this, NULL) { 185 push_messaging_service_(this, NULL) {
178 } 186 }
179 187
(...skipping 15 matching lines...) Expand all
195 const std::vector<std::string>& sender_ids, 203 const std::vector<std::string>& sender_ids,
196 const GCMDriver::RegisterCallback& callback) { 204 const GCMDriver::RegisterCallback& callback) {
197 if (driver_) 205 if (driver_)
198 driver_->Register(app_id, sender_ids, callback); 206 driver_->Register(app_id, sender_ids, callback);
199 } 207 }
200 208
201 void GCMProfileService::Shutdown() { 209 void GCMProfileService::Shutdown() {
202 #if !defined(OS_ANDROID) 210 #if !defined(OS_ANDROID)
203 identity_observer_.reset(); 211 identity_observer_.reset();
204 #endif // !defined(OS_ANDROID) 212 #endif // !defined(OS_ANDROID)
213 #if defined(OS_CHROMEOS)
214 driver_->RemoveConnectionObserver(chromeos_connection_observer_.get());
215 chromeos_connection_observer_.reset();
216 #endif
205 217
206 if (driver_) { 218 if (driver_) {
207 driver_->Shutdown(); 219 driver_->Shutdown();
208 driver_.reset(); 220 driver_.reset();
209 } 221 }
210 } 222 }
211 223
212 std::string GCMProfileService::SignedInUserName() const { 224 std::string GCMProfileService::SignedInUserName() const {
213 #if defined(OS_ANDROID) 225 #if defined(OS_ANDROID)
214 return std::string(); 226 return std::string();
215 #else 227 #else
216 return identity_observer_ ? identity_observer_->SignedInUserName() 228 return identity_observer_ ? identity_observer_->SignedInUserName()
217 : std::string(); 229 : std::string();
218 #endif // defined(OS_ANDROID) 230 #endif // defined(OS_ANDROID)
219 } 231 }
220 232
221 void GCMProfileService::SetDriverForTesting(GCMDriver* driver) { 233 void GCMProfileService::SetDriverForTesting(GCMDriver* driver) {
222 driver_.reset(driver); 234 driver_.reset(driver);
223 } 235 }
224 236
225 } // namespace gcm 237 } // 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