| 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/sockets_tcp/sockets_tcp_api.h" | 5 #include "chrome/browser/extensions/api/sockets_tcp/sockets_tcp_api.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/tcp_socket_event_dispatcher.
h" | 8 #include "chrome/browser/extensions/api/sockets_tcp/tcp_socket_event_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 "content/public/common/socket_permission_request.h" | 10 #include "content/public/common/socket_permission_request.h" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 | 151 |
| 152 SocketsTcpSetPausedFunction::SocketsTcpSetPausedFunction() | 152 SocketsTcpSetPausedFunction::SocketsTcpSetPausedFunction() |
| 153 : socket_event_dispatcher_(NULL) {} | 153 : socket_event_dispatcher_(NULL) {} |
| 154 | 154 |
| 155 SocketsTcpSetPausedFunction::~SocketsTcpSetPausedFunction() {} | 155 SocketsTcpSetPausedFunction::~SocketsTcpSetPausedFunction() {} |
| 156 | 156 |
| 157 bool SocketsTcpSetPausedFunction::Prepare() { | 157 bool SocketsTcpSetPausedFunction::Prepare() { |
| 158 params_ = api::sockets_tcp::SetPaused::Params::Create(*args_); | 158 params_ = api::sockets_tcp::SetPaused::Params::Create(*args_); |
| 159 EXTENSION_FUNCTION_VALIDATE(params_.get()); | 159 EXTENSION_FUNCTION_VALIDATE(params_.get()); |
| 160 | 160 |
| 161 socket_event_dispatcher_ = TCPSocketEventDispatcher::Get(GetProfile()); | 161 socket_event_dispatcher_ = TCPSocketEventDispatcher::Get(context()); |
| 162 DCHECK(socket_event_dispatcher_) << "There is no socket event dispatcher. " | 162 DCHECK(socket_event_dispatcher_) << "There is no socket event dispatcher. " |
| 163 "If this assertion is failing during a test, then it is likely that " | 163 "If this assertion is failing during a test, then it is likely that " |
| 164 "TestExtensionSystem is failing to provide an instance of " | 164 "TestExtensionSystem is failing to provide an instance of " |
| 165 "TCPSocketEventDispatcher."; | 165 "TCPSocketEventDispatcher."; |
| 166 return socket_event_dispatcher_ != NULL; | 166 return socket_event_dispatcher_ != NULL; |
| 167 } | 167 } |
| 168 | 168 |
| 169 void SocketsTcpSetPausedFunction::Work() { | 169 void SocketsTcpSetPausedFunction::Work() { |
| 170 ResumableTCPSocket* socket = GetTcpSocket(params_->socket_id); | 170 ResumableTCPSocket* socket = GetTcpSocket(params_->socket_id); |
| 171 if (!socket) { | 171 if (!socket) { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 | 236 |
| 237 SocketsTcpConnectFunction::SocketsTcpConnectFunction() | 237 SocketsTcpConnectFunction::SocketsTcpConnectFunction() |
| 238 : socket_event_dispatcher_(NULL) {} | 238 : socket_event_dispatcher_(NULL) {} |
| 239 | 239 |
| 240 SocketsTcpConnectFunction::~SocketsTcpConnectFunction() {} | 240 SocketsTcpConnectFunction::~SocketsTcpConnectFunction() {} |
| 241 | 241 |
| 242 bool SocketsTcpConnectFunction::Prepare() { | 242 bool SocketsTcpConnectFunction::Prepare() { |
| 243 params_ = sockets_tcp::Connect::Params::Create(*args_); | 243 params_ = sockets_tcp::Connect::Params::Create(*args_); |
| 244 EXTENSION_FUNCTION_VALIDATE(params_.get()); | 244 EXTENSION_FUNCTION_VALIDATE(params_.get()); |
| 245 | 245 |
| 246 socket_event_dispatcher_ = TCPSocketEventDispatcher::Get(GetProfile()); | 246 socket_event_dispatcher_ = TCPSocketEventDispatcher::Get(context()); |
| 247 DCHECK(socket_event_dispatcher_) << "There is no socket event dispatcher. " | 247 DCHECK(socket_event_dispatcher_) << "There is no socket event dispatcher. " |
| 248 "If this assertion is failing during a test, then it is likely that " | 248 "If this assertion is failing during a test, then it is likely that " |
| 249 "TestExtensionSystem is failing to provide an instance of " | 249 "TestExtensionSystem is failing to provide an instance of " |
| 250 "TCPSocketEventDispatcher."; | 250 "TCPSocketEventDispatcher."; |
| 251 return socket_event_dispatcher_ != NULL; | 251 return socket_event_dispatcher_ != NULL; |
| 252 } | 252 } |
| 253 | 253 |
| 254 void SocketsTcpConnectFunction::AsyncWorkStart() { | 254 void SocketsTcpConnectFunction::AsyncWorkStart() { |
| 255 ResumableTCPSocket* socket = GetTcpSocket(params_->socket_id); | 255 ResumableTCPSocket* socket = GetTcpSocket(params_->socket_id); |
| 256 if (!socket) { | 256 if (!socket) { |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 if (socket) { | 435 if (socket) { |
| 436 socket_infos.push_back(CreateSocketInfo(socket_id, socket)); | 436 socket_infos.push_back(CreateSocketInfo(socket_id, socket)); |
| 437 } | 437 } |
| 438 } | 438 } |
| 439 } | 439 } |
| 440 results_ = sockets_tcp::GetSockets::Results::Create(socket_infos); | 440 results_ = sockets_tcp::GetSockets::Results::Create(socket_infos); |
| 441 } | 441 } |
| 442 | 442 |
| 443 } // namespace api | 443 } // namespace api |
| 444 } // namespace extensions | 444 } // namespace extensions |
| OLD | NEW |