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

Unified Diff: mojo/services/network/udp_socket_impl.cc

Issue 880613005: De-Clientize UDPSocket service (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@rollin
Patch Set: Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/services/network/udp_socket_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/services/network/udp_socket_impl.cc
diff --git a/mojo/services/network/udp_socket_impl.cc b/mojo/services/network/udp_socket_impl.cc
index 524136a32744b49fd542a1c1a468485cc605f2bf..cc11da7c0e89fdd50f5485b4b808677da30e063f 100644
--- a/mojo/services/network/udp_socket_impl.cc
+++ b/mojo/services/network/udp_socket_impl.cc
@@ -34,9 +34,12 @@ UDPSocketImpl::PendingSendRequest::PendingSendRequest() {}
UDPSocketImpl::PendingSendRequest::~PendingSendRequest() {}
-UDPSocketImpl::UDPSocketImpl()
- : socket_(net::DatagramSocket::DEFAULT_BIND, net::RandIntCallback(),
- nullptr, net::NetLog::Source()),
+UDPSocketImpl::UDPSocketImpl(InterfaceRequest<UDPSocket> request)
+ : binding_(this, request.Pass()),
+ socket_(net::DatagramSocket::DEFAULT_BIND,
+ net::RandIntCallback(),
+ nullptr,
+ net::NetLog::Source()),
state_(NOT_BOUND_OR_CONNECTED),
allow_address_reuse_(false),
remaining_recv_slots_(0),
@@ -60,7 +63,9 @@ void UDPSocketImpl::AllowAddressReuse(
void UDPSocketImpl::Bind(
NetAddressPtr addr,
- const Callback<void(NetworkErrorPtr, NetAddressPtr)>& callback) {
+ const Callback<void(NetworkErrorPtr,
+ NetAddressPtr,
+ InterfaceRequest<UDPSocketReceiver>)>& callback) {
int net_result = net::OK;
bool opened = false;
@@ -98,7 +103,7 @@ void UDPSocketImpl::Bind(
state_ = BOUND;
callback.Run(MakeNetworkError(net_result),
- NetAddress::From(bound_ip_end_point));
+ NetAddress::From(bound_ip_end_point), GetProxy(&receiver_));
if (remaining_recv_slots_ > 0) {
DCHECK(!recvfrom_buffer_.get());
@@ -110,12 +115,14 @@ void UDPSocketImpl::Bind(
DCHECK(net_result != net::OK);
if (opened)
socket_.Close();
- callback.Run(MakeNetworkError(net_result), nullptr);
+ callback.Run(MakeNetworkError(net_result), nullptr, nullptr);
}
void UDPSocketImpl::Connect(
NetAddressPtr remote_addr,
- const Callback<void(NetworkErrorPtr, NetAddressPtr)>& callback) {
+ const Callback<void(NetworkErrorPtr,
+ NetAddressPtr,
+ InterfaceRequest<UDPSocketReceiver>)>& callback) {
int net_result = net::OK;
bool opened = false;
@@ -147,7 +154,7 @@ void UDPSocketImpl::Connect(
state_ = CONNECTED;
callback.Run(MakeNetworkError(net_result),
- NetAddress::From(local_ip_end_point));
+ NetAddress::From(local_ip_end_point), GetProxy(&receiver_));
if (remaining_recv_slots_ > 0) {
DCHECK(!recvfrom_buffer_.get());
@@ -159,7 +166,7 @@ void UDPSocketImpl::Connect(
DCHECK(net_result != net::OK);
if (opened)
socket_.Close();
- callback.Run(MakeNetworkError(net_result), nullptr);
+ callback.Run(MakeNetworkError(net_result), nullptr, nullptr);
}
void UDPSocketImpl::SetSendBufferSize(
@@ -216,6 +223,8 @@ void UDPSocketImpl::NegotiateMaxPendingSendRequests(
}
void UDPSocketImpl::ReceiveMore(uint32_t datagram_number) {
+ if (!receiver_)
+ return;
if (datagram_number == 0)
return;
if (std::numeric_limits<size_t>::max() - remaining_recv_slots_ <
@@ -264,6 +273,7 @@ void UDPSocketImpl::SendTo(NetAddressPtr dest_addr,
void UDPSocketImpl::DoRecvFrom() {
DCHECK(IsBoundOrConnected());
+ DCHECK(receiver_);
DCHECK(!recvfrom_buffer_.get());
DCHECK_GT(remaining_recv_slots_, 0u);
@@ -337,9 +347,8 @@ void UDPSocketImpl::OnRecvFromCompleted(int net_result) {
}
recvfrom_buffer_ = nullptr;
- client()->OnReceived(MakeNetworkError(net_result), net_address.Pass(),
- array.Pass());
-
+ receiver_->OnReceived(MakeNetworkError(net_result), net_address.Pass(),
+ array.Pass());
DCHECK_GT(remaining_recv_slots_, 0u);
remaining_recv_slots_--;
if (remaining_recv_slots_ > 0)
« no previous file with comments | « mojo/services/network/udp_socket_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698