| 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_udp/sockets_udp_api.h" | 5 #include "chrome/browser/extensions/api/sockets_udp/sockets_udp_api.h" |
| 6 | 6 |
| 7 #include "chrome/browser/extensions/api/socket/udp_socket.h" | 7 #include "chrome/browser/extensions/api/socket/udp_socket.h" |
| 8 #include "chrome/browser/extensions/api/sockets_udp/udp_socket_event_dispatcher.
h" | 8 #include "chrome/browser/extensions/api/sockets_udp/udp_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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 | 133 |
| 134 SocketsUdpSetPausedFunction::SocketsUdpSetPausedFunction() | 134 SocketsUdpSetPausedFunction::SocketsUdpSetPausedFunction() |
| 135 : socket_event_dispatcher_(NULL) {} | 135 : socket_event_dispatcher_(NULL) {} |
| 136 | 136 |
| 137 SocketsUdpSetPausedFunction::~SocketsUdpSetPausedFunction() {} | 137 SocketsUdpSetPausedFunction::~SocketsUdpSetPausedFunction() {} |
| 138 | 138 |
| 139 bool SocketsUdpSetPausedFunction::Prepare() { | 139 bool SocketsUdpSetPausedFunction::Prepare() { |
| 140 params_ = api::sockets_udp::SetPaused::Params::Create(*args_); | 140 params_ = api::sockets_udp::SetPaused::Params::Create(*args_); |
| 141 EXTENSION_FUNCTION_VALIDATE(params_.get()); | 141 EXTENSION_FUNCTION_VALIDATE(params_.get()); |
| 142 | 142 |
| 143 socket_event_dispatcher_ = UDPSocketEventDispatcher::Get(GetProfile()); | 143 socket_event_dispatcher_ = UDPSocketEventDispatcher::Get(context()); |
| 144 DCHECK(socket_event_dispatcher_) << "There is no socket event dispatcher. " | 144 DCHECK(socket_event_dispatcher_) << "There is no socket event dispatcher. " |
| 145 "If this assertion is failing during a test, then it is likely that " | 145 "If this assertion is failing during a test, then it is likely that " |
| 146 "TestExtensionSystem is failing to provide an instance of " | 146 "TestExtensionSystem is failing to provide an instance of " |
| 147 "UDPSocketEventDispatcher."; | 147 "UDPSocketEventDispatcher."; |
| 148 return socket_event_dispatcher_ != NULL; | 148 return socket_event_dispatcher_ != NULL; |
| 149 } | 149 } |
| 150 | 150 |
| 151 void SocketsUdpSetPausedFunction::Work() { | 151 void SocketsUdpSetPausedFunction::Work() { |
| 152 ResumableUDPSocket* socket = GetUdpSocket(params_->socket_id); | 152 ResumableUDPSocket* socket = GetUdpSocket(params_->socket_id); |
| 153 if (!socket) { | 153 if (!socket) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 169 SocketsUdpBindFunction::SocketsUdpBindFunction() | 169 SocketsUdpBindFunction::SocketsUdpBindFunction() |
| 170 : socket_event_dispatcher_(NULL) { | 170 : socket_event_dispatcher_(NULL) { |
| 171 } | 171 } |
| 172 | 172 |
| 173 SocketsUdpBindFunction::~SocketsUdpBindFunction() {} | 173 SocketsUdpBindFunction::~SocketsUdpBindFunction() {} |
| 174 | 174 |
| 175 bool SocketsUdpBindFunction::Prepare() { | 175 bool SocketsUdpBindFunction::Prepare() { |
| 176 params_ = sockets_udp::Bind::Params::Create(*args_); | 176 params_ = sockets_udp::Bind::Params::Create(*args_); |
| 177 EXTENSION_FUNCTION_VALIDATE(params_.get()); | 177 EXTENSION_FUNCTION_VALIDATE(params_.get()); |
| 178 | 178 |
| 179 socket_event_dispatcher_ = UDPSocketEventDispatcher::Get(GetProfile()); | 179 socket_event_dispatcher_ = UDPSocketEventDispatcher::Get(context()); |
| 180 DCHECK(socket_event_dispatcher_) << "There is no socket event dispatcher. " | 180 DCHECK(socket_event_dispatcher_) << "There is no socket event dispatcher. " |
| 181 "If this assertion is failing during a test, then it is likely that " | 181 "If this assertion is failing during a test, then it is likely that " |
| 182 "TestExtensionSystem is failing to provide an instance of " | 182 "TestExtensionSystem is failing to provide an instance of " |
| 183 "UDPSocketEventDispatcher."; | 183 "UDPSocketEventDispatcher."; |
| 184 return socket_event_dispatcher_ != NULL; | 184 return socket_event_dispatcher_ != NULL; |
| 185 } | 185 } |
| 186 | 186 |
| 187 void SocketsUdpBindFunction::Work() { | 187 void SocketsUdpBindFunction::Work() { |
| 188 ResumableUDPSocket* socket = GetUdpSocket(params_->socket_id); | 188 ResumableUDPSocket* socket = GetUdpSocket(params_->socket_id); |
| 189 if (!socket) { | 189 if (!socket) { |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 error_ = kPermissionError; | 496 error_ = kPermissionError; |
| 497 return; | 497 return; |
| 498 } | 498 } |
| 499 | 499 |
| 500 const std::vector<std::string>& groups = socket->GetJoinedGroups(); | 500 const std::vector<std::string>& groups = socket->GetJoinedGroups(); |
| 501 results_ = sockets_udp::GetJoinedGroups::Results::Create(groups); | 501 results_ = sockets_udp::GetJoinedGroups::Results::Create(groups); |
| 502 } | 502 } |
| 503 | 503 |
| 504 } // namespace api | 504 } // namespace api |
| 505 } // namespace extensions | 505 } // namespace extensions |
| OLD | NEW |