Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/extensions/api/gcm/gcm_api.h" | 5 #include "chrome/browser/extensions/api/gcm/gcm_api.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/metrics/histogram.h" | |
| 11 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/services/gcm/gcm_profile_service.h" | 16 #include "chrome/browser/services/gcm/gcm_profile_service.h" |
| 16 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" | 17 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" |
| 17 #include "chrome/common/extensions/api/gcm.h" | 18 #include "chrome/common/extensions/api/gcm.h" |
| 18 #include "extensions/common/extension.h" | 19 #include "extensions/common/extension.h" |
| 19 | 20 |
| 20 namespace { | 21 namespace { |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 124 SetResult(new base::StringValue(registration_id)); | 125 SetResult(new base::StringValue(registration_id)); |
| 125 SetError(GcmResultToError(result)); | 126 SetError(GcmResultToError(result)); |
| 126 SendResponse(gcm::GCMClient::SUCCESS == result); | 127 SendResponse(gcm::GCMClient::SUCCESS == result); |
| 127 } | 128 } |
| 128 | 129 |
| 129 GcmUnregisterFunction::GcmUnregisterFunction() {} | 130 GcmUnregisterFunction::GcmUnregisterFunction() {} |
| 130 | 131 |
| 131 GcmUnregisterFunction::~GcmUnregisterFunction() {} | 132 GcmUnregisterFunction::~GcmUnregisterFunction() {} |
| 132 | 133 |
| 133 bool GcmUnregisterFunction::DoWork() { | 134 bool GcmUnregisterFunction::DoWork() { |
| 135 UMA_HISTOGRAM_COUNTS("GCM.APICallUnregister", 1); | |
|
Alexei Svitkine (slow)
2014/05/08 21:21:57
Use an UMA_HISTOGRAM_BOOLEAN() instead. The result
jianli
2014/05/08 21:26:07
Done.
| |
| 136 | |
| 134 GCMProfileService()->Unregister( | 137 GCMProfileService()->Unregister( |
| 135 GetExtension()->id(), | 138 GetExtension()->id(), |
| 136 base::Bind(&GcmUnregisterFunction::CompleteFunctionWithResult, this)); | 139 base::Bind(&GcmUnregisterFunction::CompleteFunctionWithResult, this)); |
| 137 | 140 |
| 138 return true; | 141 return true; |
| 139 } | 142 } |
| 140 | 143 |
| 141 void GcmUnregisterFunction::CompleteFunctionWithResult( | 144 void GcmUnregisterFunction::CompleteFunctionWithResult( |
| 142 gcm::GCMClient::Result result) { | 145 gcm::GCMClient::Result result) { |
| 143 SetError(GcmResultToError(result)); | 146 SetError(GcmResultToError(result)); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 251 | 254 |
| 252 void GcmJsEventRouter::OnListenerAdded(const EventListenerInfo& details) { | 255 void GcmJsEventRouter::OnListenerAdded(const EventListenerInfo& details) { |
| 253 if (gcm::GCMProfileService::GetGCMEnabledState(profile_) == | 256 if (gcm::GCMProfileService::GetGCMEnabledState(profile_) == |
| 254 gcm::GCMProfileService::ALWAYS_DISABLED) { | 257 gcm::GCMProfileService::ALWAYS_DISABLED) { |
| 255 return; | 258 return; |
| 256 } | 259 } |
| 257 gcm::GCMProfileServiceFactory::GetForProfile(profile_)->Start(); | 260 gcm::GCMProfileServiceFactory::GetForProfile(profile_)->Start(); |
| 258 } | 261 } |
| 259 | 262 |
| 260 } // namespace extensions | 263 } // namespace extensions |
| OLD | NEW |