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 3// found in the LICENSE file. 4 5#ifndef CONTENT_RENDERER_GPU_INPUT_HANDLER_MANAGER_H_ 6#define CONTENT_RENDERER_GPU_INPUT_HANDLER_MANAGER_H_ 7 8#include <map> 9 10#include "base/memory/ref_counted.h" 11#include "base/memory/weak_ptr.h" 12#include "content/port/common/input_event_ack_state.h" 13#include "content/renderer/render_view_impl.h" 14 15namespace base { 16class MessageLoopProxy; 17} 18 19namespace cc { 20class InputHandler; 21struct DidOverscrollParams; 22} 23 24namespace WebKit { 25class WebInputEvent; 26} 27 28namespace content { 29 30class InputHandlerWrapper; 31class InputHandlerManagerClient; 32 33// InputHandlerManager class manages InputHandlerProxy instances for 34// the WebViews in this renderer. 35class InputHandlerManager { 36 public: 37 // |message_loop_proxy| is the MessageLoopProxy of the compositor thread. Both 38 // the underlying MessageLoop and supplied |client| must outlive this object. 39 InputHandlerManager( 40 const scoped_refptr<base::MessageLoopProxy>& message_loop_proxy, 41 InputHandlerManagerClient* client); 42 ~InputHandlerManager(); 43 44 // Callable from the main thread only. 45 void AddInputHandler( 46 int routing_id, 47 const base::WeakPtr<cc::InputHandler>& input_handler, 48 const base::WeakPtr<RenderViewImpl>& render_view_impl); 49 50 // Callback only from the compositor's thread. 51 void RemoveInputHandler(int routing_id); 52 53 // Called from the compositor's thread. 54 InputEventAckState HandleInputEvent(int routing_id, 55 const WebKit::WebInputEvent* input_event, 56 const ui::LatencyInfo& latency_info); 57 58 // Called from the compositor's thread. 59 void DidOverscroll(int routing_id, const cc::DidOverscrollParams& params); 60 61 private: 62 // Called from the compositor's thread. 63 void AddInputHandlerOnCompositorThread( 64 int routing_id, 65 const scoped_refptr<base::MessageLoopProxy>& main_loop, 66 const base::WeakPtr<cc::InputHandler>& input_handler, 67 const base::WeakPtr<RenderViewImpl>& render_view_impl); 68 69 typedef std::map<int, // routing_id 70 scoped_refptr<InputHandlerWrapper> > InputHandlerMap; 71 InputHandlerMap input_handlers_; 72 73 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; 74 InputHandlerManagerClient* client_; 75}; 76 77} // namespace content 78 79#endif // CONTENT_RENDERER_GPU_INPUT_HANDLER_MANAGER_H_ 80