| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 extension()->id(), | 121 extension()->id(), |
| 122 params->sender_ids, | 122 params->sender_ids, |
| 123 base::Bind(&GcmRegisterFunction::CompleteFunctionWithResult, this)); | 123 base::Bind(&GcmRegisterFunction::CompleteFunctionWithResult, this)); |
| 124 | 124 |
| 125 return true; | 125 return true; |
| 126 } | 126 } |
| 127 | 127 |
| 128 void GcmRegisterFunction::CompleteFunctionWithResult( | 128 void GcmRegisterFunction::CompleteFunctionWithResult( |
| 129 const std::string& registration_id, | 129 const std::string& registration_id, |
| 130 gcm::GCMClient::Result result) { | 130 gcm::GCMClient::Result result) { |
| 131 SetResult(base::MakeUnique<base::StringValue>(registration_id)); | 131 SetResult(base::MakeUnique<base::Value>(registration_id)); |
| 132 SetError(GcmResultToError(result)); | 132 SetError(GcmResultToError(result)); |
| 133 SendResponse(gcm::GCMClient::SUCCESS == result); | 133 SendResponse(gcm::GCMClient::SUCCESS == result); |
| 134 } | 134 } |
| 135 | 135 |
| 136 GcmUnregisterFunction::GcmUnregisterFunction() {} | 136 GcmUnregisterFunction::GcmUnregisterFunction() {} |
| 137 | 137 |
| 138 GcmUnregisterFunction::~GcmUnregisterFunction() {} | 138 GcmUnregisterFunction::~GcmUnregisterFunction() {} |
| 139 | 139 |
| 140 bool GcmUnregisterFunction::DoWork() { | 140 bool GcmUnregisterFunction::DoWork() { |
| 141 UMA_HISTOGRAM_BOOLEAN("GCM.APICallUnregister", true); | 141 UMA_HISTOGRAM_BOOLEAN("GCM.APICallUnregister", true); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 params->message.destination_id, | 175 params->message.destination_id, |
| 176 outgoing_message, | 176 outgoing_message, |
| 177 base::Bind(&GcmSendFunction::CompleteFunctionWithResult, this)); | 177 base::Bind(&GcmSendFunction::CompleteFunctionWithResult, this)); |
| 178 | 178 |
| 179 return true; | 179 return true; |
| 180 } | 180 } |
| 181 | 181 |
| 182 void GcmSendFunction::CompleteFunctionWithResult( | 182 void GcmSendFunction::CompleteFunctionWithResult( |
| 183 const std::string& message_id, | 183 const std::string& message_id, |
| 184 gcm::GCMClient::Result result) { | 184 gcm::GCMClient::Result result) { |
| 185 SetResult(base::MakeUnique<base::StringValue>(message_id)); | 185 SetResult(base::MakeUnique<base::Value>(message_id)); |
| 186 SetError(GcmResultToError(result)); | 186 SetError(GcmResultToError(result)); |
| 187 SendResponse(gcm::GCMClient::SUCCESS == result); | 187 SendResponse(gcm::GCMClient::SUCCESS == result); |
| 188 } | 188 } |
| 189 | 189 |
| 190 bool GcmSendFunction::ValidateMessageData(const gcm::MessageData& data) const { | 190 bool GcmSendFunction::ValidateMessageData(const gcm::MessageData& data) const { |
| 191 size_t total_size = 0u; | 191 size_t total_size = 0u; |
| 192 for (std::map<std::string, std::string>::const_iterator iter = data.begin(); | 192 for (std::map<std::string, std::string>::const_iterator iter = data.begin(); |
| 193 iter != data.end(); ++iter) { | 193 iter != data.end(); ++iter) { |
| 194 total_size += iter->first.size() + iter->second.size(); | 194 total_size += iter->first.size() + iter->second.size(); |
| 195 | 195 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 error.details.additional_properties = send_error_details.additional_data; | 242 error.details.additional_properties = send_error_details.additional_data; |
| 243 | 243 |
| 244 std::unique_ptr<Event> event( | 244 std::unique_ptr<Event> event( |
| 245 new Event(events::GCM_ON_SEND_ERROR, api::gcm::OnSendError::kEventName, | 245 new Event(events::GCM_ON_SEND_ERROR, api::gcm::OnSendError::kEventName, |
| 246 api::gcm::OnSendError::Create(error), profile_)); | 246 api::gcm::OnSendError::Create(error), profile_)); |
| 247 EventRouter::Get(profile_) | 247 EventRouter::Get(profile_) |
| 248 ->DispatchEventToExtension(app_id, std::move(event)); | 248 ->DispatchEventToExtension(app_id, std::move(event)); |
| 249 } | 249 } |
| 250 | 250 |
| 251 } // namespace extensions | 251 } // namespace extensions |
| OLD | NEW |