Index: content/renderer/gpu/compositor_thread.cc |
diff --git a/content/renderer/gpu/compositor_thread.cc b/content/renderer/gpu/compositor_thread.cc |
index d4c790c297ff3a5973b22bd3abf1c52fa328617b..aa7fec47d393b53fa9c13758441e99e0d29e9da0 100644 |
--- a/content/renderer/gpu/compositor_thread.cc |
+++ b/content/renderer/gpu/compositor_thread.cc |
@@ -6,9 +6,10 @@ |
#include "base/bind.h" |
#include "content/renderer/gpu/input_event_filter.h" |
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositor.h" |
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositorClient.h" |
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebActiveWheelFlingParameters.h" |
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositorInputHandlerClient.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositorInputHandler.h" |
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
using WebKit::WebCompositorInputHandler; |
using WebKit::WebInputEvent; |
@@ -16,17 +17,30 @@ using WebKit::WebInputEvent; |
//------------------------------------------------------------------------------ |
class CompositorThread::InputHandlerWrapper |
- : public WebKit::WebCompositorClient { |
+ : public WebKit::WebCompositorInputHandlerClient, |
+ public base::RefCountedThreadSafe<InputHandlerWrapper> { |
public: |
InputHandlerWrapper(CompositorThread* compositor_thread, |
int routing_id, |
- WebKit::WebCompositorInputHandler* input_handler) |
+ WebKit::WebCompositorInputHandler* input_handler, |
+ scoped_refptr<base::MessageLoopProxy> main_loop, |
+ const base::WeakPtr<RenderViewImpl>& render_view_impl) |
: compositor_thread_(compositor_thread), |
routing_id_(routing_id), |
- input_handler_(input_handler) { |
+ 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)); |
+ } |
+ |
virtual ~InputHandlerWrapper() { |
input_handler_->setClient(NULL); |
} |
@@ -36,7 +50,7 @@ class CompositorThread::InputHandlerWrapper |
return input_handler_; |
} |
- // WebCompositorClient methods: |
+ // WebCompositorInputHandlerClient methods: |
virtual void willShutdown() { |
compositor_thread_->RemoveInputHandler(routing_id_); |
@@ -54,6 +68,10 @@ class CompositorThread::InputHandlerWrapper |
CompositorThread* compositor_thread_; |
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); |
}; |
@@ -76,14 +94,27 @@ IPC::ChannelProxy::MessageFilter* CompositorThread::GetMessageFilter() const { |
return filter_; |
} |
-void CompositorThread::AddInputHandler(int routing_id, int input_handler_id) { |
- if (thread_.message_loop() != MessageLoop::current()) { |
- thread_.message_loop()->PostTask( |
- FROM_HERE, |
- base::Bind(&CompositorThread::AddInputHandler, base::Unretained(this), |
- routing_id, input_handler_id)); |
- return; |
- } |
+void CompositorThread::AddInputHandler( |
+ int routing_id, int input_handler_id, |
+ const base::WeakPtr<RenderViewImpl>& render_view_impl) { |
+ DCHECK_NE(thread_.message_loop(), MessageLoop::current()); |
+ |
+ thread_.message_loop()->PostTask( |
+ FROM_HERE, |
+ base::Bind(&CompositorThread::AddInputHandlerOnCompositorThread, |
+ base::Unretained(this), |
+ routing_id, |
+ input_handler_id, |
+ base::MessageLoopProxy::current(), |
+ render_view_impl)); |
jamesr
2012/03/27 17:38:57
Since you asked for const ref on the WeakPtr I'm a
|
+} |
+ |
+void CompositorThread::AddInputHandlerOnCompositorThread( |
+ int routing_id, int input_handler_id, |
+ scoped_refptr<base::MessageLoopProxy> main_loop, |
+ const base::WeakPtr<RenderViewImpl>& render_view_impl) { |
+ |
+ DCHECK_EQ(thread_.message_loop(), MessageLoop::current()); |
WebCompositorInputHandler* input_handler = |
WebCompositorInputHandler::fromIdentifier(input_handler_id); |
@@ -100,11 +131,12 @@ void CompositorThread::AddInputHandler(int routing_id, int input_handler_id) { |
filter_->AddRoute(routing_id); |
input_handlers_[routing_id] = |
- make_linked_ptr(new InputHandlerWrapper(this, routing_id, input_handler)); |
+ make_scoped_refptr(new InputHandlerWrapper(this, |
+ routing_id, input_handler, main_loop, render_view_impl)); |
} |
void CompositorThread::RemoveInputHandler(int routing_id) { |
- DCHECK(thread_.message_loop() == MessageLoop::current()); |
+ DCHECK_EQ(MessageLoop::current(), thread_.message_loop()); |
filter_->RemoveRoute(routing_id); |
input_handlers_.erase(routing_id); |