| OLD | NEW |
| 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/renderer/gpu/compositor_thread.h" | 5 #include "content/renderer/gpu/compositor_thread.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "content/renderer/gpu/input_event_filter.h" | 9 #include "content/renderer/gpu/input_event_filter.h" |
| 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebActiveWheelFlingPa
rameters.h" | 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebActiveWheelFlingPa
rameters.h" |
| 11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositorInputHan
dlerClient.h" | 11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositorInputHan
dlerClient.h" |
| 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositorInputHan
dler.h" | 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositorInputHan
dler.h" |
| 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
| 14 | 14 |
| 15 #if defined(OS_ANDROID) |
| 16 // TODO(epenner): Move thread priorities to base. (crbug.com/170549) |
| 17 #include <sys/resource.h> |
| 18 #endif |
| 19 |
| 15 using WebKit::WebCompositorInputHandler; | 20 using WebKit::WebCompositorInputHandler; |
| 16 using WebKit::WebInputEvent; | 21 using WebKit::WebInputEvent; |
| 17 | 22 |
| 18 namespace content { | 23 namespace content { |
| 19 | 24 |
| 20 //------------------------------------------------------------------------------ | 25 //------------------------------------------------------------------------------ |
| 21 | 26 |
| 22 class CompositorThread::InputHandlerWrapper | 27 class CompositorThread::InputHandlerWrapper |
| 23 : public WebKit::WebCompositorInputHandlerClient, | 28 : public WebKit::WebCompositorInputHandlerClient, |
| 24 public base::RefCountedThreadSafe<InputHandlerWrapper> { | 29 public base::RefCountedThreadSafe<InputHandlerWrapper> { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 scoped_refptr<base::MessageLoopProxy> main_loop_; | 81 scoped_refptr<base::MessageLoopProxy> main_loop_; |
| 77 | 82 |
| 78 // Can only be accessed on the main thread. | 83 // Can only be accessed on the main thread. |
| 79 base::WeakPtr<RenderViewImpl> render_view_impl_; | 84 base::WeakPtr<RenderViewImpl> render_view_impl_; |
| 80 | 85 |
| 81 DISALLOW_COPY_AND_ASSIGN(InputHandlerWrapper); | 86 DISALLOW_COPY_AND_ASSIGN(InputHandlerWrapper); |
| 82 }; | 87 }; |
| 83 | 88 |
| 84 //------------------------------------------------------------------------------ | 89 //------------------------------------------------------------------------------ |
| 85 | 90 |
| 91 #if defined(OS_ANDROID) |
| 92 // TODO(epenner): Move thread priorities to base. (crbug.com/170549) |
| 93 namespace { |
| 94 void SetHighThreadPriority() { |
| 95 int nice_value = -6; // High priority. |
| 96 setpriority(PRIO_PROCESS, base::PlatformThread::CurrentId(), nice_value); |
| 97 } |
| 98 } |
| 99 #endif |
| 100 |
| 86 CompositorThread::CompositorThread(IPC::Listener* main_listener) | 101 CompositorThread::CompositorThread(IPC::Listener* main_listener) |
| 87 : thread_("Compositor") { | 102 : thread_("Compositor") { |
| 88 filter_ = | 103 filter_ = |
| 89 new InputEventFilter(main_listener, | 104 new InputEventFilter(main_listener, |
| 90 thread_.message_loop()->message_loop_proxy(), | 105 thread_.message_loop()->message_loop_proxy(), |
| 91 base::Bind(&CompositorThread::HandleInputEvent, | 106 base::Bind(&CompositorThread::HandleInputEvent, |
| 92 base::Unretained(this))); | 107 base::Unretained(this))); |
| 108 #if defined(OS_ANDROID) |
| 109 // TODO(epenner): Move thread priorities to base. (crbug.com/170549) |
| 110 thread_.message_loop()->PostTask(FROM_HERE, |
| 111 base::Bind(&SetHighThreadPriority)); |
| 112 #endif |
| 93 } | 113 } |
| 94 | 114 |
| 95 CompositorThread::~CompositorThread() { | 115 CompositorThread::~CompositorThread() { |
| 96 } | 116 } |
| 97 | 117 |
| 98 IPC::ChannelProxy::MessageFilter* CompositorThread::GetMessageFilter() const { | 118 IPC::ChannelProxy::MessageFilter* CompositorThread::GetMessageFilter() const { |
| 99 return filter_; | 119 return filter_; |
| 100 } | 120 } |
| 101 | 121 |
| 102 void CompositorThread::AddInputHandler( | 122 void CompositorThread::AddInputHandler( |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 TRACE_EVENT0("CompositorThread::HandleInputEvent", "NoInputHandlerFound"); | 180 TRACE_EVENT0("CompositorThread::HandleInputEvent", "NoInputHandlerFound"); |
| 161 // Oops, we no longer have an interested input handler.. | 181 // Oops, we no longer have an interested input handler.. |
| 162 filter_->DidNotHandleInputEvent(true); | 182 filter_->DidNotHandleInputEvent(true); |
| 163 return; | 183 return; |
| 164 } | 184 } |
| 165 | 185 |
| 166 it->second->input_handler()->handleInputEvent(*input_event); | 186 it->second->input_handler()->handleInputEvent(*input_event); |
| 167 } | 187 } |
| 168 | 188 |
| 169 } // namespace content | 189 } // namespace content |
| OLD | NEW |