| 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/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 <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 // static | 108 // static |
| 109 size_t RenderWidgetHost::BackingStoreMemorySize() { | 109 size_t RenderWidgetHost::BackingStoreMemorySize() { |
| 110 return BackingStoreManager::MemorySize(); | 110 return BackingStoreManager::MemorySize(); |
| 111 } | 111 } |
| 112 | 112 |
| 113 /////////////////////////////////////////////////////////////////////////////// | 113 /////////////////////////////////////////////////////////////////////////////// |
| 114 // RenderWidgetHostImpl | 114 // RenderWidgetHostImpl |
| 115 | 115 |
| 116 RenderWidgetHostImpl::RenderWidgetHostImpl(RenderWidgetHostDelegate* delegate, | 116 RenderWidgetHostImpl::RenderWidgetHostImpl(RenderWidgetHostDelegate* delegate, |
| 117 RenderProcessHost* process, | 117 RenderProcessHost* process, |
| 118 int routing_id) | 118 int routing_id, |
| 119 bool hidden) |
| 119 : view_(NULL), | 120 : view_(NULL), |
| 120 renderer_initialized_(false), | 121 renderer_initialized_(false), |
| 121 hung_renderer_delay_ms_(kHungRendererDelayMs), | 122 hung_renderer_delay_ms_(kHungRendererDelayMs), |
| 122 delegate_(delegate), | 123 delegate_(delegate), |
| 123 process_(process), | 124 process_(process), |
| 124 routing_id_(routing_id), | 125 routing_id_(routing_id), |
| 125 surface_id_(0), | 126 surface_id_(0), |
| 126 is_loading_(false), | 127 is_loading_(false), |
| 127 is_hidden_(false), | 128 is_hidden_(hidden), |
| 128 is_fullscreen_(false), | 129 is_fullscreen_(false), |
| 129 is_accelerated_compositing_active_(false), | 130 is_accelerated_compositing_active_(false), |
| 130 repaint_ack_pending_(false), | 131 repaint_ack_pending_(false), |
| 131 resize_ack_pending_(false), | 132 resize_ack_pending_(false), |
| 132 overdraw_bottom_height_(0.f), | 133 overdraw_bottom_height_(0.f), |
| 133 should_auto_resize_(false), | 134 should_auto_resize_(false), |
| 134 waiting_for_screen_rects_ack_(false), | 135 waiting_for_screen_rects_ack_(false), |
| 135 accessibility_mode_(AccessibilityModeOff), | 136 accessibility_mode_(AccessibilityModeOff), |
| 136 needs_repainting_on_restore_(false), | 137 needs_repainting_on_restore_(false), |
| 137 is_unresponsive_(false), | 138 is_unresponsive_(false), |
| (...skipping 30 matching lines...) Expand all Loading... |
| 168 process_->GetID(), | 169 process_->GetID(), |
| 169 routing_id_); | 170 routing_id_); |
| 170 DCHECK(surface_id_); | 171 DCHECK(surface_id_); |
| 171 } | 172 } |
| 172 | 173 |
| 173 is_threaded_compositing_enabled_ = IsThreadedCompositingEnabled(); | 174 is_threaded_compositing_enabled_ = IsThreadedCompositingEnabled(); |
| 174 | 175 |
| 175 g_routing_id_widget_map.Get().insert(std::make_pair( | 176 g_routing_id_widget_map.Get().insert(std::make_pair( |
| 176 RenderWidgetHostID(process->GetID(), routing_id_), this)); | 177 RenderWidgetHostID(process->GetID(), routing_id_), this)); |
| 177 process_->AddRoute(routing_id_, this); | 178 process_->AddRoute(routing_id_, this); |
| 178 // Because the widget initializes as is_hidden_ == false, | 179 |
| 179 // tell the process host that we're alive. | 180 // If we're initially visible, tell the process host that we're alive. |
| 180 process_->WidgetRestored(); | 181 // Otherwise we'll notify the process host when we are first shown. |
| 182 if (!hidden) |
| 183 process_->WidgetRestored(); |
| 181 | 184 |
| 182 accessibility_mode_ = | 185 accessibility_mode_ = |
| 183 BrowserAccessibilityStateImpl::GetInstance()->accessibility_mode(); | 186 BrowserAccessibilityStateImpl::GetInstance()->accessibility_mode(); |
| 184 | 187 |
| 185 for (size_t i = 0; i < g_created_callbacks.Get().size(); i++) | 188 for (size_t i = 0; i < g_created_callbacks.Get().size(); i++) |
| 186 g_created_callbacks.Get().at(i).Run(this); | 189 g_created_callbacks.Get().at(i).Run(this); |
| 187 | 190 |
| 188 input_router_.reset(new ImmediateInputRouter(process, this, routing_id_)); | 191 input_router_.reset(new ImmediateInputRouter(process, this, routing_id_)); |
| 189 | 192 |
| 190 #if defined(USE_AURA) | 193 #if defined(USE_AURA) |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 } | 475 } |
| 473 | 476 |
| 474 bool RenderWidgetHostImpl::Send(IPC::Message* msg) { | 477 bool RenderWidgetHostImpl::Send(IPC::Message* msg) { |
| 475 if (IPC_MESSAGE_ID_CLASS(msg->type()) == InputMsgStart) | 478 if (IPC_MESSAGE_ID_CLASS(msg->type()) == InputMsgStart) |
| 476 return input_router_->SendInput(msg); | 479 return input_router_->SendInput(msg); |
| 477 | 480 |
| 478 return process_->Send(msg); | 481 return process_->Send(msg); |
| 479 } | 482 } |
| 480 | 483 |
| 481 void RenderWidgetHostImpl::WasHidden() { | 484 void RenderWidgetHostImpl::WasHidden() { |
| 485 if (is_hidden_) |
| 486 return; |
| 487 |
| 482 is_hidden_ = true; | 488 is_hidden_ = true; |
| 483 | 489 |
| 484 // Don't bother reporting hung state when we aren't active. | 490 // Don't bother reporting hung state when we aren't active. |
| 485 StopHangMonitorTimeout(); | 491 StopHangMonitorTimeout(); |
| 486 | 492 |
| 487 // If we have a renderer, then inform it that we are being hidden so it can | 493 // If we have a renderer, then inform it that we are being hidden so it can |
| 488 // reduce its resource utilization. | 494 // reduce its resource utilization. |
| 489 Send(new ViewMsg_WasHidden(routing_id_)); | 495 Send(new ViewMsg_WasHidden(routing_id_)); |
| 490 | 496 |
| 491 // Tell the RenderProcessHost we were hidden. | 497 // Tell the RenderProcessHost we were hidden. |
| 492 process_->WidgetHidden(); | 498 process_->WidgetHidden(); |
| 493 | 499 |
| 494 bool is_visible = false; | 500 bool is_visible = false; |
| 495 NotificationService::current()->Notify( | 501 NotificationService::current()->Notify( |
| 496 NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED, | 502 NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED, |
| 497 Source<RenderWidgetHost>(this), | 503 Source<RenderWidgetHost>(this), |
| 498 Details<bool>(&is_visible)); | 504 Details<bool>(&is_visible)); |
| 499 } | 505 } |
| 500 | 506 |
| 501 void RenderWidgetHostImpl::WasShown() { | 507 void RenderWidgetHostImpl::WasShown() { |
| 502 // When we create the widget, it is created as *not* hidden. | |
| 503 if (!is_hidden_) | 508 if (!is_hidden_) |
| 504 return; | 509 return; |
| 505 is_hidden_ = false; | 510 is_hidden_ = false; |
| 506 | 511 |
| 507 SendScreenRects(); | 512 SendScreenRects(); |
| 508 | 513 |
| 509 BackingStore* backing_store = BackingStoreManager::Lookup(this); | 514 BackingStore* backing_store = BackingStoreManager::Lookup(this); |
| 510 // If we already have a backing store for this widget, then we don't need to | 515 // If we already have a backing store for this widget, then we don't need to |
| 511 // repaint on restore _unless_ we know that our backing store is invalid. | 516 // repaint on restore _unless_ we know that our backing store is invalid. |
| 512 // When accelerated compositing is on, we must always repaint, even when | 517 // When accelerated compositing is on, we must always repaint, even when |
| (...skipping 1963 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2476 int process_id = (b->first.second >> 32) & 0xffffffff; | 2481 int process_id = (b->first.second >> 32) & 0xffffffff; |
| 2477 RenderWidgetHost* rwh = | 2482 RenderWidgetHost* rwh = |
| 2478 RenderWidgetHost::FromID(process_id, routing_id); | 2483 RenderWidgetHost::FromID(process_id, routing_id); |
| 2479 if (!rwh) | 2484 if (!rwh) |
| 2480 continue; | 2485 continue; |
| 2481 RenderWidgetHostImpl::From(rwh)->FrameSwapped(latency_info); | 2486 RenderWidgetHostImpl::From(rwh)->FrameSwapped(latency_info); |
| 2482 } | 2487 } |
| 2483 } | 2488 } |
| 2484 | 2489 |
| 2485 } // namespace content | 2490 } // namespace content |
| OLD | NEW |