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

Side by Side Diff: components/html_viewer/html_frame.cc

Issue 1391963004: Correctly record and pass around navigation start time. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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 | « components/html_viewer/html_frame.h ('k') | components/html_viewer/html_frame_apptest.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/html_viewer/html_frame.h" 5 #include "components/html_viewer/html_frame.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 if (IsLocal()) 265 if (IsLocal())
266 return true; 266 return true;
267 267
268 for (HTMLFrame* child : children_) { 268 for (HTMLFrame* child : children_) {
269 if (child->HasLocalDescendant()) 269 if (child->HasLocalDescendant())
270 return true; 270 return true;
271 } 271 }
272 return false; 272 return false;
273 } 273 }
274 274
275 void HTMLFrame::LoadRequest(const blink::WebURLRequest& request) { 275 void HTMLFrame::LoadRequest(const blink::WebURLRequest& request,
276 base::TimeTicks navigation_start_time) {
276 DCHECK(IsLocal()); 277 DCHECK(IsLocal());
277 278
278 DVLOG(2) << "HTMLFrame::LoadRequest this=" << this << " id=" << id_ 279 DVLOG(2) << "HTMLFrame::LoadRequest this=" << this << " id=" << id_
279 << " URL=" << GURL(request.url()); 280 << " URL=" << GURL(request.url());
280 281
281 pending_navigation_ = false; 282 pending_navigation_ = false;
283 navigation_start_time_ = navigation_start_time;
282 web_frame_->toWebLocalFrame()->loadRequest(request); 284 web_frame_->toWebLocalFrame()->loadRequest(request);
283 } 285 }
284 286
285 HTMLFrame::~HTMLFrame() { 287 HTMLFrame::~HTMLFrame() {
286 DVLOG(2) << "~HTMLFrame this=" << this << " id=" << id_; 288 DVLOG(2) << "~HTMLFrame this=" << this << " id=" << id_;
287 289
288 DCHECK(children_.empty()); 290 DCHECK(children_.empty());
289 291
290 if (parent_) { 292 if (parent_) {
291 auto iter = 293 auto iter =
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 } 390 }
389 391
390 // Ask the Frame to handle the navigation. Returning 392 // Ask the Frame to handle the navigation. Returning
391 // WebNavigationPolicyHandledByClient to inform blink that the navigation is 393 // WebNavigationPolicyHandledByClient to inform blink that the navigation is
392 // being handled. 394 // being handled.
393 DVLOG(2) << "HTMLFrame::decidePolicyForNavigation calls " 395 DVLOG(2) << "HTMLFrame::decidePolicyForNavigation calls "
394 << "Frame::RequestNavigate this=" << this << " id=" << id_ 396 << "Frame::RequestNavigate this=" << this << " id=" << id_
395 << " URL=" << GURL(info.urlRequest.url()); 397 << " URL=" << GURL(info.urlRequest.url());
396 398
397 mojo::URLRequestPtr url_request = mojo::URLRequest::From(info.urlRequest); 399 mojo::URLRequestPtr url_request = mojo::URLRequest::From(info.urlRequest);
400 url_request->originating_time_ticks =
401 base::TimeTicks::Now().ToInternalValue();
398 server_->RequestNavigate( 402 server_->RequestNavigate(
399 WebNavigationPolicyToNavigationTarget(info.defaultPolicy), id_, 403 WebNavigationPolicyToNavigationTarget(info.defaultPolicy), id_,
400 url_request.Pass()); 404 url_request.Pass());
401 405
402 // TODO(yzshen): crbug.com/532556 If the server side drops the request, 406 // TODO(yzshen): crbug.com/532556 If the server side drops the request,
403 // this frame will be in permenant-loading state. We should send a 407 // this frame will be in permenant-loading state. We should send a
404 // notification to mark this frame as not loading in that case. We also need 408 // notification to mark this frame as not loading in that case. We also need
405 // to better keep track of multiple pending navigations. 409 // to better keep track of multiple pending navigations.
406 pending_navigation_ = true; 410 pending_navigation_ = true;
407 return blink::WebNavigationPolicyHandledByClient; 411 return blink::WebNavigationPolicyHandledByClient;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 server_->SetClientProperty(kPropertyFrameOrigin, 488 server_->SetClientProperty(kPropertyFrameOrigin,
485 FrameOriginToClientProperty(frame)); 489 FrameOriginToClientProperty(frame));
486 490
487 // TODO(erg): We need to pass way more information from here through to the 491 // TODO(erg): We need to pass way more information from here through to the
488 // other side. See FrameHostMsg_DidCommitProvisionalLoad_Params. It is a grab 492 // other side. See FrameHostMsg_DidCommitProvisionalLoad_Params. It is a grab
489 // bag of everything and it looks like a combination of 493 // bag of everything and it looks like a combination of
490 // NavigatorImpl::DidNavigate and 494 // NavigatorImpl::DidNavigate and
491 // NavigationControllerImpl::RendererDidNavigate use everything passed 495 // NavigationControllerImpl::RendererDidNavigate use everything passed
492 // through. 496 // through.
493 server_->DidCommitProvisionalLoad(); 497 server_->DidCommitProvisionalLoad();
498
499 if (!navigation_start_time_.is_null()) {
500 frame->dataSource()->setNavigationStartTime(
501 navigation_start_time_.ToInternalValue() /
502 static_cast<double>(base::Time::kMicrosecondsPerSecond));
503 navigation_start_time_ = base::TimeTicks();
504 }
494 } 505 }
495 506
496 void HTMLFrame::didReceiveTitle(blink::WebLocalFrame* frame, 507 void HTMLFrame::didReceiveTitle(blink::WebLocalFrame* frame,
497 const blink::WebString& title, 508 const blink::WebString& title,
498 blink::WebTextDirection direction) { 509 blink::WebTextDirection direction) {
499 // TODO(beng): handle |direction|. 510 // TODO(beng): handle |direction|.
500 mojo::String formatted; 511 mojo::String formatted;
501 if (!title.isNull()) { 512 if (!title.isNull()) {
502 formatted = 513 formatted =
503 mojo::String::From(base::string16(title).substr(0, kMaxTitleChars)); 514 mojo::String::From(base::string16(title).substr(0, kMaxTitleChars));
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 void HTMLFrame::OnViewFocusChanged(mus::View* gained_focus, 790 void HTMLFrame::OnViewFocusChanged(mus::View* gained_focus,
780 mus::View* lost_focus) { 791 mus::View* lost_focus) {
781 UpdateFocus(); 792 UpdateFocus();
782 } 793 }
783 794
784 void HTMLFrame::OnConnect(web_view::mojom::FramePtr frame, 795 void HTMLFrame::OnConnect(web_view::mojom::FramePtr frame,
785 uint32_t change_id, 796 uint32_t change_id,
786 uint32_t view_id, 797 uint32_t view_id,
787 web_view::mojom::ViewConnectType view_connect_type, 798 web_view::mojom::ViewConnectType view_connect_type,
788 mojo::Array<web_view::mojom::FrameDataPtr> frame_data, 799 mojo::Array<web_view::mojom::FrameDataPtr> frame_data,
800 int64_t navigation_start_time_ticks,
789 const OnConnectCallback& callback) { 801 const OnConnectCallback& callback) {
790 // This is called if this frame is created by way of OnCreatedFrame(). 802 // This is called if this frame is created by way of OnCreatedFrame().
791 callback.Run(); 803 callback.Run();
792 } 804 }
793 805
794 void HTMLFrame::OnFrameAdded(uint32_t change_id, 806 void HTMLFrame::OnFrameAdded(uint32_t change_id,
795 web_view::mojom::FrameDataPtr frame_data) { 807 web_view::mojom::FrameDataPtr frame_data) {
796 frame_tree_manager_->ProcessOnFrameAdded(this, change_id, frame_data.Pass()); 808 frame_tree_manager_->ProcessOnFrameAdded(this, change_id, frame_data.Pass());
797 } 809 }
798 810
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1013 if (!surface_layer_) 1025 if (!surface_layer_)
1014 return; 1026 return;
1015 1027
1016 surface_layer_->SetSurfaceId( 1028 surface_layer_->SetSurfaceId(
1017 cc::SurfaceId(owned_view_->view()->id()), 1029 cc::SurfaceId(owned_view_->view()->id()),
1018 global_state()->device_pixel_ratio(), 1030 global_state()->device_pixel_ratio(),
1019 owned_view_->view()->bounds().To<gfx::Rect>().size()); 1031 owned_view_->view()->bounds().To<gfx::Rect>().size());
1020 } 1032 }
1021 1033
1022 } // namespace mojo 1034 } // namespace mojo
OLDNEW
« no previous file with comments | « components/html_viewer/html_frame.h ('k') | components/html_viewer/html_frame_apptest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698