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

Side by Side Diff: chrome/browser/extensions/api/gcm/gcm_api.cc

Issue 1871713002: Convert //chrome/browser/extensions from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and fix header Created 4 years, 8 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
OLDNEW
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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 gcm::GCMDriver* GcmApiFunction::GetGCMDriver() const { 105 gcm::GCMDriver* GcmApiFunction::GetGCMDriver() const {
106 return gcm::GCMProfileServiceFactory::GetForProfile( 106 return gcm::GCMProfileServiceFactory::GetForProfile(
107 Profile::FromBrowserContext(browser_context()))->driver(); 107 Profile::FromBrowserContext(browser_context()))->driver();
108 } 108 }
109 109
110 GcmRegisterFunction::GcmRegisterFunction() {} 110 GcmRegisterFunction::GcmRegisterFunction() {}
111 111
112 GcmRegisterFunction::~GcmRegisterFunction() {} 112 GcmRegisterFunction::~GcmRegisterFunction() {}
113 113
114 bool GcmRegisterFunction::DoWork() { 114 bool GcmRegisterFunction::DoWork() {
115 scoped_ptr<api::gcm::Register::Params> params( 115 std::unique_ptr<api::gcm::Register::Params> params(
116 api::gcm::Register::Params::Create(*args_)); 116 api::gcm::Register::Params::Create(*args_));
117 EXTENSION_FUNCTION_VALIDATE(params.get()); 117 EXTENSION_FUNCTION_VALIDATE(params.get());
118 118
119 GetGCMDriver()->Register( 119 GetGCMDriver()->Register(
120 extension()->id(), 120 extension()->id(),
121 params->sender_ids, 121 params->sender_ids,
122 base::Bind(&GcmRegisterFunction::CompleteFunctionWithResult, this)); 122 base::Bind(&GcmRegisterFunction::CompleteFunctionWithResult, this));
123 123
124 return true; 124 return true;
125 } 125 }
(...skipping 24 matching lines...) Expand all
150 gcm::GCMClient::Result result) { 150 gcm::GCMClient::Result result) {
151 SetError(GcmResultToError(result)); 151 SetError(GcmResultToError(result));
152 SendResponse(gcm::GCMClient::SUCCESS == result); 152 SendResponse(gcm::GCMClient::SUCCESS == result);
153 } 153 }
154 154
155 GcmSendFunction::GcmSendFunction() {} 155 GcmSendFunction::GcmSendFunction() {}
156 156
157 GcmSendFunction::~GcmSendFunction() {} 157 GcmSendFunction::~GcmSendFunction() {}
158 158
159 bool GcmSendFunction::DoWork() { 159 bool GcmSendFunction::DoWork() {
160 scoped_ptr<api::gcm::Send::Params> params( 160 std::unique_ptr<api::gcm::Send::Params> params(
161 api::gcm::Send::Params::Create(*args_)); 161 api::gcm::Send::Params::Create(*args_));
162 EXTENSION_FUNCTION_VALIDATE(params.get()); 162 EXTENSION_FUNCTION_VALIDATE(params.get());
163 EXTENSION_FUNCTION_VALIDATE( 163 EXTENSION_FUNCTION_VALIDATE(
164 ValidateMessageData(params->message.data.additional_properties)); 164 ValidateMessageData(params->message.data.additional_properties));
165 165
166 gcm::OutgoingMessage outgoing_message; 166 gcm::OutgoingMessage outgoing_message;
167 outgoing_message.id = params->message.message_id; 167 outgoing_message.id = params->message.message_id;
168 outgoing_message.data = params->message.data.additional_properties; 168 outgoing_message.data = params->message.data.additional_properties;
169 if (params->message.time_to_live.get()) 169 if (params->message.time_to_live.get())
170 outgoing_message.time_to_live = *params->message.time_to_live; 170 outgoing_message.time_to_live = *params->message.time_to_live;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 210
211 void GcmJsEventRouter::OnMessage(const std::string& app_id, 211 void GcmJsEventRouter::OnMessage(const std::string& app_id,
212 const gcm::IncomingMessage& message) { 212 const gcm::IncomingMessage& message) {
213 api::gcm::OnMessage::Message message_arg; 213 api::gcm::OnMessage::Message message_arg;
214 message_arg.data.additional_properties = message.data; 214 message_arg.data.additional_properties = message.data;
215 if (!message.sender_id.empty()) 215 if (!message.sender_id.empty())
216 message_arg.from.reset(new std::string(message.sender_id)); 216 message_arg.from.reset(new std::string(message.sender_id));
217 if (!message.collapse_key.empty()) 217 if (!message.collapse_key.empty())
218 message_arg.collapse_key.reset(new std::string(message.collapse_key)); 218 message_arg.collapse_key.reset(new std::string(message.collapse_key));
219 219
220 scoped_ptr<Event> event( 220 std::unique_ptr<Event> event(
221 new Event(events::GCM_ON_MESSAGE, api::gcm::OnMessage::kEventName, 221 new Event(events::GCM_ON_MESSAGE, api::gcm::OnMessage::kEventName,
222 api::gcm::OnMessage::Create(message_arg), profile_)); 222 api::gcm::OnMessage::Create(message_arg), profile_));
223 EventRouter::Get(profile_) 223 EventRouter::Get(profile_)
224 ->DispatchEventToExtension(app_id, std::move(event)); 224 ->DispatchEventToExtension(app_id, std::move(event));
225 } 225 }
226 226
227 void GcmJsEventRouter::OnMessagesDeleted(const std::string& app_id) { 227 void GcmJsEventRouter::OnMessagesDeleted(const std::string& app_id) {
228 scoped_ptr<Event> event(new Event( 228 std::unique_ptr<Event> event(new Event(
229 events::GCM_ON_MESSAGES_DELETED, api::gcm::OnMessagesDeleted::kEventName, 229 events::GCM_ON_MESSAGES_DELETED, api::gcm::OnMessagesDeleted::kEventName,
230 api::gcm::OnMessagesDeleted::Create(), profile_)); 230 api::gcm::OnMessagesDeleted::Create(), profile_));
231 EventRouter::Get(profile_) 231 EventRouter::Get(profile_)
232 ->DispatchEventToExtension(app_id, std::move(event)); 232 ->DispatchEventToExtension(app_id, std::move(event));
233 } 233 }
234 234
235 void GcmJsEventRouter::OnSendError( 235 void GcmJsEventRouter::OnSendError(
236 const std::string& app_id, 236 const std::string& app_id,
237 const gcm::GCMClient::SendErrorDetails& send_error_details) { 237 const gcm::GCMClient::SendErrorDetails& send_error_details) {
238 api::gcm::OnSendError::Error error; 238 api::gcm::OnSendError::Error error;
239 error.message_id.reset(new std::string(send_error_details.message_id)); 239 error.message_id.reset(new std::string(send_error_details.message_id));
240 error.error_message = GcmResultToError(send_error_details.result); 240 error.error_message = GcmResultToError(send_error_details.result);
241 error.details.additional_properties = send_error_details.additional_data; 241 error.details.additional_properties = send_error_details.additional_data;
242 242
243 scoped_ptr<Event> event( 243 std::unique_ptr<Event> event(
244 new Event(events::GCM_ON_SEND_ERROR, api::gcm::OnSendError::kEventName, 244 new Event(events::GCM_ON_SEND_ERROR, api::gcm::OnSendError::kEventName,
245 api::gcm::OnSendError::Create(error), profile_)); 245 api::gcm::OnSendError::Create(error), profile_));
246 EventRouter::Get(profile_) 246 EventRouter::Get(profile_)
247 ->DispatchEventToExtension(app_id, std::move(event)); 247 ->DispatchEventToExtension(app_id, std::move(event));
248 } 248 }
249 249
250 } // namespace extensions 250 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698