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

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

Issue 722043004: Clean up wake on wifi handling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments Created 6 years, 1 month 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
« no previous file with comments | « chrome/browser/services/gcm/gcm_profile_service.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/pref_names.h" 12 #include "chrome/common/pref_names.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 "components/gcm_driver/gcm_driver_android.h" 17 #include "components/gcm_driver/gcm_driver_android.h"
18 #else 18 #else
19 #include "base/bind.h" 19 #include "base/bind.h"
20 #if defined(OS_CHROMEOS)
21 #include "chrome/browser/services/gcm/chromeos_gcm_connection_observer.h"
22 #endif
23 #include "base/files/file_path.h" 20 #include "base/files/file_path.h"
24 #include "base/memory/weak_ptr.h" 21 #include "base/memory/weak_ptr.h"
25 #include "chrome/browser/services/gcm/gcm_account_tracker.h" 22 #include "chrome/browser/services/gcm/gcm_account_tracker.h"
26 #include "chrome/browser/services/gcm/gcm_desktop_utils.h" 23 #include "chrome/browser/services/gcm/gcm_desktop_utils.h"
27 #include "chrome/browser/signin/profile_identity_provider.h" 24 #include "chrome/browser/signin/profile_identity_provider.h"
28 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 25 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
29 #include "chrome/browser/signin/signin_manager_factory.h" 26 #include "chrome/browser/signin/signin_manager_factory.h"
30 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" 27 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
31 #include "chrome/common/chrome_constants.h" 28 #include "chrome/common/chrome_constants.h"
32 #include "components/gcm_driver/gcm_client_factory.h" 29 #include "components/gcm_driver/gcm_client_factory.h"
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 : profile_(profile), 156 : profile_(profile),
160 push_messaging_service_(this, profile) { 157 push_messaging_service_(this, profile) {
161 DCHECK(!profile->IsOffTheRecord()); 158 DCHECK(!profile->IsOffTheRecord());
162 159
163 driver_ = CreateGCMDriverDesktop( 160 driver_ = CreateGCMDriverDesktop(
164 gcm_client_factory.Pass(), 161 gcm_client_factory.Pass(),
165 profile_->GetPrefs(), 162 profile_->GetPrefs(),
166 profile_->GetPath().Append(chrome::kGCMStoreDirname), 163 profile_->GetPath().Append(chrome::kGCMStoreDirname),
167 profile_->GetRequestContext()); 164 profile_->GetRequestContext());
168 165
169 #if defined(OS_CHROMEOS)
170 chromeos_connection_observer_.reset(new gcm::ChromeOSGCMConnectionObserver);
171 driver_->AddConnectionObserver(chromeos_connection_observer_.get());
172 #endif
173
174 identity_observer_.reset(new IdentityObserver(profile, driver_.get())); 166 identity_observer_.reset(new IdentityObserver(profile, driver_.get()));
175 } 167 }
176 #endif // defined(OS_ANDROID) 168 #endif // defined(OS_ANDROID)
177 169
178 GCMProfileService::GCMProfileService() 170 GCMProfileService::GCMProfileService()
179 : profile_(NULL), 171 : profile_(NULL),
180 push_messaging_service_(this, NULL) { 172 push_messaging_service_(this, NULL) {
181 } 173 }
182 174
183 GCMProfileService::~GCMProfileService() { 175 GCMProfileService::~GCMProfileService() {
184 } 176 }
185 177
186 void GCMProfileService::Shutdown() { 178 void GCMProfileService::Shutdown() {
187 #if !defined(OS_ANDROID) 179 #if !defined(OS_ANDROID)
188 identity_observer_.reset(); 180 identity_observer_.reset();
189 #endif // !defined(OS_ANDROID) 181 #endif // !defined(OS_ANDROID)
190 if (driver_) { 182 if (driver_) {
191 #if defined(OS_CHROMEOS)
192 driver_->RemoveConnectionObserver(chromeos_connection_observer_.get());
193 chromeos_connection_observer_.reset();
194 #endif
195 driver_->Shutdown(); 183 driver_->Shutdown();
196 driver_.reset(); 184 driver_.reset();
197 } 185 }
198 } 186 }
199 187
200 std::string GCMProfileService::SignedInUserName() const { 188 std::string GCMProfileService::SignedInUserName() const {
201 #if defined(OS_ANDROID) 189 #if defined(OS_ANDROID)
202 return std::string(); 190 return std::string();
203 #else 191 #else
204 return identity_observer_ ? identity_observer_->SignedInUserName() 192 return identity_observer_ ? identity_observer_->SignedInUserName()
205 : std::string(); 193 : std::string();
206 #endif // defined(OS_ANDROID) 194 #endif // defined(OS_ANDROID)
207 } 195 }
208 196
209 void GCMProfileService::SetDriverForTesting(GCMDriver* driver) { 197 void GCMProfileService::SetDriverForTesting(GCMDriver* driver) {
210 driver_.reset(driver); 198 driver_.reset(driver);
211 #if !defined(OS_ANDROID) 199 #if !defined(OS_ANDROID)
212 if (identity_observer_) 200 if (identity_observer_)
213 identity_observer_.reset(new IdentityObserver(profile_, driver)); 201 identity_observer_.reset(new IdentityObserver(profile_, driver));
214 #endif // !defined(OS_ANDROID) 202 #endif // !defined(OS_ANDROID)
215 } 203 }
216 204
217 } // namespace gcm 205 } // namespace gcm
OLDNEW
« no previous file with comments | « chrome/browser/services/gcm/gcm_profile_service.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698