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 21 matching lines...) Expand all Loading... |
32 #include "content/browser/renderer_host/render_process_host_impl.h" | 32 #include "content/browser/renderer_host/render_process_host_impl.h" |
33 #include "content/browser/renderer_host/render_view_host_impl.h" | 33 #include "content/browser/renderer_host/render_view_host_impl.h" |
34 #include "content/browser/renderer_host/render_widget_helper.h" | 34 #include "content/browser/renderer_host/render_widget_helper.h" |
35 #include "content/browser/renderer_host/render_widget_host_delegate.h" | 35 #include "content/browser/renderer_host/render_widget_host_delegate.h" |
36 #include "content/browser/renderer_host/touch_event_queue.h" | 36 #include "content/browser/renderer_host/touch_event_queue.h" |
37 #include "content/browser/renderer_host/touchpad_tap_suppression_controller.h" | 37 #include "content/browser/renderer_host/touchpad_tap_suppression_controller.h" |
38 #include "content/common/accessibility_messages.h" | 38 #include "content/common/accessibility_messages.h" |
39 #include "content/common/content_constants_internal.h" | 39 #include "content/common/content_constants_internal.h" |
40 #include "content/common/gpu/gpu_messages.h" | 40 #include "content/common/gpu/gpu_messages.h" |
41 #include "content/common/input_messages.h" | 41 #include "content/common/input_messages.h" |
| 42 #include "content/common/memory_pressure_messages.h" |
42 #include "content/common/view_messages.h" | 43 #include "content/common/view_messages.h" |
43 #include "content/port/browser/render_widget_host_view_port.h" | 44 #include "content/port/browser/render_widget_host_view_port.h" |
44 #include "content/public/browser/compositor_util.h" | 45 #include "content/public/browser/compositor_util.h" |
45 #include "content/public/browser/native_web_keyboard_event.h" | 46 #include "content/public/browser/native_web_keyboard_event.h" |
46 #include "content/public/browser/notification_service.h" | 47 #include "content/public/browser/notification_service.h" |
47 #include "content/public/browser/notification_types.h" | 48 #include "content/public/browser/notification_types.h" |
48 #include "content/public/browser/user_metrics.h" | 49 #include "content/public/browser/user_metrics.h" |
49 #include "content/public/common/content_constants.h" | 50 #include "content/public/common/content_constants.h" |
50 #include "content/public/common/content_switches.h" | 51 #include "content/public/common/content_switches.h" |
51 #include "content/public/common/result_codes.h" | 52 #include "content/public/common/result_codes.h" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 text_direction_updated_(false), | 167 text_direction_updated_(false), |
167 text_direction_(WebKit::WebTextDirectionLeftToRight), | 168 text_direction_(WebKit::WebTextDirectionLeftToRight), |
168 text_direction_canceled_(false), | 169 text_direction_canceled_(false), |
169 suppress_next_char_events_(false), | 170 suppress_next_char_events_(false), |
170 pending_mouse_lock_request_(false), | 171 pending_mouse_lock_request_(false), |
171 allow_privileged_mouse_lock_(false), | 172 allow_privileged_mouse_lock_(false), |
172 has_touch_handler_(false), | 173 has_touch_handler_(false), |
173 weak_factory_(this), | 174 weak_factory_(this), |
174 touch_event_queue_(new TouchEventQueue(this)), | 175 touch_event_queue_(new TouchEventQueue(this)), |
175 gesture_event_filter_(new GestureEventFilter(this)), | 176 gesture_event_filter_(new GestureEventFilter(this)), |
176 last_input_number_(0) { | 177 last_input_number_(0), |
| 178 memory_pressure_listener_(base::Bind( |
| 179 &RenderWidgetHostImpl::SendMemoryPressureSignal, |
| 180 base::Unretained(this))) { |
177 CHECK(delegate_); | 181 CHECK(delegate_); |
178 if (routing_id_ == MSG_ROUTING_NONE) { | 182 if (routing_id_ == MSG_ROUTING_NONE) { |
179 routing_id_ = process_->GetNextRoutingID(); | 183 routing_id_ = process_->GetNextRoutingID(); |
180 surface_id_ = GpuSurfaceTracker::Get()->AddSurfaceForRenderer( | 184 surface_id_ = GpuSurfaceTracker::Get()->AddSurfaceForRenderer( |
181 process_->GetID(), | 185 process_->GetID(), |
182 routing_id_); | 186 routing_id_); |
183 } else { | 187 } else { |
184 // TODO(piman): This is a O(N) lookup, where we could forward the | 188 // TODO(piman): This is a O(N) lookup, where we could forward the |
185 // information from the RenderWidgetHelper. The problem is that doing so | 189 // information from the RenderWidgetHelper. The problem is that doing so |
186 // currently leaks outside of content all the way to chrome classes, and | 190 // currently leaks outside of content all the way to chrome classes, and |
(...skipping 2327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2514 // Clear the new_auto_size_ since the empty value is used as a flag to | 2518 // Clear the new_auto_size_ since the empty value is used as a flag to |
2515 // indicate that no callback is in progress (i.e. without this line | 2519 // indicate that no callback is in progress (i.e. without this line |
2516 // DelayedAutoResized will not get called again). | 2520 // DelayedAutoResized will not get called again). |
2517 new_auto_size_.SetSize(0, 0); | 2521 new_auto_size_.SetSize(0, 0); |
2518 if (!should_auto_resize_) | 2522 if (!should_auto_resize_) |
2519 return; | 2523 return; |
2520 | 2524 |
2521 OnRenderAutoResized(new_size); | 2525 OnRenderAutoResized(new_size); |
2522 } | 2526 } |
2523 | 2527 |
| 2528 void RenderWidgetHostImpl::SendMemoryPressureSignal( |
| 2529 base::MemoryPressureListener::MemoryPressureLevel level) { |
| 2530 Send(new MemoryPressureMsg_MemoryPressure(level)); |
| 2531 } |
| 2532 |
2524 void RenderWidgetHostImpl::DetachDelegate() { | 2533 void RenderWidgetHostImpl::DetachDelegate() { |
2525 delegate_ = NULL; | 2534 delegate_ = NULL; |
2526 } | 2535 } |
2527 | 2536 |
2528 void RenderWidgetHostImpl::FrameSwapped(const ui::LatencyInfo& latency_info) { | 2537 void RenderWidgetHostImpl::FrameSwapped(const ui::LatencyInfo& latency_info) { |
2529 ui::LatencyInfo::LatencyMap::const_iterator l = | 2538 ui::LatencyInfo::LatencyMap::const_iterator l = |
2530 latency_info.latency_components.find(std::make_pair( | 2539 latency_info.latency_components.find(std::make_pair( |
2531 ui::INPUT_EVENT_LATENCY_RWH_COMPONENT, GetLatencyComponentId())); | 2540 ui::INPUT_EVENT_LATENCY_RWH_COMPONENT, GetLatencyComponentId())); |
2532 if (l == latency_info.latency_components.end()) | 2541 if (l == latency_info.latency_components.end()) |
2533 return; | 2542 return; |
(...skipping 24 matching lines...) Expand all Loading... |
2558 if (!host) | 2567 if (!host) |
2559 continue; | 2568 continue; |
2560 RenderWidgetHost* rwh = host->GetRenderWidgetHostByID(routing_id); | 2569 RenderWidgetHost* rwh = host->GetRenderWidgetHostByID(routing_id); |
2561 if (!rwh) | 2570 if (!rwh) |
2562 continue; | 2571 continue; |
2563 RenderWidgetHostImpl::From(rwh)->FrameSwapped(latency_info); | 2572 RenderWidgetHostImpl::From(rwh)->FrameSwapped(latency_info); |
2564 } | 2573 } |
2565 } | 2574 } |
2566 | 2575 |
2567 } // namespace content | 2576 } // namespace content |
OLD | NEW |