Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(116)

Unified Diff: ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.h

Issue 817983002: ozone: xkb: Load keymaps on worker thread & cache them (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adds unittests Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.h
diff --git a/ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.h b/ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.h
index d7a98545d3a435c884854f069798f9b72bcc1b4d..eba1d3518d5d47fb5ba8b8818226e12779a79c85 100644
--- a/ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.h
+++ b/ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.h
@@ -5,11 +5,16 @@
#ifndef UI_EVENTS_OZONE_LAYOUT_XKB_XKB_KEYBOARD_LAYOUT_ENGINE_H_
#define UI_EVENTS_OZONE_LAYOUT_XKB_XKB_KEYBOARD_LAYOUT_ENGINE_H_
+#include <map>
#include <xkbcommon/xkbcommon.h>
#include "base/containers/hash_tables.h"
+#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
+#include "base/single_thread_task_runner.h"
#include "base/strings/string16.h"
+#include "base/task_runner.h"
#include "ui/events/ozone/layout/events_ozone_layout_export.h"
#include "ui/events/ozone/layout/keyboard_layout_engine.h"
#include "ui/events/ozone/layout/xkb/scoped_xkb.h"
@@ -37,6 +42,10 @@ class EVENTS_OZONE_LAYOUT_EXPORT XkbKeyboardLayoutEngine
KeyboardCode* key_code,
uint32* platform_keycode) const override;
+ // Gets the names of the RMLO rule for libxkbcommon.
+ // Makes it protected for testing.
+ scoped_ptr<xkb_rule_names> GetXkbRuleNames(const std::string& layout_name);
+
protected:
// Table for EventFlagsToXkbFlags().
struct XkbFlagMapEntry {
@@ -60,6 +69,7 @@ class EVENTS_OZONE_LAYOUT_EXPORT XkbKeyboardLayoutEngine
const XkbKeyCodeConverter& key_code_converter_;
private:
+
// Sets a new XKB keymap. This updates xkb_state_ (which takes ownership
// of the keymap), and updates xkb_flag_map_ for the new keymap.
void SetKeymap(xkb_keymap* keymap);
@@ -82,10 +92,22 @@ class EVENTS_OZONE_LAYOUT_EXPORT XkbKeyboardLayoutEngine
base::char16 base_character,
int ui_flags) const;
+ // Callback when keymap file is loaded complete.
+ void OnKeymapLoaded(const std::string& layout_name, xkb_keymap* keymap);
+
// libxkbcommon uses explicit reference counting for its structures,
// so we need to trigger its cleanup.
scoped_ptr<xkb_context, XkbContextDeleter> xkb_context_;
scoped_ptr<xkb_state, XkbStateDeleter> xkb_state_;
+ std::map<std::string, xkb_keymap*> xkb_keymaps_;
+
+ std::string current_layout_name_;
+
+ // Task runner for event dispatch.
+ scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_;
+
+ // Support weak pointers for attach & detach callbacks.
+ base::WeakPtrFactory<XkbKeyboardLayoutEngine> weak_ptr_factory_;
};
} // namespace ui

Powered by Google App Engine
This is Rietveld 408576698