| Index: content/renderer/gpu/input_handler_manager.cc
|
| diff --git a/content/renderer/gpu/input_handler_manager.cc b/content/renderer/gpu/input_handler_manager.cc
|
| index 246c86652401aaf2be01f278dd4a0b804d8a2eb5..ef6bc3f1357113904a54f24e641a48048e0a19ca 100644
|
| --- a/content/renderer/gpu/input_handler_manager.cc
|
| +++ b/content/renderer/gpu/input_handler_manager.cc
|
| @@ -6,87 +6,20 @@
|
|
|
| #include "base/bind.h"
|
| #include "base/debug/trace_event.h"
|
| +#include "cc/input/input_handler.h"
|
| #include "content/renderer/gpu/input_event_filter.h"
|
| +#include "content/renderer/gpu/input_handler_wrapper.h"
|
| #include "third_party/WebKit/Source/WebKit/chromium/public/WebActiveWheelFlingParameters.h"
|
| -#include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositorInputHandler.h"
|
| -#include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositorInputHandlerClient.h"
|
|
|
| #if defined(OS_ANDROID)
|
| // TODO(epenner): Move thread priorities to base. (crbug.com/170549)
|
| #include <sys/resource.h>
|
| #endif
|
|
|
| -using WebKit::WebCompositorInputHandler;
|
| using WebKit::WebInputEvent;
|
|
|
| namespace content {
|
|
|
| -//------------------------------------------------------------------------------
|
| -
|
| -class InputHandlerManager::InputHandlerWrapper
|
| - : public WebKit::WebCompositorInputHandlerClient,
|
| - public base::RefCountedThreadSafe<InputHandlerWrapper> {
|
| - public:
|
| - InputHandlerWrapper(InputHandlerManager* input_handler_manager,
|
| - int routing_id,
|
| - WebKit::WebCompositorInputHandler* input_handler,
|
| - const scoped_refptr<base::MessageLoopProxy>& main_loop,
|
| - const base::WeakPtr<RenderViewImpl>& render_view_impl)
|
| - : input_handler_manager_(input_handler_manager),
|
| - routing_id_(routing_id),
|
| - input_handler_(input_handler),
|
| - main_loop_(main_loop),
|
| - render_view_impl_(render_view_impl) {
|
| - input_handler_->setClient(this);
|
| - }
|
| -
|
| - virtual void transferActiveWheelFlingAnimation(
|
| - const WebKit::WebActiveWheelFlingParameters& params) {
|
| - main_loop_->PostTask(
|
| - FROM_HERE,
|
| - base::Bind(&RenderViewImpl::TransferActiveWheelFlingAnimation,
|
| - render_view_impl_, params));
|
| - }
|
| -
|
| - int routing_id() const { return routing_id_; }
|
| - WebKit::WebCompositorInputHandler* input_handler() const {
|
| - return input_handler_;
|
| - }
|
| -
|
| - // WebCompositorInputHandlerClient methods:
|
| -
|
| - virtual void willShutdown() {
|
| - input_handler_manager_->RemoveInputHandler(routing_id_);
|
| - }
|
| -
|
| - virtual void didHandleInputEvent() {
|
| - input_handler_manager_->filter_->DidHandleInputEvent();
|
| - }
|
| -
|
| - virtual void didNotHandleInputEvent(bool send_to_widget) {
|
| - input_handler_manager_->filter_->DidNotHandleInputEvent(send_to_widget);
|
| - }
|
| -
|
| - private:
|
| - friend class base::RefCountedThreadSafe<InputHandlerWrapper>;
|
| -
|
| - virtual ~InputHandlerWrapper() {
|
| - input_handler_->setClient(NULL);
|
| - }
|
| -
|
| - InputHandlerManager* input_handler_manager_;
|
| - int routing_id_;
|
| - WebKit::WebCompositorInputHandler* input_handler_;
|
| - scoped_refptr<base::MessageLoopProxy> main_loop_;
|
| -
|
| - // Can only be accessed on the main thread.
|
| - base::WeakPtr<RenderViewImpl> render_view_impl_;
|
| -
|
| - DISALLOW_COPY_AND_ASSIGN(InputHandlerWrapper);
|
| -};
|
| -
|
| -//------------------------------------------------------------------------------
|
| -
|
| #if defined(OS_ANDROID)
|
| // TODO(epenner): Move thread priorities to base. (crbug.com/170549)
|
| namespace {
|
| @@ -121,7 +54,8 @@ InputHandlerManager::GetMessageFilter() const {
|
| }
|
|
|
| void InputHandlerManager::AddInputHandler(
|
| - int routing_id, int input_handler_id,
|
| + int routing_id,
|
| + const base::WeakPtr<cc::InputHandler>& input_handler,
|
| const base::WeakPtr<RenderViewImpl>& render_view_impl) {
|
| DCHECK(!message_loop_proxy_->BelongsToCurrentThread());
|
|
|
| @@ -130,35 +64,31 @@ void InputHandlerManager::AddInputHandler(
|
| base::Bind(&InputHandlerManager::AddInputHandlerOnCompositorThread,
|
| base::Unretained(this),
|
| routing_id,
|
| - input_handler_id,
|
| base::MessageLoopProxy::current(),
|
| + input_handler,
|
| render_view_impl));
|
| }
|
|
|
| void InputHandlerManager::AddInputHandlerOnCompositorThread(
|
| - int routing_id, int input_handler_id,
|
| + int routing_id,
|
| const scoped_refptr<base::MessageLoopProxy>& main_loop,
|
| + const base::WeakPtr<cc::InputHandler>& input_handler,
|
| const base::WeakPtr<RenderViewImpl>& render_view_impl) {
|
| DCHECK(message_loop_proxy_->BelongsToCurrentThread());
|
|
|
| - WebCompositorInputHandler* input_handler =
|
| - WebCompositorInputHandler::fromIdentifier(input_handler_id);
|
| + // The handler could be gone by this point if the compositor has shut down.
|
| if (!input_handler)
|
| return;
|
|
|
| - if (input_handlers_.count(routing_id) != 0) {
|
| - // It's valid to call AddInputHandler() for the same routing id with the
|
| - // same input_handler many times, but it's not valid to change the
|
| - // input_handler for a route.
|
| - DCHECK_EQ(input_handlers_[routing_id]->input_handler(), input_handler);
|
| + // The same handler may be registered for a route multiple times.
|
| + if (input_handlers_.count(routing_id) != 0)
|
| return;
|
| - }
|
|
|
| TRACE_EVENT0("InputHandlerManager::AddInputHandler", "AddingRoute");
|
| filter_->AddRoute(routing_id);
|
| input_handlers_[routing_id] =
|
| make_scoped_refptr(new InputHandlerWrapper(this,
|
| - routing_id, input_handler, main_loop, render_view_impl));
|
| + routing_id, main_loop, input_handler, render_view_impl));
|
| }
|
|
|
| void InputHandlerManager::RemoveInputHandler(int routing_id) {
|
| @@ -184,7 +114,7 @@ void InputHandlerManager::HandleInputEvent(
|
| return;
|
| }
|
|
|
| - it->second->input_handler()->handleInputEvent(*input_event);
|
| + it->second->input_handler_proxy()->HandleInputEvent(*input_event);
|
| }
|
|
|
| } // namespace content
|
|
|