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

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

Issue 9572036: Convert uses of int ms to TimeDelta in chrome/browser and net. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Add more TimeDelta integration. 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
« 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) 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 "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"
(...skipping 217 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(kHelloTimeoutMs[hello_attempts_++]); 238 StartHelloTimer(base::TimeDelta::FromMilliseconds(
239 kHelloTimeoutMs[hello_attempts_++]));
239 240
240 read_buffer_ = new IOBuffer(kMaxPacketLength); 241 read_buffer_ = new IOBuffer(kMaxPacketLength);
241 return socket_->Read(read_buffer_, kMaxPacketLength, io_callback_); 242 return socket_->Read(read_buffer_, kMaxPacketLength, io_callback_);
242 } 243 }
243 244
244 int ClientPacketizer::DoWaitingCookieComplete(int rv) { 245 int ClientPacketizer::DoWaitingCookieComplete(int rv) {
245 // TODO(mbelshe): Add Histogram for hello_attempts_. 246 // TODO(mbelshe): Add Histogram for hello_attempts_.
246 RevokeHelloTimer(); 247 RevokeHelloTimer();
247 248
248 // TODO(mbelshe): Validate the cookie here 249 // TODO(mbelshe): Validate the cookie here
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 if (!endpoint.FromSockAddr(current_address_->ai_addr, 307 if (!endpoint.FromSockAddr(current_address_->ai_addr,
307 current_address_->ai_addrlen)) 308 current_address_->ai_addrlen))
308 return ERR_FAILED; 309 return ERR_FAILED;
309 310
310 int rv = socket_->Connect(endpoint); 311 int rv = socket_->Connect(endpoint);
311 DCHECK_NE(ERR_IO_PENDING, rv); 312 DCHECK_NE(ERR_IO_PENDING, rv);
312 313
313 return rv; 314 return rv;
314 } 315 }
315 316
316 void ClientPacketizer::StartHelloTimer(int milliseconds) { 317 void ClientPacketizer::StartHelloTimer(base::TimeDelta delay) {
317 MessageLoop::current()->PostDelayedTask( 318 MessageLoop::current()->PostDelayedTask(
318 FROM_HERE, 319 FROM_HERE,
319 base::Bind(&ClientPacketizer::OnHelloTimeout, weak_factory_.GetWeakPtr()), 320 base::Bind(&ClientPacketizer::OnHelloTimeout, weak_factory_.GetWeakPtr()),
320 milliseconds); 321 delay);
321 } 322 }
322 323
323 void ClientPacketizer::RevokeHelloTimer() { 324 void ClientPacketizer::RevokeHelloTimer() {
324 weak_factory_.InvalidateWeakPtrs(); 325 weak_factory_.InvalidateWeakPtrs();
325 } 326 }
326 327
327 void ClientPacketizer::OnHelloTimeout() { 328 void ClientPacketizer::OnHelloTimeout() {
328 DCHECK_EQ(WAITING_COOKIE_COMPLETE, next_state_); 329 DCHECK_EQ(WAITING_COOKIE_COMPLETE, next_state_);
329 next_state_ = SENDING_HELLO; 330 next_state_ = SENDING_HELLO;
330 DLOG(INFO) << "HelloTimeout #" << hello_attempts_; 331 DLOG(INFO) << "HelloTimeout #" << hello_attempts_;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 return rv; 381 return rv;
381 } 382 }
382 383
383 void ClientPacketizer::OnIOComplete(int result) { 384 void ClientPacketizer::OnIOComplete(int result) {
384 int rv = DoLoop(result); 385 int rv = DoLoop(result);
385 if (rv != ERR_IO_PENDING) 386 if (rv != ERR_IO_PENDING)
386 DoCallback(rv); 387 DoCallback(rv);
387 } 388 }
388 389
389 } // namespace net 390 } // 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