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

Side by Side Diff: net/curvecp/client_packetizer.cc

Issue 9597005: Revert 124890 - Convert uses of int ms to TimeDelta in chrome/browser and net. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 9 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 | « net/curvecp/client_packetizer.h ('k') | net/disk_cache/stress_cache.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 (c) 2012 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 "net/curvecp/client_packetizer.h" 5 #include "net/curvecp/client_packetizer.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "net/base/io_buffer.h" 8 #include "net/base/io_buffer.h"
9 #include "net/base/net_errors.h" 9 #include "net/base/net_errors.h"
10 #include "net/base/sys_addrinfo.h" 10 #include "net/base/sys_addrinfo.h"
11 #include "net/curvecp/protocol.h" 11 #include "net/curvecp/protocol.h"
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 if (rv != sizeof(struct HelloPacket)) 228 if (rv != sizeof(struct HelloPacket))
229 return ERR_FAILED; 229 return ERR_FAILED;
230 230
231 next_state_ = WAITING_COOKIE; 231 next_state_ = WAITING_COOKIE;
232 return OK; 232 return OK;
233 } 233 }
234 234
235 int ClientPacketizer::DoWaitingCookie() { 235 int ClientPacketizer::DoWaitingCookie() {
236 next_state_ = WAITING_COOKIE_COMPLETE; 236 next_state_ = WAITING_COOKIE_COMPLETE;
237 237
238 StartHelloTimer(base::TimeDelta::FromMilliseconds( 238 StartHelloTimer(kHelloTimeoutMs[hello_attempts_++]);
239 kHelloTimeoutMs[hello_attempts_++]));
240 239
241 read_buffer_ = new IOBuffer(kMaxPacketLength); 240 read_buffer_ = new IOBuffer(kMaxPacketLength);
242 return socket_->Read(read_buffer_, kMaxPacketLength, io_callback_); 241 return socket_->Read(read_buffer_, kMaxPacketLength, io_callback_);
243 } 242 }
244 243
245 int ClientPacketizer::DoWaitingCookieComplete(int rv) { 244 int ClientPacketizer::DoWaitingCookieComplete(int rv) {
246 // TODO(mbelshe): Add Histogram for hello_attempts_. 245 // TODO(mbelshe): Add Histogram for hello_attempts_.
247 RevokeHelloTimer(); 246 RevokeHelloTimer();
248 247
249 // TODO(mbelshe): Validate the cookie here 248 // TODO(mbelshe): Validate the cookie here
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 if (!endpoint.FromSockAddr(current_address_->ai_addr, 306 if (!endpoint.FromSockAddr(current_address_->ai_addr,
308 current_address_->ai_addrlen)) 307 current_address_->ai_addrlen))
309 return ERR_FAILED; 308 return ERR_FAILED;
310 309
311 int rv = socket_->Connect(endpoint); 310 int rv = socket_->Connect(endpoint);
312 DCHECK_NE(ERR_IO_PENDING, rv); 311 DCHECK_NE(ERR_IO_PENDING, rv);
313 312
314 return rv; 313 return rv;
315 } 314 }
316 315
317 void ClientPacketizer::StartHelloTimer(base::TimeDelta delay) { 316 void ClientPacketizer::StartHelloTimer(int milliseconds) {
318 MessageLoop::current()->PostDelayedTask( 317 MessageLoop::current()->PostDelayedTask(
319 FROM_HERE, 318 FROM_HERE,
320 base::Bind(&ClientPacketizer::OnHelloTimeout, weak_factory_.GetWeakPtr()), 319 base::Bind(&ClientPacketizer::OnHelloTimeout, weak_factory_.GetWeakPtr()),
321 delay); 320 milliseconds);
322 } 321 }
323 322
324 void ClientPacketizer::RevokeHelloTimer() { 323 void ClientPacketizer::RevokeHelloTimer() {
325 weak_factory_.InvalidateWeakPtrs(); 324 weak_factory_.InvalidateWeakPtrs();
326 } 325 }
327 326
328 void ClientPacketizer::OnHelloTimeout() { 327 void ClientPacketizer::OnHelloTimeout() {
329 DCHECK_EQ(WAITING_COOKIE_COMPLETE, next_state_); 328 DCHECK_EQ(WAITING_COOKIE_COMPLETE, next_state_);
330 next_state_ = SENDING_HELLO; 329 next_state_ = SENDING_HELLO;
331 DLOG(INFO) << "HelloTimeout #" << hello_attempts_; 330 DLOG(INFO) << "HelloTimeout #" << hello_attempts_;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 return rv; 380 return rv;
382 } 381 }
383 382
384 void ClientPacketizer::OnIOComplete(int result) { 383 void ClientPacketizer::OnIOComplete(int result) {
385 int rv = DoLoop(result); 384 int rv = DoLoop(result);
386 if (rv != ERR_IO_PENDING) 385 if (rv != ERR_IO_PENDING)
387 DoCallback(rv); 386 DoCallback(rv);
388 } 387 }
389 388
390 } // namespace net 389 } // namespace net
OLDNEW
« no previous file with comments | « net/curvecp/client_packetizer.h ('k') | net/disk_cache/stress_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698