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

Side by Side Diff: chromeos/ime/component_extension_ime_manager.h

Issue 457943002: Improve perforance for component IME extensions initialization by using map instead of vector in Co… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed tests. Created 6 years, 4 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 | chromeos/ime/component_extension_ime_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #ifndef CHROMEOS_IME_COMPONENT_EXTENSION_IME_MANAGER_H_ 5 #ifndef CHROMEOS_IME_COMPONENT_EXTENSION_IME_MANAGER_H_
6 #define CHROMEOS_IME_COMPONENT_EXTENSION_IME_MANAGER_H_ 6 #define CHROMEOS_IME_COMPONENT_EXTENSION_IME_MANAGER_H_
7 7
8 #include <map>
8 #include <set> 9 #include <set>
9 10
10 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
11 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
12 #include "base/observer_list.h" 13 #include "base/observer_list.h"
13 #include "chromeos/chromeos_export.h" 14 #include "chromeos/chromeos_export.h"
14 #include "chromeos/ime/input_method_descriptor.h" 15 #include "chromeos/ime/input_method_descriptor.h"
15 16
16 namespace chromeos { 17 namespace chromeos {
17 18
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 // false if already corresponding component extension is unloaded. 82 // false if already corresponding component extension is unloaded.
82 bool UnloadComponentExtensionIME(const std::string& input_method_id); 83 bool UnloadComponentExtensionIME(const std::string& input_method_id);
83 84
84 // Returns true if |input_method_id| is whitelisted component extension input 85 // Returns true if |input_method_id| is whitelisted component extension input
85 // method. 86 // method.
86 bool IsWhitelisted(const std::string& input_method_id); 87 bool IsWhitelisted(const std::string& input_method_id);
87 88
88 // Returns true if |extension_id| is whitelisted component extension. 89 // Returns true if |extension_id| is whitelisted component extension.
89 bool IsWhitelistedExtension(const std::string& extension_id); 90 bool IsWhitelistedExtension(const std::string& extension_id);
90 91
91 // Returns InputMethodId. This function returns empty string if |extension_id|
92 // and |engine_id| is not a whitelisted component extention IME.
93 std::string GetId(const std::string& extension_id,
94 const std::string& engine_id);
95
96 // Returns localized name of |input_method_id|.
97 std::string GetName(const std::string& input_method_id);
98
99 // Returns localized description of |input_method_id|.
100 std::string GetDescription(const std::string& input_method_id);
101
102 // Returns list of input method id associated with |language|.
103 std::vector<std::string> ListIMEByLanguage(const std::string& language);
104
105 // Returns all IME as InputMethodDescriptors. 92 // Returns all IME as InputMethodDescriptors.
106 input_method::InputMethodDescriptors GetAllIMEAsInputMethodDescriptor(); 93 input_method::InputMethodDescriptors GetAllIMEAsInputMethodDescriptor();
107 94
108 // Returns all XKB keyboard IME as InputMethodDescriptors. 95 // Returns all XKB keyboard IME as InputMethodDescriptors.
109 input_method::InputMethodDescriptors GetXkbIMEAsInputMethodDescriptor(); 96 input_method::InputMethodDescriptors GetXkbIMEAsInputMethodDescriptor();
110 97
111 private: 98 private:
112 // Finds ComponentExtensionIME and EngineDescription associated with 99 // Finds ComponentExtensionIME and EngineDescription associated with
113 // |input_method_id|. This function retruns true if it is found, otherwise 100 // |input_method_id|. This function retruns true if it is found, otherwise
114 // returns false. |out_extension| and |out_engine| can be NULL. 101 // returns false. |out_extension| and |out_engine| can be NULL.
115 bool FindEngineEntry(const std::string& input_method_id, 102 bool FindEngineEntry(const std::string& input_method_id,
116 ComponentExtensionIME* out_extension, 103 ComponentExtensionIME* out_extension);
117 ComponentExtensionEngine* out_engine);
118 104
119 bool IsInLoginLayoutWhitelist(const std::vector<std::string>& layouts); 105 bool IsInLoginLayoutWhitelist(const std::vector<std::string>& layouts);
120 106
121 scoped_ptr<ComponentExtensionIMEManagerDelegate> delegate_; 107 scoped_ptr<ComponentExtensionIMEManagerDelegate> delegate_;
122 108
123 std::vector<ComponentExtensionIME> component_extension_imes_; 109 // The map of extension_id to ComponentExtensionIME instance.
110 // It's filled by Initialize() method and never changed during runtime.
111 std::map<std::string, ComponentExtensionIME> component_extension_imes_;
112
113 // For quick check the validity of a given input method id.
114 // It's filled by Initialize() method and never changed during runtime.
115 std::set<std::string> input_method_id_set_;
124 116
125 std::set<std::string> login_layout_set_; 117 std::set<std::string> login_layout_set_;
126 118
127 DISALLOW_COPY_AND_ASSIGN(ComponentExtensionIMEManager); 119 DISALLOW_COPY_AND_ASSIGN(ComponentExtensionIMEManager);
128 }; 120 };
129 121
130 } // namespace chromeos 122 } // namespace chromeos
131 123
132 #endif // CHROMEOS_IME_COMPONENT_EXTENSION_IME_MANAGER_H_ 124 #endif // CHROMEOS_IME_COMPONENT_EXTENSION_IME_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | chromeos/ime/component_extension_ime_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698