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

Side by Side Diff: extensions/browser/api/sockets_tcp_server/sockets_tcp_server_api.cc

Issue 598173003: Run clang-modernize -use-nullptr over src/extensions/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/browser/api/sockets_tcp_server/sockets_tcp_server_api.h" 5 #include "extensions/browser/api/sockets_tcp_server/sockets_tcp_server_api.h"
6 6
7 #include "content/public/common/socket_permission_request.h" 7 #include "content/public/common/socket_permission_request.h"
8 #include "extensions/browser/api/socket/tcp_socket.h" 8 #include "extensions/browser/api/socket/tcp_socket.h"
9 #include "extensions/browser/api/sockets_tcp_server/tcp_server_socket_event_disp atcher.h" 9 #include "extensions/browser/api/sockets_tcp_server/tcp_server_socket_event_disp atcher.h"
10 #include "extensions/common/api/sockets/sockets_manifest_data.h" 10 #include "extensions/common/api/sockets/sockets_manifest_data.h"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 if (!socket) { 114 if (!socket) {
115 error_ = kSocketNotFoundError; 115 error_ = kSocketNotFoundError;
116 return; 116 return;
117 } 117 }
118 118
119 SetSocketProperties(socket, &params_.get()->properties); 119 SetSocketProperties(socket, &params_.get()->properties);
120 results_ = sockets_tcp_server::Update::Results::Create(); 120 results_ = sockets_tcp_server::Update::Results::Create();
121 } 121 }
122 122
123 SocketsTcpServerSetPausedFunction::SocketsTcpServerSetPausedFunction() 123 SocketsTcpServerSetPausedFunction::SocketsTcpServerSetPausedFunction()
124 : socket_event_dispatcher_(NULL) {} 124 : socket_event_dispatcher_(nullptr) {
125 }
125 126
126 SocketsTcpServerSetPausedFunction::~SocketsTcpServerSetPausedFunction() {} 127 SocketsTcpServerSetPausedFunction::~SocketsTcpServerSetPausedFunction() {}
127 128
128 bool SocketsTcpServerSetPausedFunction::Prepare() { 129 bool SocketsTcpServerSetPausedFunction::Prepare() {
129 params_ = core_api::sockets_tcp_server::SetPaused::Params::Create(*args_); 130 params_ = core_api::sockets_tcp_server::SetPaused::Params::Create(*args_);
130 EXTENSION_FUNCTION_VALIDATE(params_.get()); 131 EXTENSION_FUNCTION_VALIDATE(params_.get());
131 132
132 socket_event_dispatcher_ = 133 socket_event_dispatcher_ =
133 TCPServerSocketEventDispatcher::Get(browser_context()); 134 TCPServerSocketEventDispatcher::Get(browser_context());
134 DCHECK(socket_event_dispatcher_) 135 DCHECK(socket_event_dispatcher_)
135 << "There is no socket event dispatcher. " 136 << "There is no socket event dispatcher. "
136 "If this assertion is failing during a test, then it is likely that " 137 "If this assertion is failing during a test, then it is likely that "
137 "TestExtensionSystem is failing to provide an instance of " 138 "TestExtensionSystem is failing to provide an instance of "
138 "TCPServerSocketEventDispatcher."; 139 "TCPServerSocketEventDispatcher.";
139 return socket_event_dispatcher_ != NULL; 140 return socket_event_dispatcher_ != nullptr;
140 } 141 }
141 142
142 void SocketsTcpServerSetPausedFunction::Work() { 143 void SocketsTcpServerSetPausedFunction::Work() {
143 ResumableTCPServerSocket* socket = GetTcpSocket(params_->socket_id); 144 ResumableTCPServerSocket* socket = GetTcpSocket(params_->socket_id);
144 if (!socket) { 145 if (!socket) {
145 error_ = kSocketNotFoundError; 146 error_ = kSocketNotFoundError;
146 return; 147 return;
147 } 148 }
148 149
149 if (socket->paused() != params_->paused) { 150 if (socket->paused() != params_->paused) {
150 socket->set_paused(params_->paused); 151 socket->set_paused(params_->paused);
151 if (socket->IsConnected() && !params_->paused) { 152 if (socket->IsConnected() && !params_->paused) {
152 socket_event_dispatcher_->OnServerSocketResume(extension_->id(), 153 socket_event_dispatcher_->OnServerSocketResume(extension_->id(),
153 params_->socket_id); 154 params_->socket_id);
154 } 155 }
155 } 156 }
156 157
157 results_ = sockets_tcp_server::SetPaused::Results::Create(); 158 results_ = sockets_tcp_server::SetPaused::Results::Create();
158 } 159 }
159 160
160 SocketsTcpServerListenFunction::SocketsTcpServerListenFunction() 161 SocketsTcpServerListenFunction::SocketsTcpServerListenFunction()
161 : socket_event_dispatcher_(NULL) {} 162 : socket_event_dispatcher_(nullptr) {
163 }
162 164
163 SocketsTcpServerListenFunction::~SocketsTcpServerListenFunction() {} 165 SocketsTcpServerListenFunction::~SocketsTcpServerListenFunction() {}
164 166
165 bool SocketsTcpServerListenFunction::Prepare() { 167 bool SocketsTcpServerListenFunction::Prepare() {
166 params_ = core_api::sockets_tcp_server::Listen::Params::Create(*args_); 168 params_ = core_api::sockets_tcp_server::Listen::Params::Create(*args_);
167 EXTENSION_FUNCTION_VALIDATE(params_.get()); 169 EXTENSION_FUNCTION_VALIDATE(params_.get());
168 170
169 socket_event_dispatcher_ = 171 socket_event_dispatcher_ =
170 TCPServerSocketEventDispatcher::Get(browser_context()); 172 TCPServerSocketEventDispatcher::Get(browser_context());
171 DCHECK(socket_event_dispatcher_) 173 DCHECK(socket_event_dispatcher_)
172 << "There is no socket event dispatcher. " 174 << "There is no socket event dispatcher. "
173 "If this assertion is failing during a test, then it is likely that " 175 "If this assertion is failing during a test, then it is likely that "
174 "TestExtensionSystem is failing to provide an instance of " 176 "TestExtensionSystem is failing to provide an instance of "
175 "TCPServerSocketEventDispatcher."; 177 "TCPServerSocketEventDispatcher.";
176 return socket_event_dispatcher_ != NULL; 178 return socket_event_dispatcher_ != nullptr;
177 } 179 }
178 180
179 void SocketsTcpServerListenFunction::Work() { 181 void SocketsTcpServerListenFunction::Work() {
180 ResumableTCPServerSocket* socket = GetTcpSocket(params_->socket_id); 182 ResumableTCPServerSocket* socket = GetTcpSocket(params_->socket_id);
181 if (!socket) { 183 if (!socket) {
182 error_ = kSocketNotFoundError; 184 error_ = kSocketNotFoundError;
183 return; 185 return;
184 } 186 }
185 187
186 SocketPermissionRequest param( 188 SocketPermissionRequest param(
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 275
274 SocketsTcpServerGetSocketsFunction::SocketsTcpServerGetSocketsFunction() {} 276 SocketsTcpServerGetSocketsFunction::SocketsTcpServerGetSocketsFunction() {}
275 277
276 SocketsTcpServerGetSocketsFunction::~SocketsTcpServerGetSocketsFunction() {} 278 SocketsTcpServerGetSocketsFunction::~SocketsTcpServerGetSocketsFunction() {}
277 279
278 bool SocketsTcpServerGetSocketsFunction::Prepare() { return true; } 280 bool SocketsTcpServerGetSocketsFunction::Prepare() { return true; }
279 281
280 void SocketsTcpServerGetSocketsFunction::Work() { 282 void SocketsTcpServerGetSocketsFunction::Work() {
281 std::vector<linked_ptr<sockets_tcp_server::SocketInfo> > socket_infos; 283 std::vector<linked_ptr<sockets_tcp_server::SocketInfo> > socket_infos;
282 base::hash_set<int>* resource_ids = GetSocketIds(); 284 base::hash_set<int>* resource_ids = GetSocketIds();
283 if (resource_ids != NULL) { 285 if (resource_ids != nullptr) {
284 for (base::hash_set<int>::iterator it = resource_ids->begin(); 286 for (base::hash_set<int>::iterator it = resource_ids->begin();
285 it != resource_ids->end(); 287 it != resource_ids->end();
286 ++it) { 288 ++it) {
287 int socket_id = *it; 289 int socket_id = *it;
288 ResumableTCPServerSocket* socket = GetTcpSocket(socket_id); 290 ResumableTCPServerSocket* socket = GetTcpSocket(socket_id);
289 if (socket) { 291 if (socket) {
290 socket_infos.push_back(CreateSocketInfo(socket_id, socket)); 292 socket_infos.push_back(CreateSocketInfo(socket_id, socket));
291 } 293 }
292 } 294 }
293 } 295 }
294 results_ = sockets_tcp_server::GetSockets::Results::Create(socket_infos); 296 results_ = sockets_tcp_server::GetSockets::Results::Create(socket_infos);
295 } 297 }
296 298
297 } // namespace core_api 299 } // namespace core_api
298 } // namespace extensions 300 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698