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

Unified Diff: chrome/browser/chromeos/cros/input_method_library.cc

Issue 4162002: Reduce CPU usage for input method switching. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review fix Created 10 years, 1 month 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: chrome/browser/chromeos/cros/input_method_library.cc
diff --git a/chrome/browser/chromeos/cros/input_method_library.cc b/chrome/browser/chromeos/cros/input_method_library.cc
index 1e6f15af8a6b8813b0ea215ca0bff6f94ff7a4cc..9b5316f1da56f338474c57627fef23ab16421d1f 100644
--- a/chrome/browser/chromeos/cros/input_method_library.cc
+++ b/chrome/browser/chromeos/cros/input_method_library.cc
@@ -23,6 +23,7 @@
#include "chrome/common/notification_service.h"
namespace {
+
const char kIBusDaemonPath[] = "/usr/bin/ibus-daemon";
const char kCandidateWindowPath[] = "/opt/google/chrome/candidate_window";
@@ -290,7 +291,11 @@ class InputMethodLibraryImpl : public InputMethodLibrary,
}
if (active_input_methods_are_changed) {
- FOR_EACH_OBSERVER(Observer, observers_, ActiveInputMethodsChanged(this));
+ const size_t num_active_input_methods = GetNumActiveInputMethods();
+ FOR_EACH_OBSERVER(Observer, observers_,
+ ActiveInputMethodsChanged(this,
+ current_input_method_,
+ num_active_input_methods));
}
}
@@ -386,13 +391,29 @@ class InputMethodLibraryImpl : public InputMethodLibrary,
previous_input_method_ = current_input_method_;
current_input_method_ = new_input_method;
}
- FOR_EACH_OBSERVER(Observer, observers_, InputMethodChanged(this));
+ const size_t num_active_input_methods = GetNumActiveInputMethods();
+ FOR_EACH_OBSERVER(Observer, observers_,
+ InputMethodChanged(this,
+ previous_input_method_,
+ current_input_method_,
+ num_active_input_methods));
+
+ // Ask the first observer to update preferences. We should not ask every
+ // observer to do so. Otherwise, we'll end up updating preferences many
+ // times when many observers are attached (ex. many windows are opened),
+ // which is unnecessary and expensive.
+ ObserverListBase<Observer>::Iterator it(observers_);
+ Observer* first_observer = it.GetNext();
+ if (first_observer) {
+ first_observer->PreferenceUpdateNeeded(this,
+ previous_input_method_,
+ current_input_method_);
+ }
}
void RegisterProperties(const ImePropertyList& prop_list) {
// |prop_list| might be empty. This means "clear all properties."
current_ime_properties_ = prop_list;
- FOR_EACH_OBSERVER(Observer, observers_, ImePropertiesChanged(this));
}
void StartInputMethodProcesses() {
@@ -404,7 +425,6 @@ class InputMethodLibraryImpl : public InputMethodLibrary,
for (size_t i = 0; i < prop_list.size(); ++i) {
FindAndUpdateProperty(prop_list[i], &current_ime_properties_);
}
- FOR_EACH_OBSERVER(Observer, observers_, ImePropertiesChanged(this));
}
// Launches an input method procsess specified by the given command
« no previous file with comments | « chrome/browser/chromeos/cros/input_method_library.h ('k') | chrome/browser/chromeos/login/keyboard_switch_menu.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698