| OLD | NEW |
| 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_udp/sockets_udp_api.h" | 5 #include "extensions/browser/api/sockets_udp/sockets_udp_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/udp_socket.h" | 8 #include "extensions/browser/api/socket/udp_socket.h" |
| 9 #include "extensions/browser/api/sockets_udp/udp_socket_event_dispatcher.h" | 9 #include "extensions/browser/api/sockets_udp/udp_socket_event_dispatcher.h" |
| 10 #include "extensions/common/api/sockets/sockets_manifest_data.h" | 10 #include "extensions/common/api/sockets/sockets_manifest_data.h" |
| 11 #include "net/base/net_errors.h" | 11 #include "net/base/net_errors.h" |
| 12 | 12 |
| 13 namespace extensions { | 13 namespace extensions { |
| 14 namespace api { | 14 namespace api { |
| 15 | 15 |
| 16 using content::SocketPermissionRequest; | 16 using content::SocketPermissionRequest; |
| 17 | 17 |
| 18 const char kSocketNotFoundError[] = "Socket not found"; | 18 const char kSocketNotFoundError[] = "Socket not found"; |
| 19 const char kPermissionError[] = "App does not have permission"; | 19 const char kPermissionError[] = "App does not have permission"; |
| 20 const char kWildcardAddress[] = "*"; | 20 const char kWildcardAddress[] = "*"; |
| 21 const int kWildcardPort = 0; | 21 const int kWildcardPort = 0; |
| 22 | 22 |
| 23 UDPSocketAsyncApiFunction::~UDPSocketAsyncApiFunction() {} | 23 UDPSocketAsyncApiFunction::~UDPSocketAsyncApiFunction() {} |
| 24 | 24 |
| 25 scoped_ptr<SocketResourceManagerInterface> | 25 std::unique_ptr<SocketResourceManagerInterface> |
| 26 UDPSocketAsyncApiFunction::CreateSocketResourceManager() { | 26 UDPSocketAsyncApiFunction::CreateSocketResourceManager() { |
| 27 return scoped_ptr<SocketResourceManagerInterface>( | 27 return std::unique_ptr<SocketResourceManagerInterface>( |
| 28 new SocketResourceManager<ResumableUDPSocket>()); | 28 new SocketResourceManager<ResumableUDPSocket>()); |
| 29 } | 29 } |
| 30 | 30 |
| 31 ResumableUDPSocket* UDPSocketAsyncApiFunction::GetUdpSocket(int socket_id) { | 31 ResumableUDPSocket* UDPSocketAsyncApiFunction::GetUdpSocket(int socket_id) { |
| 32 return static_cast<ResumableUDPSocket*>(GetSocket(socket_id)); | 32 return static_cast<ResumableUDPSocket*>(GetSocket(socket_id)); |
| 33 } | 33 } |
| 34 | 34 |
| 35 UDPSocketExtensionWithDnsLookupFunction:: | 35 UDPSocketExtensionWithDnsLookupFunction:: |
| 36 ~UDPSocketExtensionWithDnsLookupFunction() {} | 36 ~UDPSocketExtensionWithDnsLookupFunction() {} |
| 37 | 37 |
| 38 scoped_ptr<SocketResourceManagerInterface> | 38 std::unique_ptr<SocketResourceManagerInterface> |
| 39 UDPSocketExtensionWithDnsLookupFunction::CreateSocketResourceManager() { | 39 UDPSocketExtensionWithDnsLookupFunction::CreateSocketResourceManager() { |
| 40 return scoped_ptr<SocketResourceManagerInterface>( | 40 return std::unique_ptr<SocketResourceManagerInterface>( |
| 41 new SocketResourceManager<ResumableUDPSocket>()); | 41 new SocketResourceManager<ResumableUDPSocket>()); |
| 42 } | 42 } |
| 43 | 43 |
| 44 ResumableUDPSocket* UDPSocketExtensionWithDnsLookupFunction::GetUdpSocket( | 44 ResumableUDPSocket* UDPSocketExtensionWithDnsLookupFunction::GetUdpSocket( |
| 45 int socket_id) { | 45 int socket_id) { |
| 46 return static_cast<ResumableUDPSocket*>(GetSocket(socket_id)); | 46 return static_cast<ResumableUDPSocket*>(GetSocket(socket_id)); |
| 47 } | 47 } |
| 48 | 48 |
| 49 sockets_udp::SocketInfo CreateSocketInfo(int socket_id, | 49 sockets_udp::SocketInfo CreateSocketInfo(int socket_id, |
| 50 ResumableUDPSocket* socket) { | 50 ResumableUDPSocket* socket) { |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 | 517 |
| 518 int net_result = socket->SetBroadcast(params_->enabled); | 518 int net_result = socket->SetBroadcast(params_->enabled); |
| 519 if (net_result != net::OK) { | 519 if (net_result != net::OK) { |
| 520 error_ = net::ErrorToString(net_result); | 520 error_ = net::ErrorToString(net_result); |
| 521 } | 521 } |
| 522 results_ = sockets_udp::SetBroadcast::Results::Create(net_result); | 522 results_ = sockets_udp::SetBroadcast::Results::Create(net_result); |
| 523 } | 523 } |
| 524 | 524 |
| 525 } // namespace api | 525 } // namespace api |
| 526 } // namespace extensions | 526 } // namespace extensions |
| OLD | NEW |