| OLD | NEW |
| 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/renderer/render_widget.h" | 5 #include "content/renderer/render_widget.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/macros.h" |
| 11 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/singleton.h" | 13 #include "base/memory/singleton.h" |
| 13 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
| 14 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
| 15 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
| 16 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 17 #include "base/sys_info.h" | 18 #include "base/sys_info.h" |
| 18 #include "base/trace_event/trace_event.h" | 19 #include "base/trace_event/trace_event.h" |
| 19 #include "base/trace_event/trace_event_synthetic_delay.h" | 20 #include "base/trace_event/trace_event_synthetic_delay.h" |
| 20 #include "build/build_config.h" | 21 #include "build/build_config.h" |
| (...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 | 477 |
| 477 RenderWidget::~RenderWidget() { | 478 RenderWidget::~RenderWidget() { |
| 478 DCHECK(!webwidget_) << "Leaking our WebWidget!"; | 479 DCHECK(!webwidget_) << "Leaking our WebWidget!"; |
| 479 | 480 |
| 480 // If we are swapped out, we have released already. | 481 // If we are swapped out, we have released already. |
| 481 if (!is_swapped_out_ && RenderProcess::current()) | 482 if (!is_swapped_out_ && RenderProcess::current()) |
| 482 RenderProcess::current()->ReleaseProcess(); | 483 RenderProcess::current()->ReleaseProcess(); |
| 483 } | 484 } |
| 484 | 485 |
| 485 // static | 486 // static |
| 486 RenderWidget* RenderWidget::Create(int32 opener_id, | 487 RenderWidget* RenderWidget::Create(int32_t opener_id, |
| 487 CompositorDependencies* compositor_deps, | 488 CompositorDependencies* compositor_deps, |
| 488 blink::WebPopupType popup_type, | 489 blink::WebPopupType popup_type, |
| 489 const blink::WebScreenInfo& screen_info) { | 490 const blink::WebScreenInfo& screen_info) { |
| 490 DCHECK(opener_id != MSG_ROUTING_NONE); | 491 DCHECK(opener_id != MSG_ROUTING_NONE); |
| 491 scoped_refptr<RenderWidget> widget(new RenderWidget( | 492 scoped_refptr<RenderWidget> widget(new RenderWidget( |
| 492 compositor_deps, popup_type, screen_info, false, false, false)); | 493 compositor_deps, popup_type, screen_info, false, false, false)); |
| 493 if (widget->Init(opener_id)) { // adds reference on success. | 494 if (widget->Init(opener_id)) { // adds reference on success. |
| 494 return widget.get(); | 495 return widget.get(); |
| 495 } | 496 } |
| 496 return NULL; | 497 return NULL; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 default: | 550 default: |
| 550 NOTREACHED(); | 551 NOTREACHED(); |
| 551 } | 552 } |
| 552 return NULL; | 553 return NULL; |
| 553 } | 554 } |
| 554 | 555 |
| 555 void RenderWidget::CloseForFrame() { | 556 void RenderWidget::CloseForFrame() { |
| 556 OnClose(); | 557 OnClose(); |
| 557 } | 558 } |
| 558 | 559 |
| 559 bool RenderWidget::Init(int32 opener_id) { | 560 bool RenderWidget::Init(int32_t opener_id) { |
| 560 return DoInit( | 561 return DoInit( |
| 561 opener_id, RenderWidget::CreateWebWidget(this), | 562 opener_id, RenderWidget::CreateWebWidget(this), |
| 562 new ViewHostMsg_CreateWidget(opener_id, popup_type_, &routing_id_)); | 563 new ViewHostMsg_CreateWidget(opener_id, popup_type_, &routing_id_)); |
| 563 } | 564 } |
| 564 | 565 |
| 565 bool RenderWidget::DoInit(int32 opener_id, | 566 bool RenderWidget::DoInit(int32_t opener_id, |
| 566 WebWidget* web_widget, | 567 WebWidget* web_widget, |
| 567 IPC::SyncMessage* create_widget_message) { | 568 IPC::SyncMessage* create_widget_message) { |
| 568 DCHECK(!webwidget_); | 569 DCHECK(!webwidget_); |
| 569 | 570 |
| 570 if (opener_id != MSG_ROUTING_NONE) | 571 if (opener_id != MSG_ROUTING_NONE) |
| 571 opener_id_ = opener_id; | 572 opener_id_ = opener_id; |
| 572 | 573 |
| 573 webwidget_ = web_widget; | 574 webwidget_ = web_widget; |
| 574 | 575 |
| 575 bool result = true; | 576 bool result = true; |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 974 } else if (RenderThreadImpl::current()->sync_compositor_message_filter()) { | 975 } else if (RenderThreadImpl::current()->sync_compositor_message_filter()) { |
| 975 return make_scoped_ptr(new SynchronousCompositorOutputSurface( | 976 return make_scoped_ptr(new SynchronousCompositorOutputSurface( |
| 976 context_provider, worker_context_provider, routing_id(), | 977 context_provider, worker_context_provider, routing_id(), |
| 977 content::RenderThreadImpl::current() | 978 content::RenderThreadImpl::current() |
| 978 ->sync_compositor_message_filter(), | 979 ->sync_compositor_message_filter(), |
| 979 frame_swap_message_queue_)); | 980 frame_swap_message_queue_)); |
| 980 } | 981 } |
| 981 #endif | 982 #endif |
| 982 } | 983 } |
| 983 | 984 |
| 984 uint32 output_surface_id = next_output_surface_id_++; | 985 uint32_t output_surface_id = next_output_surface_id_++; |
| 985 // Composite-to-mailbox is currently used for layout tests in order to cause | 986 // Composite-to-mailbox is currently used for layout tests in order to cause |
| 986 // them to draw inside in the renderer to do the readback there. This should | 987 // them to draw inside in the renderer to do the readback there. This should |
| 987 // no longer be the case when crbug.com/311404 is fixed. | 988 // no longer be the case when crbug.com/311404 is fixed. |
| 988 if (!RenderThreadImpl::current() || | 989 if (!RenderThreadImpl::current() || |
| 989 !RenderThreadImpl::current()->layout_test_mode()) { | 990 !RenderThreadImpl::current()->layout_test_mode()) { |
| 990 DCHECK(compositor_deps_->GetCompositorImplThreadTaskRunner()); | 991 DCHECK(compositor_deps_->GetCompositorImplThreadTaskRunner()); |
| 991 return make_scoped_ptr(new DelegatedCompositorOutputSurface( | 992 return make_scoped_ptr(new DelegatedCompositorOutputSurface( |
| 992 routing_id(), output_surface_id, context_provider, | 993 routing_id(), output_surface_id, context_provider, |
| 993 worker_context_provider, frame_swap_message_queue_)); | 994 worker_context_provider, frame_swap_message_queue_)); |
| 994 } | 995 } |
| (...skipping 1163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2158 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { | 2159 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { |
| 2159 video_hole_frames_.AddObserver(frame); | 2160 video_hole_frames_.AddObserver(frame); |
| 2160 } | 2161 } |
| 2161 | 2162 |
| 2162 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { | 2163 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { |
| 2163 video_hole_frames_.RemoveObserver(frame); | 2164 video_hole_frames_.RemoveObserver(frame); |
| 2164 } | 2165 } |
| 2165 #endif // defined(VIDEO_HOLE) | 2166 #endif // defined(VIDEO_HOLE) |
| 2166 | 2167 |
| 2167 } // namespace content | 2168 } // namespace content |
| OLD | NEW |