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

Side by Side Diff: ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.cc

Issue 2611473002: Use TaskScheduler instead of WorkerPool in xkb_keyboard_layout_engine.cc. (Closed)
Patch Set: Created 3 years, 11 months 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.h" 5 #include "ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <xkbcommon/xkbcommon-names.h> 8 #include <xkbcommon/xkbcommon-names.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/location.h" 13 #include "base/location.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/free_deleter.h" 16 #include "base/memory/free_deleter.h"
17 #include "base/single_thread_task_runner.h" 17 #include "base/single_thread_task_runner.h"
18 #include "base/task_runner.h" 18 #include "base/task_runner.h"
19 #include "base/task_scheduler/post_task.h"
19 #include "base/threading/thread_task_runner_handle.h" 20 #include "base/threading/thread_task_runner_handle.h"
20 #include "base/threading/worker_pool.h"
21 #include "build/build_config.h" 21 #include "build/build_config.h"
22 #include "ui/events/event_constants.h" 22 #include "ui/events/event_constants.h"
23 #include "ui/events/keycodes/dom/dom_code.h" 23 #include "ui/events/keycodes/dom/dom_code.h"
24 #include "ui/events/keycodes/dom/dom_key.h" 24 #include "ui/events/keycodes/dom/dom_key.h"
25 #include "ui/events/keycodes/dom/keycode_converter.h" 25 #include "ui/events/keycodes/dom/keycode_converter.h"
26 #include "ui/events/keycodes/keyboard_code_conversion.h" 26 #include "ui/events/keycodes/keyboard_code_conversion.h"
27 #include "ui/events/keycodes/keyboard_code_conversion_xkb.h" 27 #include "ui/events/keycodes/keyboard_code_conversion_xkb.h"
28 28
29 namespace ui { 29 namespace ui {
30 30
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 #if defined(OS_CHROMEOS) 678 #if defined(OS_CHROMEOS)
679 current_layout_name_ = layout_name; 679 current_layout_name_ = layout_name;
680 for (const auto& entry : xkb_keymaps_) { 680 for (const auto& entry : xkb_keymaps_) {
681 if (entry.layout_name == layout_name) { 681 if (entry.layout_name == layout_name) {
682 SetKeymap(entry.keymap); 682 SetKeymap(entry.keymap);
683 return true; 683 return true;
684 } 684 }
685 } 685 }
686 LoadKeymapCallback reply_callback = base::Bind( 686 LoadKeymapCallback reply_callback = base::Bind(
687 &XkbKeyboardLayoutEngine::OnKeymapLoaded, weak_ptr_factory_.GetWeakPtr()); 687 &XkbKeyboardLayoutEngine::OnKeymapLoaded, weak_ptr_factory_.GetWeakPtr());
688 base::WorkerPool::PostTask( 688 base::PostTaskWithTraits(
689 FROM_HERE, 689 FROM_HERE, base::TaskTraits()
690 .WithShutdownBehavior(
691 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN)
692 .MayBlock(),
690 base::Bind(&LoadKeymap, layout_name, base::ThreadTaskRunnerHandle::Get(), 693 base::Bind(&LoadKeymap, layout_name, base::ThreadTaskRunnerHandle::Get(),
691 reply_callback), 694 reply_callback));
692 true);
693 return true; 695 return true;
694 #else 696 #else
695 // Required by ozone-wayland (at least) for non ChromeOS builds. See 697 // Required by ozone-wayland (at least) for non ChromeOS builds. See
696 // http://xkbcommon.org/doc/current/md_doc_quick-guide.html for further info. 698 // http://xkbcommon.org/doc/current/md_doc_quick-guide.html for further info.
697 xkb_keymap* keymap = xkb_keymap_new_from_string( 699 xkb_keymap* keymap = xkb_keymap_new_from_string(
698 xkb_context_.get(), layout_name.c_str(), XKB_KEYMAP_FORMAT_TEXT_V1, 700 xkb_context_.get(), layout_name.c_str(), XKB_KEYMAP_FORMAT_TEXT_V1,
699 XKB_KEYMAP_COMPILE_NO_FLAGS); 701 XKB_KEYMAP_COMPILE_NO_FLAGS);
700 if (!keymap) 702 if (!keymap)
701 return false; 703 return false;
702 SetKeymap(keymap); 704 SetKeymap(keymap);
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 close_index = layout_name.size(); 973 close_index = layout_name.size();
972 *layout_variant = layout_name.substr(parentheses_index + 1, 974 *layout_variant = layout_name.substr(parentheses_index + 1,
973 close_index - parentheses_index - 1); 975 close_index - parentheses_index - 1);
974 } else if (dash_index != std::string::npos) { 976 } else if (dash_index != std::string::npos) {
975 *layout_id = layout_name.substr(0, dash_index); 977 *layout_id = layout_name.substr(0, dash_index);
976 *layout_variant = layout_name.substr(dash_index + 1); 978 *layout_variant = layout_name.substr(dash_index + 1);
977 } 979 }
978 } 980 }
979 981
980 } // namespace ui 982 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698