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

Side by Side Diff: mojo/services/public/cpp/network/udp_socket_wrapper.cc

Issue 703753005: More Windows build fixes. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: remove generated files Created 6 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « mojo/edk/system/data_pipe_consumer_dispatcher.cc ('k') | mojo/shell/desktop/mojo_main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "mojo/services/public/cpp/network/udp_socket_wrapper.h" 5 #include "mojo/services/public/cpp/network/udp_socket_wrapper.h"
6 6
7 #include <assert.h> 7 #include <assert.h>
8 8
9 #include "mojo/public/cpp/environment/logging.h" 9 #include "mojo/public/cpp/environment/logging.h"
10 10
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 request->dest_addr = dest_addr.Pass(); 117 request->dest_addr = dest_addr.Pass();
118 request->data = data.Pass(); 118 request->data = data.Pass();
119 request->callback = callback; 119 request->callback = callback;
120 send_requests_.push(request); 120 send_requests_.push(request);
121 return; 121 return;
122 } 122 }
123 123
124 MOJO_DCHECK(send_requests_.empty()); 124 MOJO_DCHECK(send_requests_.empty());
125 current_pending_sends_++; 125 current_pending_sends_++;
126 socket_->SendTo(dest_addr.Pass(), data.Pass(), 126 socket_->SendTo(dest_addr.Pass(), data.Pass(),
127 ErrorCallback(static_cast<typename ErrorCallback::Runnable*>( 127 ErrorCallback(static_cast<ErrorCallback::Runnable*>(
128 new SendCallbackHandler(this, callback)))); 128 new SendCallbackHandler(this, callback))));
129 } 129 }
130 130
131 void UDPSocketWrapper::OnReceived(NetworkErrorPtr result, 131 void UDPSocketWrapper::OnReceived(NetworkErrorPtr result,
132 NetAddressPtr src_addr, 132 NetAddressPtr src_addr,
133 Array<uint8_t> data) { 133 Array<uint8_t> data) {
134 if (!receive_requests_.empty()) { 134 if (!receive_requests_.empty()) {
135 // The cache should be empty if there are user requests waiting for data. 135 // The cache should be empty if there are user requests waiting for data.
136 MOJO_DCHECK(receive_queue_.empty()); 136 MOJO_DCHECK(receive_queue_.empty());
137 137
(...skipping 12 matching lines...) Expand all
150 received_data->src_addr = src_addr.Pass(); 150 received_data->src_addr = src_addr.Pass();
151 received_data->data = data.Pass(); 151 received_data->data = data.Pass();
152 receive_queue_.push(received_data); 152 receive_queue_.push(received_data);
153 } 153 }
154 154
155 void UDPSocketWrapper::Initialize(uint32_t requested_max_pending_sends) { 155 void UDPSocketWrapper::Initialize(uint32_t requested_max_pending_sends) {
156 socket_.set_client(this); 156 socket_.set_client(this);
157 socket_->NegotiateMaxPendingSendRequests( 157 socket_->NegotiateMaxPendingSendRequests(
158 requested_max_pending_sends, 158 requested_max_pending_sends,
159 Callback<void(uint32_t)>( 159 Callback<void(uint32_t)>(
160 static_cast<typename Callback<void(uint32_t)>::Runnable*>( 160 static_cast< Callback<void(uint32_t)>::Runnable*>(
161 new NegotiateCallbackHandler(this)))); 161 new NegotiateCallbackHandler(this))));
162 socket_->ReceiveMore(max_receive_queue_size_); 162 socket_->ReceiveMore(max_receive_queue_size_);
163 } 163 }
164 164
165 void UDPSocketWrapper::OnNegotiateMaxPendingSendRequestsCompleted( 165 void UDPSocketWrapper::OnNegotiateMaxPendingSendRequestsCompleted(
166 uint32_t actual_size) { 166 uint32_t actual_size) {
167 MOJO_DCHECK(max_pending_sends_ == 1); 167 MOJO_DCHECK(max_pending_sends_ == 1);
168 168
169 if (actual_size == 0) { 169 if (actual_size == 0) {
170 assert(false); 170 assert(false);
(...skipping 18 matching lines...) Expand all
189 if (current_pending_sends_ >= max_pending_sends_ || send_requests_.empty()) 189 if (current_pending_sends_ >= max_pending_sends_ || send_requests_.empty())
190 return false; 190 return false;
191 191
192 SendRequest* request = send_requests_.front(); 192 SendRequest* request = send_requests_.front();
193 send_requests_.pop(); 193 send_requests_.pop();
194 194
195 current_pending_sends_++; 195 current_pending_sends_++;
196 196
197 socket_->SendTo( 197 socket_->SendTo(
198 request->dest_addr.Pass(), request->data.Pass(), 198 request->dest_addr.Pass(), request->data.Pass(),
199 ErrorCallback(static_cast<typename ErrorCallback::Runnable*>( 199 ErrorCallback(static_cast<ErrorCallback::Runnable*>(
200 new SendCallbackHandler(this, request->callback)))); 200 new SendCallbackHandler(this, request->callback))));
201 201
202 delete request; 202 delete request;
203 203
204 return true; 204 return true;
205 } 205 }
206 206
207 } // namespace mojo 207 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/data_pipe_consumer_dispatcher.cc ('k') | mojo/shell/desktop/mojo_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698