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

Side by Side Diff: content/common/resource_dispatcher.cc

Issue 7602023: Use a monotonic clock (TimeTicks) to report network times to WebCore. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add random test Created 9 years 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
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 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc e-loading 5 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc e-loading
6 6
7 #include "content/common/resource_dispatcher.h" 7 #include "content/common/resource_dispatcher.h"
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 return; 325 return;
326 326
327 request_info->peer->OnUploadProgress(position, size); 327 request_info->peer->OnUploadProgress(position, size);
328 328
329 // Acknowledge receipt 329 // Acknowledge receipt
330 message_sender()->Send( 330 message_sender()->Send(
331 new ResourceHostMsg_UploadProgress_ACK(message.routing_id(), request_id)); 331 new ResourceHostMsg_UploadProgress_ACK(message.routing_id(), request_id));
332 } 332 }
333 333
334 void ResourceDispatcher::OnReceivedResponse( 334 void ResourceDispatcher::OnReceivedResponse(
335 int request_id, const ResourceResponseHead& response_head) { 335 int request_id, const ResourceResponseHead& response_head,
336 const base::TimeTicks& request_start_time,
337 const base::TimeTicks& response_start_time) {
336 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); 338 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id);
337 if (!request_info) 339 if (!request_info)
338 return; 340 return;
339 341
340 if (delegate_) { 342 if (delegate_) {
341 webkit_glue::ResourceLoaderBridge::Peer* new_peer = 343 webkit_glue::ResourceLoaderBridge::Peer* new_peer =
342 delegate_->OnReceivedResponse( 344 delegate_->OnReceivedResponse(
343 request_info->peer, response_head.mime_type, request_info->url); 345 request_info->peer, response_head.mime_type, request_info->url);
344 if (new_peer) 346 if (new_peer)
345 request_info->peer = new_peer; 347 request_info->peer = new_peer;
346 } 348 }
347 349
348 request_info->peer->OnReceivedResponse(response_head); 350 request_info->peer->OnReceivedResponse(response_head,
351 request_start_time,
352 response_start_time);
349 } 353 }
350 354
351 void ResourceDispatcher::OnReceivedCachedMetadata( 355 void ResourceDispatcher::OnReceivedCachedMetadata(
352 int request_id, const std::vector<char>& data) { 356 int request_id, const std::vector<char>& data) {
353 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); 357 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id);
354 if (!request_info) 358 if (!request_info)
355 return; 359 return;
356 360
357 if (data.size()) 361 if (data.size())
358 request_info->peer->OnReceivedCachedMetadata(&data.front(), data.size()); 362 request_info->peer->OnReceivedCachedMetadata(&data.front(), data.size());
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 if (!request_info) 396 if (!request_info)
393 return; 397 return;
394 398
395 request_info->peer->OnDownloadedData(data_len); 399 request_info->peer->OnDownloadedData(data_len);
396 } 400 }
397 401
398 void ResourceDispatcher::OnReceivedRedirect( 402 void ResourceDispatcher::OnReceivedRedirect(
399 const IPC::Message& message, 403 const IPC::Message& message,
400 int request_id, 404 int request_id,
401 const GURL& new_url, 405 const GURL& new_url,
402 const webkit_glue::ResourceResponseInfo& info) { 406 const webkit_glue::ResourceResponseInfo& info,
407 const base::TimeTicks& request_start_time,
408 const base::TimeTicks& response_start_time) {
403 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); 409 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id);
404 if (!request_info) 410 if (!request_info)
405 return; 411 return;
406 412
407 int32 routing_id = message.routing_id(); 413 int32 routing_id = message.routing_id();
408 bool has_new_first_party_for_cookies = false; 414 bool has_new_first_party_for_cookies = false;
409 GURL new_first_party_for_cookies; 415 GURL new_first_party_for_cookies;
410 if (request_info->peer->OnReceivedRedirect(new_url, info, 416 if (request_info->peer->OnReceivedRedirect(new_url, info,
411 &has_new_first_party_for_cookies, 417 request_start_time,
412 &new_first_party_for_cookies)) { 418 response_start_time,
419 &has_new_first_party_for_cookies,
420 &new_first_party_for_cookies)) {
413 // Double-check if the request is still around. The call above could 421 // Double-check if the request is still around. The call above could
414 // potentially remove it. 422 // potentially remove it.
415 request_info = GetPendingRequestInfo(request_id); 423 request_info = GetPendingRequestInfo(request_id);
416 if (!request_info) 424 if (!request_info)
417 return; 425 return;
418 request_info->pending_redirect_message.reset( 426 request_info->pending_redirect_message.reset(
419 new ResourceHostMsg_FollowRedirect(routing_id, request_id, 427 new ResourceHostMsg_FollowRedirect(routing_id, request_id,
420 has_new_first_party_for_cookies, 428 has_new_first_party_for_cookies,
421 new_first_party_for_cookies)); 429 new_first_party_for_cookies));
422 if (!request_info->is_deferred) { 430 if (!request_info->is_deferred) {
423 FollowPendingRedirect(request_id, *request_info); 431 FollowPendingRedirect(request_id, *request_info);
424 } 432 }
425 } else { 433 } else {
426 CancelPendingRequest(routing_id, request_id); 434 CancelPendingRequest(routing_id, request_id);
427 } 435 }
428 } 436 }
429 437
430 void ResourceDispatcher::FollowPendingRedirect( 438 void ResourceDispatcher::FollowPendingRedirect(
431 int request_id, 439 int request_id,
432 PendingRequestInfo& request_info) { 440 PendingRequestInfo& request_info) {
433 IPC::Message* msg = request_info.pending_redirect_message.release(); 441 IPC::Message* msg = request_info.pending_redirect_message.release();
434 if (msg) 442 if (msg)
435 message_sender()->Send(msg); 443 message_sender()->Send(msg);
436 } 444 }
437 445
438 void ResourceDispatcher::OnRequestComplete(int request_id, 446 void ResourceDispatcher::OnRequestComplete(
439 const net::URLRequestStatus& status, 447 int request_id,
440 const std::string& security_info, 448 const net::URLRequestStatus& status,
441 const base::Time& completion_time) { 449 const std::string& security_info,
450 const base::TimeTicks& completion_time) {
442 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); 451 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id);
443 if (!request_info) 452 if (!request_info)
444 return; 453 return;
445 454
446 webkit_glue::ResourceLoaderBridge::Peer* peer = request_info->peer; 455 webkit_glue::ResourceLoaderBridge::Peer* peer = request_info->peer;
447 456
448 if (delegate_) { 457 if (delegate_) {
449 webkit_glue::ResourceLoaderBridge::Peer* new_peer = 458 webkit_glue::ResourceLoaderBridge::Peer* new_peer =
450 delegate_->OnRequestComplete( 459 delegate_->OnRequestComplete(
451 request_info->peer, request_info->resource_type, status); 460 request_info->peer, request_info->resource_type, status);
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 619
611 // static 620 // static
612 void ResourceDispatcher::ReleaseResourcesInMessageQueue(MessageQueue* queue) { 621 void ResourceDispatcher::ReleaseResourcesInMessageQueue(MessageQueue* queue) {
613 while (!queue->empty()) { 622 while (!queue->empty()) {
614 IPC::Message* message = queue->front(); 623 IPC::Message* message = queue->front();
615 ReleaseResourcesInDataMessage(*message); 624 ReleaseResourcesInDataMessage(*message);
616 queue->pop_front(); 625 queue->pop_front();
617 delete message; 626 delete message;
618 } 627 }
619 } 628 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698