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

Side by Side Diff: webkit/plugins/ppapi/ppb_transport_impl.cc

Issue 7820008: Add TCP configuration parameters for Transport API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 9 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/glue/p2p_transport.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "webkit/plugins/ppapi/ppb_transport_impl.h" 5 #include "webkit/plugins/ppapi/ppb_transport_impl.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "net/base/io_buffer.h" 9 #include "net/base/io_buffer.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
(...skipping 15 matching lines...) Expand all
26 namespace webkit { 26 namespace webkit {
27 namespace ppapi { 27 namespace ppapi {
28 28
29 namespace { 29 namespace {
30 30
31 const char kUdpProtocolName[] = "udp"; 31 const char kUdpProtocolName[] = "udp";
32 const char kTcpProtocolName[] = "tcp"; 32 const char kTcpProtocolName[] = "tcp";
33 33
34 const int kMinBufferSize = 1024; 34 const int kMinBufferSize = 1024;
35 const int kMaxBufferSize = 1024 * 1024; 35 const int kMaxBufferSize = 1024 * 1024;
36 const int kMinAckDelay = 10;
37 const int kMaxAckDelay = 1000;
36 38
37 int MapNetError(int result) { 39 int MapNetError(int result) {
38 if (result > 0) 40 if (result > 0)
39 return result; 41 return result;
40 42
41 switch (result) { 43 switch (result) {
42 case net::OK: 44 case net::OK:
43 return PP_OK; 45 return PP_OK;
44 case net::ERR_IO_PENDING: 46 case net::ERR_IO_PENDING:
45 return PP_OK_COMPLETIONPENDING; 47 return PP_OK_COMPLETIONPENDING;
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 165
164 int32_t int_value = value.value.as_int; 166 int32_t int_value = value.value.as_int;
165 if (value.type != PP_VARTYPE_INT32 || int_value < kMinBufferSize || 167 if (value.type != PP_VARTYPE_INT32 || int_value < kMinBufferSize ||
166 int_value > kMaxBufferSize) { 168 int_value > kMaxBufferSize) {
167 return PP_ERROR_BADARGUMENT; 169 return PP_ERROR_BADARGUMENT;
168 } 170 }
169 config_.tcp_send_window = int_value; 171 config_.tcp_send_window = int_value;
170 break; 172 break;
171 } 173 }
172 174
175 case PP_TRANSPORTPROPERTY_TCP_NO_DELAY: {
176 if (!use_tcp_)
177 return PP_ERROR_BADARGUMENT;
178
179 if (value.type != PP_VARTYPE_BOOL)
180 return PP_ERROR_BADARGUMENT;
181 config_.tcp_no_delay = PP_ToBool(value.value.as_bool);
182 break;
183 }
184
185 case PP_TRANSPORTPROPERTY_TCP_ACK_DELAY: {
186 if (!use_tcp_)
187 return PP_ERROR_BADARGUMENT;
188
189 int32_t int_value = value.value.as_int;
190 if (value.type != PP_VARTYPE_INT32 || int_value < kMinAckDelay ||
191 int_value > kMaxAckDelay) {
192 return PP_ERROR_BADARGUMENT;
193 }
194 config_.tcp_ack_delay_ms = int_value;
195 break;
196 }
197
173 default: 198 default:
174 return PP_ERROR_BADARGUMENT; 199 return PP_ERROR_BADARGUMENT;
175 } 200 }
176 201
177 return PP_OK; 202 return PP_OK;
178 } 203 }
179 204
180 int32_t PPB_Transport_Impl::Connect(PP_CompletionCallback callback) { 205 int32_t PPB_Transport_Impl::Connect(PP_CompletionCallback callback) {
181 if (!p2p_transport_.get()) 206 if (!p2p_transport_.get())
182 return PP_ERROR_FAILED; 207 return PP_ERROR_FAILED;
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 317
293 return result; 318 return result;
294 } 319 }
295 320
296 int32_t PPB_Transport_Impl::Close() { 321 int32_t PPB_Transport_Impl::Close() {
297 if (!p2p_transport_.get()) 322 if (!p2p_transport_.get())
298 return PP_ERROR_FAILED; 323 return PP_ERROR_FAILED;
299 324
300 p2p_transport_.reset(); 325 p2p_transport_.reset();
301 326
302
303 PluginModule* plugin_module = ResourceHelper::GetPluginModule(this); 327 PluginModule* plugin_module = ResourceHelper::GetPluginModule(this);
304 if (plugin_module) 328 if (plugin_module)
305 plugin_module->GetCallbackTracker()->AbortAll(); 329 plugin_module->GetCallbackTracker()->AbortAll();
306 return PP_OK; 330 return PP_OK;
307 } 331 }
308 332
309 void PPB_Transport_Impl::OnCandidateReady(const std::string& address) { 333 void PPB_Transport_Impl::OnCandidateReady(const std::string& address) {
310 // Store the candidate first before calling the callback. 334 // Store the candidate first before calling the callback.
311 local_candidates_.push_back(address); 335 local_candidates_.push_back(address);
312 336
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 void PPB_Transport_Impl::OnWritten(int result) { 370 void PPB_Transport_Impl::OnWritten(int result) {
347 DCHECK(send_callback_.get() && !send_callback_->completed()); 371 DCHECK(send_callback_.get() && !send_callback_->completed());
348 372
349 scoped_refptr<TrackedCompletionCallback> callback; 373 scoped_refptr<TrackedCompletionCallback> callback;
350 callback.swap(send_callback_); 374 callback.swap(send_callback_);
351 callback->Run(MapNetError(result)); 375 callback->Run(MapNetError(result));
352 } 376 }
353 377
354 } // namespace ppapi 378 } // namespace ppapi
355 } // namespace webkit 379 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/glue/p2p_transport.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698