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 "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" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 void GCMProfileService::RegisterProfilePrefs( | 135 void GCMProfileService::RegisterProfilePrefs( |
136 user_prefs::PrefRegistrySyncable* registry) { | 136 user_prefs::PrefRegistrySyncable* registry) { |
137 registry->RegisterBooleanPref( | 137 registry->RegisterBooleanPref( |
138 prefs::kGCMChannelEnabled, | 138 prefs::kGCMChannelEnabled, |
139 true, | 139 true, |
140 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 140 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
141 PushMessagingServiceImpl::RegisterProfilePrefs(registry); | 141 PushMessagingServiceImpl::RegisterProfilePrefs(registry); |
142 } | 142 } |
143 | 143 |
144 #if defined(OS_ANDROID) | 144 #if defined(OS_ANDROID) |
145 static GCMProfileService* debug_instance = nullptr; // TODO(johnme): Remove. | |
146 | |
147 GCMProfileService::GCMProfileService(Profile* profile) | 145 GCMProfileService::GCMProfileService(Profile* profile) |
148 : profile_(profile), | 146 : profile_(profile), |
149 push_messaging_service_(this, profile) { | 147 push_messaging_service_(this, profile) { |
150 CHECK(!profile->IsOffTheRecord()); | 148 DCHECK(!profile->IsOffTheRecord()); |
151 | |
152 // TODO(johnme): Remove this debug code once crbug.com/437827 is fixed. | |
153 if (debug_instance != nullptr) { | |
154 LOG(FATAL) << "An instance of GCMProfileService already exists!" | |
155 << " Old profile: " << debug_instance->profile_ << " " | |
156 << debug_instance->profile_->GetDebugName() << " " | |
157 << debug_instance->profile_->GetProfileType() << " " | |
158 << debug_instance->profile_->IsSupervised() << " " | |
159 << debug_instance->profile_->IsNewProfile() << " " | |
160 << debug_instance->profile_->GetStartTime().ToInternalValue() | |
161 << ", new profile: " << profile << " " | |
162 << profile_->GetDebugName() << " " | |
163 << profile_->GetProfileType() << " " | |
164 << profile_->IsSupervised() << " " | |
165 << profile_->IsNewProfile() << " " | |
166 << profile_->GetStartTime().ToInternalValue(); | |
167 } | |
168 debug_instance = this; | |
169 | 149 |
170 driver_.reset(new GCMDriverAndroid); | 150 driver_.reset(new GCMDriverAndroid); |
171 } | 151 } |
172 #else | 152 #else |
173 GCMProfileService::GCMProfileService( | 153 GCMProfileService::GCMProfileService( |
174 Profile* profile, | 154 Profile* profile, |
175 scoped_ptr<GCMClientFactory> gcm_client_factory) | 155 scoped_ptr<GCMClientFactory> gcm_client_factory) |
176 : profile_(profile), | 156 : profile_(profile), |
177 push_messaging_service_(this, profile) { | 157 push_messaging_service_(this, profile) { |
178 DCHECK(!profile->IsOffTheRecord()); | 158 DCHECK(!profile->IsOffTheRecord()); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 | 196 |
217 void GCMProfileService::SetDriverForTesting(GCMDriver* driver) { | 197 void GCMProfileService::SetDriverForTesting(GCMDriver* driver) { |
218 driver_.reset(driver); | 198 driver_.reset(driver); |
219 #if !defined(OS_ANDROID) | 199 #if !defined(OS_ANDROID) |
220 if (identity_observer_) | 200 if (identity_observer_) |
221 identity_observer_.reset(new IdentityObserver(profile_, driver)); | 201 identity_observer_.reset(new IdentityObserver(profile_, driver)); |
222 #endif // !defined(OS_ANDROID) | 202 #endif // !defined(OS_ANDROID) |
223 } | 203 } |
224 | 204 |
225 } // namespace gcm | 205 } // namespace gcm |
OLD | NEW |