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

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

Issue 584753002: Revert of GCM: D-Bus methods for wake-on-packet (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
22 #include "base/files/file_path.h" 19 #include "base/files/file_path.h"
23 #include "base/memory/weak_ptr.h" 20 #include "base/memory/weak_ptr.h"
24 #include "chrome/browser/services/gcm/gcm_account_tracker.h" 21 #include "chrome/browser/services/gcm/gcm_account_tracker.h"
25 #include "chrome/browser/services/gcm/gcm_desktop_utils.h" 22 #include "chrome/browser/services/gcm/gcm_desktop_utils.h"
26 #include "chrome/browser/signin/profile_identity_provider.h" 23 #include "chrome/browser/signin/profile_identity_provider.h"
27 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 24 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
28 #include "chrome/browser/signin/signin_manager_factory.h" 25 #include "chrome/browser/signin/signin_manager_factory.h"
29 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" 26 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
30 #include "chrome/common/chrome_constants.h" 27 #include "chrome/common/chrome_constants.h"
31 #include "components/gcm_driver/gcm_client_factory.h" 28 #include "components/gcm_driver/gcm_client_factory.h"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 scoped_ptr<GCMClientFactory> gcm_client_factory) 160 scoped_ptr<GCMClientFactory> gcm_client_factory)
164 : profile_(profile), 161 : profile_(profile),
165 push_messaging_service_(this, profile) { 162 push_messaging_service_(this, profile) {
166 DCHECK(!profile->IsOffTheRecord()); 163 DCHECK(!profile->IsOffTheRecord());
167 164
168 driver_ = CreateGCMDriverDesktop( 165 driver_ = CreateGCMDriverDesktop(
169 gcm_client_factory.Pass(), 166 gcm_client_factory.Pass(),
170 profile_->GetPath().Append(chrome::kGCMStoreDirname), 167 profile_->GetPath().Append(chrome::kGCMStoreDirname),
171 profile_->GetRequestContext()); 168 profile_->GetRequestContext());
172 169
173 #ifdef CHROMEOS
174 chromeos_connection_observer_.reset(new gcm::ChromeOSGCMConnectionObserver);
175 driver_->AddConnectionObserver(chromeos_connection_observer_.get());
176 #endif
177
178 identity_observer_.reset(new IdentityObserver( 170 identity_observer_.reset(new IdentityObserver(
179 profile, static_cast<gcm::GCMDriverDesktop*>(driver_.get()))); 171 profile, static_cast<gcm::GCMDriverDesktop*>(driver_.get())));
180 } 172 }
181 #endif // defined(OS_ANDROID) 173 #endif // defined(OS_ANDROID)
182 174
183 GCMProfileService::GCMProfileService() 175 GCMProfileService::GCMProfileService()
184 : profile_(NULL), 176 : profile_(NULL),
185 push_messaging_service_(this, NULL) { 177 push_messaging_service_(this, NULL) {
186 } 178 }
187 179
(...skipping 15 matching lines...) Expand all
203 const std::vector<std::string>& sender_ids, 195 const std::vector<std::string>& sender_ids,
204 const GCMDriver::RegisterCallback& callback) { 196 const GCMDriver::RegisterCallback& callback) {
205 if (driver_) 197 if (driver_)
206 driver_->Register(app_id, sender_ids, callback); 198 driver_->Register(app_id, sender_ids, callback);
207 } 199 }
208 200
209 void GCMProfileService::Shutdown() { 201 void GCMProfileService::Shutdown() {
210 #if !defined(OS_ANDROID) 202 #if !defined(OS_ANDROID)
211 identity_observer_.reset(); 203 identity_observer_.reset();
212 #endif // !defined(OS_ANDROID) 204 #endif // !defined(OS_ANDROID)
213 #if defined(OS_CHROMEOS)
214 driver_->RemoveConnectionObserver(chromeos_connection_observer_.get());
215 chromeos_connection_observer_.reset();
216 #endif
217 205
218 if (driver_) { 206 if (driver_) {
219 driver_->Shutdown(); 207 driver_->Shutdown();
220 driver_.reset(); 208 driver_.reset();
221 } 209 }
222 } 210 }
223 211
224 std::string GCMProfileService::SignedInUserName() const { 212 std::string GCMProfileService::SignedInUserName() const {
225 #if defined(OS_ANDROID) 213 #if defined(OS_ANDROID)
226 return std::string(); 214 return std::string();
227 #else 215 #else
228 return identity_observer_ ? identity_observer_->SignedInUserName() 216 return identity_observer_ ? identity_observer_->SignedInUserName()
229 : std::string(); 217 : std::string();
230 #endif // defined(OS_ANDROID) 218 #endif // defined(OS_ANDROID)
231 } 219 }
232 220
233 void GCMProfileService::SetDriverForTesting(GCMDriver* driver) { 221 void GCMProfileService::SetDriverForTesting(GCMDriver* driver) {
234 driver_.reset(driver); 222 driver_.reset(driver);
235 } 223 }
236 224
237 } // namespace gcm 225 } // 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