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

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

Issue 177003015: Pull AsyncApiFunction out of src/chrome (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
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/sockets_tcp_server/sockets_tcp_server_ap i.h" 5 #include "chrome/browser/extensions/api/sockets_tcp_server/sockets_tcp_server_ap i.h"
6 6
7 #include "chrome/browser/extensions/api/socket/tcp_socket.h" 7 #include "chrome/browser/extensions/api/socket/tcp_socket.h"
8 #include "chrome/browser/extensions/api/sockets_tcp_server/tcp_server_socket_eve nt_dispatcher.h" 8 #include "chrome/browser/extensions/api/sockets_tcp_server/tcp_server_socket_eve nt_dispatcher.h"
9 #include "chrome/common/extensions/api/sockets/sockets_manifest_data.h" 9 #include "chrome/common/extensions/api/sockets/sockets_manifest_data.h"
10 #include "chrome/common/extensions/permissions/socket_permission.h" 10 #include "chrome/common/extensions/permissions/socket_permission.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 122
123 SocketsTcpServerSetPausedFunction::SocketsTcpServerSetPausedFunction() 123 SocketsTcpServerSetPausedFunction::SocketsTcpServerSetPausedFunction()
124 : socket_event_dispatcher_(NULL) {} 124 : socket_event_dispatcher_(NULL) {}
125 125
126 SocketsTcpServerSetPausedFunction::~SocketsTcpServerSetPausedFunction() {} 126 SocketsTcpServerSetPausedFunction::~SocketsTcpServerSetPausedFunction() {}
127 127
128 bool SocketsTcpServerSetPausedFunction::Prepare() { 128 bool SocketsTcpServerSetPausedFunction::Prepare() {
129 params_ = api::sockets_tcp_server::SetPaused::Params::Create(*args_); 129 params_ = api::sockets_tcp_server::SetPaused::Params::Create(*args_);
130 EXTENSION_FUNCTION_VALIDATE(params_.get()); 130 EXTENSION_FUNCTION_VALIDATE(params_.get());
131 131
132 socket_event_dispatcher_ = TCPServerSocketEventDispatcher::Get(GetProfile()); 132 socket_event_dispatcher_ = TCPServerSocketEventDispatcher::Get(context());
133 DCHECK(socket_event_dispatcher_) << "There is no socket event dispatcher. " 133 DCHECK(socket_event_dispatcher_) << "There is no socket event dispatcher. "
134 "If this assertion is failing during a test, then it is likely that " 134 "If this assertion is failing during a test, then it is likely that "
135 "TestExtensionSystem is failing to provide an instance of " 135 "TestExtensionSystem is failing to provide an instance of "
136 "TCPServerSocketEventDispatcher."; 136 "TCPServerSocketEventDispatcher.";
137 return socket_event_dispatcher_ != NULL; 137 return socket_event_dispatcher_ != NULL;
138 } 138 }
139 139
140 void SocketsTcpServerSetPausedFunction::Work() { 140 void SocketsTcpServerSetPausedFunction::Work() {
141 ResumableTCPServerSocket* socket = GetTcpSocket(params_->socket_id); 141 ResumableTCPServerSocket* socket = GetTcpSocket(params_->socket_id);
142 if (!socket) { 142 if (!socket) {
(...skipping 14 matching lines...) Expand all
157 157
158 SocketsTcpServerListenFunction::SocketsTcpServerListenFunction() 158 SocketsTcpServerListenFunction::SocketsTcpServerListenFunction()
159 : socket_event_dispatcher_(NULL) {} 159 : socket_event_dispatcher_(NULL) {}
160 160
161 SocketsTcpServerListenFunction::~SocketsTcpServerListenFunction() {} 161 SocketsTcpServerListenFunction::~SocketsTcpServerListenFunction() {}
162 162
163 bool SocketsTcpServerListenFunction::Prepare() { 163 bool SocketsTcpServerListenFunction::Prepare() {
164 params_ = api::sockets_tcp_server::Listen::Params::Create(*args_); 164 params_ = api::sockets_tcp_server::Listen::Params::Create(*args_);
165 EXTENSION_FUNCTION_VALIDATE(params_.get()); 165 EXTENSION_FUNCTION_VALIDATE(params_.get());
166 166
167 socket_event_dispatcher_ = TCPServerSocketEventDispatcher::Get(GetProfile()); 167 socket_event_dispatcher_ = TCPServerSocketEventDispatcher::Get(context());
168 DCHECK(socket_event_dispatcher_) << "There is no socket event dispatcher. " 168 DCHECK(socket_event_dispatcher_) << "There is no socket event dispatcher. "
169 "If this assertion is failing during a test, then it is likely that " 169 "If this assertion is failing during a test, then it is likely that "
170 "TestExtensionSystem is failing to provide an instance of " 170 "TestExtensionSystem is failing to provide an instance of "
171 "TCPServerSocketEventDispatcher."; 171 "TCPServerSocketEventDispatcher.";
172 return socket_event_dispatcher_ != NULL; 172 return socket_event_dispatcher_ != NULL;
173 } 173 }
174 174
175 void SocketsTcpServerListenFunction::Work() { 175 void SocketsTcpServerListenFunction::Work() {
176 ResumableTCPServerSocket* socket = GetTcpSocket(params_->socket_id); 176 ResumableTCPServerSocket* socket = GetTcpSocket(params_->socket_id);
177 if (!socket) { 177 if (!socket) {
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 if (socket) { 289 if (socket) {
290 socket_infos.push_back(CreateSocketInfo(socket_id, socket)); 290 socket_infos.push_back(CreateSocketInfo(socket_id, socket));
291 } 291 }
292 } 292 }
293 } 293 }
294 results_ = sockets_tcp_server::GetSockets::Results::Create(socket_infos); 294 results_ = sockets_tcp_server::GetSockets::Results::Create(socket_infos);
295 } 295 }
296 296
297 } // namespace api 297 } // namespace api
298 } // namespace extensions 298 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698