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

Side by Side Diff: content/browser/renderer_host/render_widget_host_impl.cc

Issue 140663003: Removed requirement for the renderer to know it's process ID (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressing feedback from jbauman@ Created 6 years, 11 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/renderer_host/render_widget_host_impl.h" 5 #include "content/browser/renderer_host/render_widget_host_impl.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 1480 matching lines...) Expand 10 before | Expand all | Expand 10 after
1491 ack_params); 1491 ack_params);
1492 return; 1492 return;
1493 } 1493 }
1494 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params gpu_params; 1494 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params gpu_params;
1495 gpu_params.surface_id = params.surface_id; 1495 gpu_params.surface_id = params.surface_id;
1496 gpu_params.surface_handle = params.surface_handle; 1496 gpu_params.surface_handle = params.surface_handle;
1497 gpu_params.route_id = params.route_id; 1497 gpu_params.route_id = params.route_id;
1498 gpu_params.size = params.size; 1498 gpu_params.size = params.size;
1499 gpu_params.scale_factor = params.scale_factor; 1499 gpu_params.scale_factor = params.scale_factor;
1500 gpu_params.latency_info = params.latency_info; 1500 gpu_params.latency_info = params.latency_info;
1501 FixMissingLatencyInfoComponentIds(gpu_params.latency_info);
1501 view_->AcceleratedSurfaceBuffersSwapped(gpu_params, 1502 view_->AcceleratedSurfaceBuffersSwapped(gpu_params,
1502 params.gpu_process_host_id); 1503 params.gpu_process_host_id);
1503 view_->DidReceiveRendererFrame(); 1504 view_->DidReceiveRendererFrame();
1504 } 1505 }
1505 #endif // OS_MACOSX 1506 #endif // OS_MACOSX
1506 1507
1507 bool RenderWidgetHostImpl::OnSwapCompositorFrame( 1508 bool RenderWidgetHostImpl::OnSwapCompositorFrame(
1508 const IPC::Message& message) { 1509 const IPC::Message& message) {
1509 ViewHostMsg_SwapCompositorFrame::Param param; 1510 ViewHostMsg_SwapCompositorFrame::Param param;
1510 if (!ViewHostMsg_SwapCompositorFrame::Read(&message, &param)) 1511 if (!ViewHostMsg_SwapCompositorFrame::Read(&message, &param))
1511 return false; 1512 return false;
1512 scoped_ptr<cc::CompositorFrame> frame(new cc::CompositorFrame); 1513 scoped_ptr<cc::CompositorFrame> frame(new cc::CompositorFrame);
1513 uint32 output_surface_id = param.a; 1514 uint32 output_surface_id = param.a;
1514 param.b.AssignTo(frame.get()); 1515 param.b.AssignTo(frame.get());
1515 1516
1517 for (size_t i = 0; i < frame->metadata.latency_info.size(); i++)
1518 FixMissingLatencyInfoComponentIds(frame->metadata.latency_info[i]);
1519
1516 input_router_->OnViewUpdated( 1520 input_router_->OnViewUpdated(
1517 GetInputRouterViewFlagsFromCompositorFrameMetadata(frame->metadata)); 1521 GetInputRouterViewFlagsFromCompositorFrameMetadata(frame->metadata));
1518 1522
1519 if (view_) { 1523 if (view_) {
1520 view_->OnSwapCompositorFrame(output_surface_id, frame.Pass()); 1524 view_->OnSwapCompositorFrame(output_surface_id, frame.Pass());
1521 view_->DidReceiveRendererFrame(); 1525 view_->DidReceiveRendererFrame();
1522 } else { 1526 } else {
1523 cc::CompositorFrameAck ack; 1527 cc::CompositorFrameAck ack;
1524 if (frame->gl_frame_data) { 1528 if (frame->gl_frame_data) {
1525 ack.gl_frame_data = frame->gl_frame_data.Pass(); 1529 ack.gl_frame_data = frame->gl_frame_data.Pass();
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
1670 NotificationService::NoDetails()); 1674 NotificationService::NoDetails());
1671 1675
1672 // We don't need to update the view if the view is hidden. We must do this 1676 // We don't need to update the view if the view is hidden. We must do this
1673 // early return after the ACK is sent, however, or the renderer will not send 1677 // early return after the ACK is sent, however, or the renderer will not send
1674 // us more data. 1678 // us more data.
1675 if (is_hidden_) 1679 if (is_hidden_)
1676 return; 1680 return;
1677 1681
1678 // Now paint the view. Watch out: it might be destroyed already. 1682 // Now paint the view. Watch out: it might be destroyed already.
1679 if (view_ && !is_accelerated_compositing_active_) { 1683 if (view_ && !is_accelerated_compositing_active_) {
1684
1685 std::vector<ui::LatencyInfo> latency_info;
1686 for (size_t i = 0; i < params.latency_info.size(); i++) {
1687 ui::LatencyInfo info = params.latency_info[i];
1688 FixMissingLatencyInfoComponentIds(info);
1689 latency_info.push_back(info);
1690 }
1691
1680 view_being_painted_ = true; 1692 view_being_painted_ = true;
1681 view_->DidUpdateBackingStore(params.scroll_rect, params.scroll_delta, 1693 view_->DidUpdateBackingStore(params.scroll_rect, params.scroll_delta,
1682 params.copy_rects, params.latency_info); 1694 params.copy_rects, latency_info);
1683 view_->DidReceiveRendererFrame(); 1695 view_->DidReceiveRendererFrame();
1684 view_being_painted_ = false; 1696 view_being_painted_ = false;
1685 } 1697 }
1686 1698
1687 // If we got a resize ack, then perhaps we have another resize to send? 1699 // If we got a resize ack, then perhaps we have another resize to send?
1688 bool is_resize_ack = 1700 bool is_resize_ack =
1689 ViewHostMsg_UpdateRect_Flags::is_resize_ack(params.flags); 1701 ViewHostMsg_UpdateRect_Flags::is_resize_ack(params.flags);
1690 if (is_resize_ack) 1702 if (is_resize_ack)
1691 WasResized(); 1703 WasResized();
1692 1704
(...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after
2505 continue; 2517 continue;
2506 } 2518 }
2507 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(rwh); 2519 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(rwh);
2508 if (rwhi_set.insert(rwhi).second) 2520 if (rwhi_set.insert(rwhi).second)
2509 rwhi->FrameSwapped(latency_info[i]); 2521 rwhi->FrameSwapped(latency_info[i]);
2510 } 2522 }
2511 } 2523 }
2512 } 2524 }
2513 } 2525 }
2514 2526
2527 void RenderWidgetHostImpl::FixMissingLatencyInfoComponentIds(
2528 ui::LatencyInfo& latency_info) {
2529 ui::LatencyInfo::LatencyMap::iterator lc =
2530 latency_info.latency_components.begin();
2531 while (lc != latency_info.latency_components.end()) {
2532 ui::LatencyComponentType component_type = lc->first.first;
2533 if (component_type == ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT) {
2534 // If the component's ID is 0, patch it with the correct value.
2535 if (lc->first.second == 0) {
jam 2014/01/17 01:27:27 i think we should always set it if it's coming fro
2536 // Generate a new component entry
2537 ui::LatencyInfo::LatencyMap::key_type key =
2538 std::make_pair(component_type, GetLatencyComponentId());
2539 latency_info.latency_components[key] = lc->second;
2540
2541 // Remove the old entry
2542 latency_info.latency_components.erase(lc++);
2543 continue;
2544 }
2545 }
2546 ++lc;
2547 }
2548 }
2549
2515 } // namespace content 2550 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698