| 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_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/browser/profiles/profile.h" | |
| 10 #include "chrome/common/extensions/api/sockets/sockets_manifest_data.h" | 9 #include "chrome/common/extensions/api/sockets/sockets_manifest_data.h" |
| 11 #include "chrome/common/extensions/permissions/socket_permission.h" | 10 #include "chrome/common/extensions/permissions/socket_permission.h" |
| 12 #include "content/public/common/socket_permission_request.h" | 11 #include "content/public/common/socket_permission_request.h" |
| 13 #include "extensions/common/permissions/permissions_data.h" | 12 #include "extensions/common/permissions/permissions_data.h" |
| 14 #include "net/base/net_errors.h" | 13 #include "net/base/net_errors.h" |
| 15 | 14 |
| 16 using content::SocketPermissionRequest; | 15 using content::SocketPermissionRequest; |
| 17 using extensions::ResumableTCPServerSocket; | 16 using extensions::ResumableTCPServerSocket; |
| 18 using extensions::api::sockets_tcp_server::SocketInfo; | 17 using extensions::api::sockets_tcp_server::SocketInfo; |
| 19 using extensions::api::sockets_tcp_server::SocketProperties; | 18 using extensions::api::sockets_tcp_server::SocketProperties; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 | 122 |
| 124 SocketsTcpServerSetPausedFunction::SocketsTcpServerSetPausedFunction() | 123 SocketsTcpServerSetPausedFunction::SocketsTcpServerSetPausedFunction() |
| 125 : socket_event_dispatcher_(NULL) {} | 124 : socket_event_dispatcher_(NULL) {} |
| 126 | 125 |
| 127 SocketsTcpServerSetPausedFunction::~SocketsTcpServerSetPausedFunction() {} | 126 SocketsTcpServerSetPausedFunction::~SocketsTcpServerSetPausedFunction() {} |
| 128 | 127 |
| 129 bool SocketsTcpServerSetPausedFunction::Prepare() { | 128 bool SocketsTcpServerSetPausedFunction::Prepare() { |
| 130 params_ = api::sockets_tcp_server::SetPaused::Params::Create(*args_); | 129 params_ = api::sockets_tcp_server::SetPaused::Params::Create(*args_); |
| 131 EXTENSION_FUNCTION_VALIDATE(params_.get()); | 130 EXTENSION_FUNCTION_VALIDATE(params_.get()); |
| 132 | 131 |
| 133 socket_event_dispatcher_ = TCPServerSocketEventDispatcher::Get(GetProfile()); | 132 socket_event_dispatcher_ = |
| 133 TCPServerSocketEventDispatcher::Get(browser_context()); |
| 134 DCHECK(socket_event_dispatcher_) << "There is no socket event dispatcher. " | 134 DCHECK(socket_event_dispatcher_) << "There is no socket event dispatcher. " |
| 135 "If this assertion is failing during a test, then it is likely that " | 135 "If this assertion is failing during a test, then it is likely that " |
| 136 "TestExtensionSystem is failing to provide an instance of " | 136 "TestExtensionSystem is failing to provide an instance of " |
| 137 "TCPServerSocketEventDispatcher."; | 137 "TCPServerSocketEventDispatcher."; |
| 138 return socket_event_dispatcher_ != NULL; | 138 return socket_event_dispatcher_ != NULL; |
| 139 } | 139 } |
| 140 | 140 |
| 141 void SocketsTcpServerSetPausedFunction::Work() { | 141 void SocketsTcpServerSetPausedFunction::Work() { |
| 142 ResumableTCPServerSocket* socket = GetTcpSocket(params_->socket_id); | 142 ResumableTCPServerSocket* socket = GetTcpSocket(params_->socket_id); |
| 143 if (!socket) { | 143 if (!socket) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 158 | 158 |
| 159 SocketsTcpServerListenFunction::SocketsTcpServerListenFunction() | 159 SocketsTcpServerListenFunction::SocketsTcpServerListenFunction() |
| 160 : socket_event_dispatcher_(NULL) {} | 160 : socket_event_dispatcher_(NULL) {} |
| 161 | 161 |
| 162 SocketsTcpServerListenFunction::~SocketsTcpServerListenFunction() {} | 162 SocketsTcpServerListenFunction::~SocketsTcpServerListenFunction() {} |
| 163 | 163 |
| 164 bool SocketsTcpServerListenFunction::Prepare() { | 164 bool SocketsTcpServerListenFunction::Prepare() { |
| 165 params_ = api::sockets_tcp_server::Listen::Params::Create(*args_); | 165 params_ = api::sockets_tcp_server::Listen::Params::Create(*args_); |
| 166 EXTENSION_FUNCTION_VALIDATE(params_.get()); | 166 EXTENSION_FUNCTION_VALIDATE(params_.get()); |
| 167 | 167 |
| 168 socket_event_dispatcher_ = TCPServerSocketEventDispatcher::Get(GetProfile()); | 168 socket_event_dispatcher_ = |
| 169 TCPServerSocketEventDispatcher::Get(browser_context()); |
| 169 DCHECK(socket_event_dispatcher_) << "There is no socket event dispatcher. " | 170 DCHECK(socket_event_dispatcher_) << "There is no socket event dispatcher. " |
| 170 "If this assertion is failing during a test, then it is likely that " | 171 "If this assertion is failing during a test, then it is likely that " |
| 171 "TestExtensionSystem is failing to provide an instance of " | 172 "TestExtensionSystem is failing to provide an instance of " |
| 172 "TCPServerSocketEventDispatcher."; | 173 "TCPServerSocketEventDispatcher."; |
| 173 return socket_event_dispatcher_ != NULL; | 174 return socket_event_dispatcher_ != NULL; |
| 174 } | 175 } |
| 175 | 176 |
| 176 void SocketsTcpServerListenFunction::Work() { | 177 void SocketsTcpServerListenFunction::Work() { |
| 177 ResumableTCPServerSocket* socket = GetTcpSocket(params_->socket_id); | 178 ResumableTCPServerSocket* socket = GetTcpSocket(params_->socket_id); |
| 178 if (!socket) { | 179 if (!socket) { |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 if (socket) { | 291 if (socket) { |
| 291 socket_infos.push_back(CreateSocketInfo(socket_id, socket)); | 292 socket_infos.push_back(CreateSocketInfo(socket_id, socket)); |
| 292 } | 293 } |
| 293 } | 294 } |
| 294 } | 295 } |
| 295 results_ = sockets_tcp_server::GetSockets::Results::Create(socket_infos); | 296 results_ = sockets_tcp_server::GetSockets::Results::Create(socket_infos); |
| 296 } | 297 } |
| 297 | 298 |
| 298 } // namespace api | 299 } // namespace api |
| 299 } // namespace extensions | 300 } // namespace extensions |
| OLD | NEW |