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

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

Issue 20356003: Provided batched input delivery with a BufferedInputRouter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Proper interface export, enum for unexpected ack callback Created 7 years, 3 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
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 <utility> 8 #include <utility>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 11 matching lines...) Expand all
22 #include "cc/output/compositor_frame.h" 22 #include "cc/output/compositor_frame.h"
23 #include "cc/output/compositor_frame_ack.h" 23 #include "cc/output/compositor_frame_ack.h"
24 #include "content/browser/accessibility/browser_accessibility_state_impl.h" 24 #include "content/browser/accessibility/browser_accessibility_state_impl.h"
25 #include "content/browser/gpu/compositor_util.h" 25 #include "content/browser/gpu/compositor_util.h"
26 #include "content/browser/gpu/gpu_process_host.h" 26 #include "content/browser/gpu/gpu_process_host.h"
27 #include "content/browser/gpu/gpu_process_host_ui_shim.h" 27 #include "content/browser/gpu/gpu_process_host_ui_shim.h"
28 #include "content/browser/gpu/gpu_surface_tracker.h" 28 #include "content/browser/gpu/gpu_surface_tracker.h"
29 #include "content/browser/renderer_host/backing_store.h" 29 #include "content/browser/renderer_host/backing_store.h"
30 #include "content/browser/renderer_host/backing_store_manager.h" 30 #include "content/browser/renderer_host/backing_store_manager.h"
31 #include "content/browser/renderer_host/dip_util.h" 31 #include "content/browser/renderer_host/dip_util.h"
32 #include "content/browser/renderer_host/input/buffered_input_router.h"
32 #include "content/browser/renderer_host/input/immediate_input_router.h" 33 #include "content/browser/renderer_host/input/immediate_input_router.h"
33 #include "content/browser/renderer_host/overscroll_controller.h" 34 #include "content/browser/renderer_host/overscroll_controller.h"
34 #include "content/browser/renderer_host/render_process_host_impl.h" 35 #include "content/browser/renderer_host/render_process_host_impl.h"
35 #include "content/browser/renderer_host/render_view_host_impl.h" 36 #include "content/browser/renderer_host/render_view_host_impl.h"
36 #include "content/browser/renderer_host/render_widget_helper.h" 37 #include "content/browser/renderer_host/render_widget_helper.h"
37 #include "content/browser/renderer_host/render_widget_host_delegate.h" 38 #include "content/browser/renderer_host/render_widget_host_delegate.h"
38 #include "content/common/accessibility_messages.h" 39 #include "content/common/accessibility_messages.h"
39 #include "content/common/content_constants_internal.h" 40 #include "content/common/content_constants_internal.h"
40 #include "content/common/gpu/gpu_messages.h" 41 #include "content/common/gpu/gpu_messages.h"
41 #include "content/common/input_messages.h" 42 #include "content/common/input_messages.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 // Otherwise we'll notify the process host when we are first shown. 183 // Otherwise we'll notify the process host when we are first shown.
183 if (!hidden) 184 if (!hidden)
184 process_->WidgetRestored(); 185 process_->WidgetRestored();
185 186
186 accessibility_mode_ = 187 accessibility_mode_ =
187 BrowserAccessibilityStateImpl::GetInstance()->accessibility_mode(); 188 BrowserAccessibilityStateImpl::GetInstance()->accessibility_mode();
188 189
189 for (size_t i = 0; i < g_created_callbacks.Get().size(); i++) 190 for (size_t i = 0; i < g_created_callbacks.Get().size(); i++)
190 g_created_callbacks.Get().at(i).Run(this); 191 g_created_callbacks.Get().at(i).Run(this);
191 192
192 input_router_.reset(new ImmediateInputRouter(process, this, routing_id_)); 193 input_router_.reset(
194 new ImmediateInputRouter(process_, this, this, routing_id_));
193 195
194 #if defined(USE_AURA) 196 #if defined(USE_AURA)
195 bool overscroll_enabled = CommandLine::ForCurrentProcess()-> 197 bool overscroll_enabled = CommandLine::ForCurrentProcess()->
196 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation) != "0"; 198 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation) != "0";
197 SetOverscrollControllerEnabled(overscroll_enabled); 199 SetOverscrollControllerEnabled(overscroll_enabled);
198 #endif 200 #endif
199 } 201 }
200 202
201 RenderWidgetHostImpl::~RenderWidgetHostImpl() { 203 RenderWidgetHostImpl::~RenderWidgetHostImpl() {
202 SetView(NULL); 204 SetView(NULL);
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 if (!msg_is_ok) { 473 if (!msg_is_ok) {
472 // The message de-serialization failed. Kill the renderer process. 474 // The message de-serialization failed. Kill the renderer process.
473 RecordAction(UserMetricsAction("BadMessageTerminate_RWH")); 475 RecordAction(UserMetricsAction("BadMessageTerminate_RWH"));
474 GetProcess()->ReceivedBadMessage(); 476 GetProcess()->ReceivedBadMessage();
475 } 477 }
476 return handled; 478 return handled;
477 } 479 }
478 480
479 bool RenderWidgetHostImpl::Send(IPC::Message* msg) { 481 bool RenderWidgetHostImpl::Send(IPC::Message* msg) {
480 if (IPC_MESSAGE_ID_CLASS(msg->type()) == InputMsgStart) 482 if (IPC_MESSAGE_ID_CLASS(msg->type()) == InputMsgStart)
481 return input_router_->SendInput(msg); 483 return input_router_->SendInput(make_scoped_ptr(msg));
482 484
483 return process_->Send(msg); 485 return process_->Send(msg);
484 } 486 }
485 487
486 void RenderWidgetHostImpl::WasHidden() { 488 void RenderWidgetHostImpl::WasHidden() {
487 if (is_hidden_) 489 if (is_hidden_)
488 return; 490 return;
489 491
490 is_hidden_ = true; 492 is_hidden_ = true;
491 493
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after
1228 1230
1229 void RenderWidgetHostImpl::RendererExited(base::TerminationStatus status, 1231 void RenderWidgetHostImpl::RendererExited(base::TerminationStatus status,
1230 int exit_code) { 1232 int exit_code) {
1231 // Clearing this flag causes us to re-create the renderer when recovering 1233 // Clearing this flag causes us to re-create the renderer when recovering
1232 // from a crashed renderer. 1234 // from a crashed renderer.
1233 renderer_initialized_ = false; 1235 renderer_initialized_ = false;
1234 1236
1235 waiting_for_screen_rects_ack_ = false; 1237 waiting_for_screen_rects_ack_ = false;
1236 1238
1237 // Reset to ensure that input routing works with a new renderer. 1239 // Reset to ensure that input routing works with a new renderer.
1238 input_router_.reset(new ImmediateInputRouter(process_, this, routing_id_)); 1240 input_router_.reset(
1241 new ImmediateInputRouter(process_, this, this, routing_id_));
1239 1242
1240 if (overscroll_controller_) 1243 if (overscroll_controller_)
1241 overscroll_controller_->Reset(); 1244 overscroll_controller_->Reset();
1242 1245
1243 // Must reset these to ensure that keyboard events work with a new renderer. 1246 // Must reset these to ensure that keyboard events work with a new renderer.
1244 suppress_next_char_events_ = false; 1247 suppress_next_char_events_ = false;
1245 1248
1246 // Reset some fields in preparation for recovering from a crash. 1249 // Reset some fields in preparation for recovering from a crash.
1247 ResetSizeAndRepaintPendingFlags(); 1250 ResetSizeAndRepaintPendingFlags();
1248 current_size_.SetSize(0, 0); 1251 current_size_.SetSize(0, 0);
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after
2095 } 2098 }
2096 2099
2097 bool RenderWidgetHostImpl::OnSendGestureEventImmediately( 2100 bool RenderWidgetHostImpl::OnSendGestureEventImmediately(
2098 const GestureEventWithLatencyInfo& gesture_event) { 2101 const GestureEventWithLatencyInfo& gesture_event) {
2099 TRACE_EVENT_INSTANT0("input", 2102 TRACE_EVENT_INSTANT0("input",
2100 "RenderWidgetHostImpl::OnSendGestureEventImmediately", 2103 "RenderWidgetHostImpl::OnSendGestureEventImmediately",
2101 TRACE_EVENT_SCOPE_THREAD); 2104 TRACE_EVENT_SCOPE_THREAD);
2102 return !IgnoreInputEvents(); 2105 return !IgnoreInputEvents();
2103 } 2106 }
2104 2107
2108 void RenderWidgetHostImpl::SetNeedsFlush() {
2109 }
2110
2111 void RenderWidgetHostImpl::DidFlush() {
2112 }
2113
2105 void RenderWidgetHostImpl::OnKeyboardEventAck( 2114 void RenderWidgetHostImpl::OnKeyboardEventAck(
2106 const NativeWebKeyboardEvent& event, 2115 const NativeWebKeyboardEvent& event,
2107 InputEventAckState ack_result) { 2116 InputEventAckState ack_result) {
2108 #if defined(OS_MACOSX) 2117 #if defined(OS_MACOSX)
2109 if (!is_hidden() && view_ && view_->PostProcessEventForPluginIme(event)) 2118 if (!is_hidden() && view_ && view_->PostProcessEventForPluginIme(event))
2110 return; 2119 return;
2111 #endif 2120 #endif
2112 2121
2113 // We only send unprocessed key event upwards if we are not hidden, 2122 // We only send unprocessed key event upwards if we are not hidden,
2114 // because the user has moved away from us and no longer expect any effect 2123 // because the user has moved away from us and no longer expect any effect
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2146 } 2155 }
2147 2156
2148 void RenderWidgetHostImpl::OnTouchEventAck( 2157 void RenderWidgetHostImpl::OnTouchEventAck(
2149 const TouchEventWithLatencyInfo& event, 2158 const TouchEventWithLatencyInfo& event,
2150 InputEventAckState ack_result) { 2159 InputEventAckState ack_result) {
2151 ComputeTouchLatency(event.latency); 2160 ComputeTouchLatency(event.latency);
2152 if (view_) 2161 if (view_)
2153 view_->ProcessAckedTouchEvent(event, ack_result); 2162 view_->ProcessAckedTouchEvent(event, ack_result);
2154 } 2163 }
2155 2164
2156 void RenderWidgetHostImpl::OnUnexpectedEventAck(bool bad_message) { 2165 void RenderWidgetHostImpl::OnUnexpectedEventAck(UnexpectedEventAckType type) {
2157 if (bad_message) { 2166 if (type == BAD_ACK_MESSAGE) {
2158 RecordAction(UserMetricsAction("BadMessageTerminate_RWH2")); 2167 RecordAction(UserMetricsAction("BadMessageTerminate_RWH2"));
2159 process_->ReceivedBadMessage(); 2168 process_->ReceivedBadMessage();
2169 } else if (type == UNEXPECTED_EVENT_TYPE) {
2170 suppress_next_char_events_ = false;
2160 } 2171 }
2161
2162 suppress_next_char_events_ = false;
2163 } 2172 }
2164 2173
2165 const gfx::Vector2d& RenderWidgetHostImpl::GetLastScrollOffset() const { 2174 const gfx::Vector2d& RenderWidgetHostImpl::GetLastScrollOffset() const {
2166 return last_scroll_offset_; 2175 return last_scroll_offset_;
2167 } 2176 }
2168 2177
2169 bool RenderWidgetHostImpl::IgnoreInputEvents() const { 2178 bool RenderWidgetHostImpl::IgnoreInputEvents() const {
2170 return ignore_input_events_ || process_->IgnoreInputEvents(); 2179 return ignore_input_events_ || process_->IgnoreInputEvents();
2171 } 2180 }
2172 2181
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
2511 int process_id = (b->first.second >> 32) & 0xffffffff; 2520 int process_id = (b->first.second >> 32) & 0xffffffff;
2512 RenderWidgetHost* rwh = 2521 RenderWidgetHost* rwh =
2513 RenderWidgetHost::FromID(process_id, routing_id); 2522 RenderWidgetHost::FromID(process_id, routing_id);
2514 if (!rwh) 2523 if (!rwh)
2515 continue; 2524 continue;
2516 RenderWidgetHostImpl::From(rwh)->FrameSwapped(latency_info); 2525 RenderWidgetHostImpl::From(rwh)->FrameSwapped(latency_info);
2517 } 2526 }
2518 } 2527 }
2519 2528
2520 } // namespace content 2529 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_impl.h ('k') | content/browser/renderer_host/render_widget_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698