Chromium Code Reviews| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 83 | 88 |
| 84 //------------------------------------------------------------------------------ | 89 //------------------------------------------------------------------------------ |
| 85 | 90 |
| 86 CompositorThread::CompositorThread(IPC::Listener* main_listener) | 91 CompositorThread::CompositorThread(IPC::Listener* main_listener) |
| 87 : thread_("Compositor") { | 92 : thread_("Compositor") { |
| 88 filter_ = | 93 filter_ = |
| 89 new InputEventFilter(main_listener, | 94 new InputEventFilter(main_listener, |
| 90 thread_.message_loop()->message_loop_proxy(), | 95 thread_.message_loop()->message_loop_proxy(), |
| 91 base::Bind(&CompositorThread::HandleInputEvent, | 96 base::Bind(&CompositorThread::HandleInputEvent, |
| 92 base::Unretained(this))); | 97 base::Unretained(this))); |
| 98 thread_.message_loop()->PostTask(FROM_HERE, | |
| 99 base::Bind(&CompositorThread::InitOnThread, | |
|
darin (slow to review)
2013/01/23 21:52:43
nit: bind a static function since you don't need a
| |
| 100 // thread_ out-lives 'this' | |
| 101 base::Unretained(this))); | |
| 93 } | 102 } |
| 94 | 103 |
| 95 CompositorThread::~CompositorThread() { | 104 CompositorThread::~CompositorThread() { |
| 96 } | 105 } |
| 97 | 106 |
| 98 IPC::ChannelProxy::MessageFilter* CompositorThread::GetMessageFilter() const { | 107 IPC::ChannelProxy::MessageFilter* CompositorThread::GetMessageFilter() const { |
| 99 return filter_; | 108 return filter_; |
| 100 } | 109 } |
| 101 | 110 |
| 102 void CompositorThread::AddInputHandler( | 111 void CompositorThread::AddInputHandler( |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 159 if (it == input_handlers_.end()) { | 168 if (it == input_handlers_.end()) { |
| 160 TRACE_EVENT0("CompositorThread::HandleInputEvent", "NoInputHandlerFound"); | 169 TRACE_EVENT0("CompositorThread::HandleInputEvent", "NoInputHandlerFound"); |
| 161 // Oops, we no longer have an interested input handler.. | 170 // Oops, we no longer have an interested input handler.. |
| 162 filter_->DidNotHandleInputEvent(true); | 171 filter_->DidNotHandleInputEvent(true); |
| 163 return; | 172 return; |
| 164 } | 173 } |
| 165 | 174 |
| 166 it->second->input_handler()->handleInputEvent(*input_event); | 175 it->second->input_handler()->handleInputEvent(*input_event); |
| 167 } | 176 } |
| 168 | 177 |
| 178 void CompositorThread::InitOnThread() { | |
| 179 #if defined(OS_ANDROID) | |
| 180 // TODO(epenner): Move thread priorities to base. (crbug.com/170549) | |
| 181 int nice_value = -6; // High priority. | |
| 182 setpriority(PRIO_PROCESS, base::PlatformThread::CurrentId(), nice_value); | |
| 183 #endif | |
| 184 } | |
| 185 | |
| 169 } // namespace content | 186 } // namespace content |
| OLD | NEW |