diff options
-rw-r--r-- | chrome/browser/ui/views/autofill/autofill_popup_base_view_browsertest.cc | 3 | ||||
-rw-r--r-- | content/browser/renderer_host/input/input_router_impl.cc | 2 | ||||
-rw-r--r-- | content/renderer/render_widget.cc | 9 | ||||
-rw-r--r-- | content/renderer/render_widget.h | 2 | ||||
-rw-r--r-- | ipc/ipc_message_utils.h | 36 | ||||
-rw-r--r-- | ui/aura/window_event_dispatcher_unittest.cc | 25 | ||||
-rw-r--r-- | ui/events/latency_info.cc | 2 | ||||
-rw-r--r-- | ui/events/latency_info.h | 10 |
8 files changed, 70 insertions, 19 deletions
diff --git a/chrome/browser/ui/views/autofill/autofill_popup_base_view_browsertest.cc b/chrome/browser/ui/views/autofill/autofill_popup_base_view_browsertest.cc index 2283233..d15571b 100644 --- a/chrome/browser/ui/views/autofill/autofill_popup_base_view_browsertest.cc +++ b/chrome/browser/ui/views/autofill/autofill_popup_base_view_browsertest.cc @@ -28,7 +28,8 @@ class MockAutofillPopupViewDelegate : public AutofillPopupViewDelegate { MOCK_METHOD1(SetSelectionAtPoint, void(const gfx::Point&)); MOCK_METHOD1(AcceptSelectionAtPoint, void(const gfx::Point&)); MOCK_METHOD0(SelectionCleared, void()); - MOCK_METHOD1(ShouldRepostEvent, bool(const ui::MouseEvent&)); + // TODO(jdduke): Mock this method upon resolution of crbug.com/352463. + bool ShouldRepostEvent(const ui::MouseEvent&) { return false; } MOCK_CONST_METHOD0(ShouldHideOnOutsideClick, bool()); MOCK_CONST_METHOD0(popup_bounds, gfx::Rect&()); MOCK_METHOD0(container_view, gfx::NativeView()); diff --git a/content/browser/renderer_host/input/input_router_impl.cc b/content/browser/renderer_host/input/input_router_impl.cc index 9ca4489..bc17077 100644 --- a/content/browser/renderer_host/input/input_router_impl.cc +++ b/content/browser/renderer_host/input/input_router_impl.cc @@ -104,7 +104,7 @@ GestureEventWithLatencyInfo MakeGestureEvent(WebInputEvent::Type type, int x, int y, int modifiers, - const ui::LatencyInfo latency) { + const ui::LatencyInfo& latency) { WebGestureEvent result; result.type = type; diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc index 9b0e73e..16edbc3 100644 --- a/content/renderer/render_widget.cc +++ b/content/renderer/render_widget.cc @@ -1037,7 +1037,7 @@ void RenderWidget::OnSwapBuffersComplete() { } void RenderWidget::OnHandleInputEvent(const blink::WebInputEvent* input_event, - ui::LatencyInfo latency_info, + const ui::LatencyInfo& latency_info, bool is_keyboard_shortcut) { handling_input_event_ = true; if (!input_event) { @@ -1056,10 +1056,11 @@ void RenderWidget::OnHandleInputEvent(const blink::WebInputEvent* input_event, TRACE_EVENT_SYNTHETIC_DELAY_BEGIN("blink.HandleInputEvent"); scoped_ptr<cc::SwapPromiseMonitor> latency_info_swap_promise_monitor; - + ui::LatencyInfo swap_latency_info(latency_info); if (compositor_) { latency_info_swap_promise_monitor = - compositor_->CreateLatencyInfoSwapPromiseMonitor(&latency_info).Pass(); + compositor_->CreateLatencyInfoSwapPromiseMonitor(&swap_latency_info) + .Pass(); } else { latency_info_.push_back(latency_info); } @@ -1169,7 +1170,7 @@ void RenderWidget::OnHandleInputEvent(const blink::WebInputEvent* input_event, new InputHostMsg_HandleInputEvent_ACK(routing_id_, input_event->type, ack_result, - latency_info)); + swap_latency_info)); if (rate_limiting_wanted && event_type_can_be_rate_limited && frame_pending && !is_hidden_) { // We want to rate limit the input events in this case, so we'll wait for diff --git a/content/renderer/render_widget.h b/content/renderer/render_widget.h index ce203d9..b960783 100644 --- a/content/renderer/render_widget.h +++ b/content/renderer/render_widget.h @@ -336,7 +336,7 @@ class CONTENT_EXPORT RenderWidget // RenderWidget IPC message handlers void OnHandleInputEvent(const blink::WebInputEvent* event, - ui::LatencyInfo latency_info, + const ui::LatencyInfo& latency_info, bool keyboard_shortcut); void OnCursorVisibilityChange(bool is_visible); void OnMouseCaptureLost(); diff --git a/ipc/ipc_message_utils.h b/ipc/ipc_message_utils.h index b05f76d..102992d 100644 --- a/ipc/ipc_message_utils.h +++ b/ipc/ipc_message_utils.h @@ -11,6 +11,7 @@ #include <string> #include <vector> +#include "base/containers/small_map.h" #include "base/files/file.h" #include "base/format_macros.h" #include "base/memory/scoped_vector.h" @@ -670,6 +671,41 @@ struct ParamTraits<ScopedVector<P> > { } }; +template <typename NormalMap, + int kArraySize, + typename EqualKey, + typename MapInit> +struct ParamTraits<base::SmallMap<NormalMap, kArraySize, EqualKey, MapInit> > { + typedef base::SmallMap<NormalMap, kArraySize, EqualKey, MapInit> param_type; + typedef typename param_type::key_type K; + typedef typename param_type::data_type V; + static void Write(Message* m, const param_type& p) { + WriteParam(m, static_cast<int>(p.size())); + typename param_type::const_iterator iter; + for (iter = p.begin(); iter != p.end(); ++iter) { + WriteParam(m, iter->first); + WriteParam(m, iter->second); + } + } + static bool Read(const Message* m, PickleIterator* iter, param_type* r) { + int size; + if (!m->ReadLength(iter, &size)) + return false; + for (int i = 0; i < size; ++i) { + K key; + if (!ReadParam(m, iter, &key)) + return false; + V& value = (*r)[key]; + if (!ReadParam(m, iter, &value)) + return false; + } + return true; + } + static void Log(const param_type& p, std::string* l) { + l->append("<base::SmallMap>"); + } +}; + // IPC types ParamTraits ------------------------------------------------------- // A ChannelHandle is basically a platform-inspecific wrapper around the diff --git a/ui/aura/window_event_dispatcher_unittest.cc b/ui/aura/window_event_dispatcher_unittest.cc index d07a1ff..aa24792 100644 --- a/ui/aura/window_event_dispatcher_unittest.cc +++ b/ui/aura/window_event_dispatcher_unittest.cc @@ -1623,14 +1623,17 @@ class WindowEventDispatcherTestWithMessageLoop // Start a nested message-loop, post an event to be dispatched, and then // terminate the message-loop. When the message-loop unwinds and gets back, // the reposted event should not have fired. - ui::MouseEvent mouse(ui::ET_MOUSE_PRESSED, gfx::Point(10, 10), - gfx::Point(10, 10), ui::EF_NONE, ui::EF_NONE); - message_loop()->PostTask(FROM_HERE, - base::Bind(&WindowEventDispatcher::RepostEvent, - base::Unretained(host()->dispatcher()), - mouse)); - message_loop()->PostTask(FROM_HERE, - message_loop()->QuitClosure()); + scoped_ptr<ui::MouseEvent> mouse(new ui::MouseEvent(ui::ET_MOUSE_PRESSED, + gfx::Point(10, 10), + gfx::Point(10, 10), + ui::EF_NONE, + ui::EF_NONE)); + message_loop()->PostTask( + FROM_HERE, + base::Bind(&WindowEventDispatcherTestWithMessageLoop::RepostEventHelper, + host()->dispatcher(), + base::Passed(&mouse))); + message_loop()->PostTask(FROM_HERE, message_loop()->QuitClosure()); base::MessageLoop::ScopedNestableTaskAllower allow(message_loop()); base::RunLoop loop; @@ -1658,6 +1661,12 @@ class WindowEventDispatcherTestWithMessageLoop } private: + // Used to avoid a copying |event| when binding to a closure. + static void RepostEventHelper(WindowEventDispatcher* dispatcher, + scoped_ptr<ui::MouseEvent> event) { + dispatcher->RepostEvent(*event); + } + scoped_ptr<Window> window_; ExitMessageLoopOnMousePress handler_; diff --git a/ui/events/latency_info.cc b/ui/events/latency_info.cc index 0e38f20..4f17667 100644 --- a/ui/events/latency_info.cc +++ b/ui/events/latency_info.cc @@ -12,7 +12,7 @@ namespace { -const unsigned int kMaxLatencyInfoNumber = 100; +const size_t kMaxLatencyInfoNumber = 100; const char* GetComponentName(ui::LatencyComponentType type) { #define CASE_TYPE(t) case ui::t: return #t diff --git a/ui/events/latency_info.h b/ui/events/latency_info.h index a9947640..7220187 100644 --- a/ui/events/latency_info.h +++ b/ui/events/latency_info.h @@ -5,11 +5,11 @@ #ifndef UI_EVENTS_LATENCY_INFO_H_ #define UI_EVENTS_LATENCY_INFO_H_ -#include <map> #include <utility> #include <vector> #include "base/basictypes.h" +#include "base/containers/small_map.h" #include "base/time/time.h" #include "ui/events/events_base_export.h" @@ -80,10 +80,14 @@ struct EVENTS_BASE_EXPORT LatencyInfo { uint32 event_count; }; + // Empirically determined constant based on a typical scroll sequence. + enum { kTypicalMaxComponentsPerLatencyInfo = 6 }; + // Map a Latency Component (with a component-specific int64 id) to a // component info. - typedef std::map<std::pair<LatencyComponentType, int64>, LatencyComponent> - LatencyMap; + typedef base::SmallMap< + std::map<std::pair<LatencyComponentType, int64>, LatencyComponent>, + kTypicalMaxComponentsPerLatencyInfo> LatencyMap; LatencyInfo(); |