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..607308574b9e186bc9fbafa6ef4f5592ed798db1 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,31 @@ 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, |
+ 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(&CompositorThread::InputHandlerWrapper:: |
+ TransferActiveWheelFlingAnimation, |
+ this, params)); |
+ } |
+ |
virtual ~InputHandlerWrapper() { |
input_handler_->setClient(NULL); |
} |
@@ -36,7 +51,7 @@ class CompositorThread::InputHandlerWrapper |
return input_handler_; |
} |
- // WebCompositorClient methods: |
+ // WebCompositorInputHandlerClient methods: |
virtual void willShutdown() { |
compositor_thread_->RemoveInputHandler(routing_id_); |
@@ -51,9 +66,20 @@ class CompositorThread::InputHandlerWrapper |
} |
private: |
+ void TransferActiveWheelFlingAnimation( |
darin (slow to review)
2012/03/27 03:47:54
Another approach would be to define this as a publ
|
+ WebKit::WebActiveWheelFlingParameters params) { |
+ DCHECK(main_loop_->BelongsToCurrentThread()); |
+ if (render_view_impl_.get() && render_view_impl_->webview()) |
+ render_view_impl_->webview()->transferActiveWheelFlingAnimation(params); |
darin (slow to review)
2012/03/27 03:47:54
nit: indentation
|
+ } |
+ |
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 +102,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, |
+ base::WeakPtr<RenderViewImpl> render_view_impl) { |
darin (slow to review)
2012/03/27 03:47:54
nit: pass WeakPtr by const ref
|
+ 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)); |
+} |
+ |
+void CompositorThread::AddInputHandlerOnCompositorThread( |
+ int routing_id, int input_handler_id, |
+ scoped_refptr<base::MessageLoopProxy> main_loop, |
+ base::WeakPtr<RenderViewImpl> render_view_impl) { |
darin (slow to review)
2012/03/27 03:47:54
nit: pass WeakPtr by const ref
|
+ |
+ DCHECK_EQ(thread_.message_loop(), MessageLoop::current()); |
WebCompositorInputHandler* input_handler = |
WebCompositorInputHandler::fromIdentifier(input_handler_id); |
@@ -100,11 +139,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); |