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

Side by Side Diff: chrome/browser/chromeos/input_method/ibus_controller_impl.cc

Issue 10159004: Extends DBusThreadManager to connect ibus-bus. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix nits Created 8 years, 7 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/chromeos/input_method/ibus_controller_impl.h" 5 #include "chrome/browser/chromeos/input_method/ibus_controller_impl.h"
6 6
7 #include <algorithm> // for std::reverse. 7 #include <algorithm> // for std::reverse.
8 #include <cstdio> 8 #include <cstdio>
9 #include <cstring> // for std::strcmp. 9 #include <cstring> // for std::strcmp.
10 #include <set> 10 #include <set>
11 #include <sstream> 11 #include <sstream>
12 #include <stack> 12 #include <stack>
13 #include <utility> 13 #include <utility>
14 14
15 #include "base/bind.h"
16 #include "base/environment.h"
17 #include "base/files/file_path_watcher.h"
15 #include "base/memory/scoped_ptr.h" 18 #include "base/memory/scoped_ptr.h"
19 #include "base/message_loop.h"
20 #include "base/rand_util.h"
16 #include "base/stringprintf.h" 21 #include "base/stringprintf.h"
17 #include "base/string_split.h" 22 #include "base/string_split.h"
18 #include "chrome/browser/chromeos/input_method/input_method_config.h" 23 #include "chrome/browser/chromeos/input_method/input_method_config.h"
19 #include "chrome/browser/chromeos/input_method/input_method_property.h" 24 #include "chrome/browser/chromeos/input_method/input_method_property.h"
20 #include "chrome/browser/chromeos/input_method/input_method_util.h" 25 #include "chrome/browser/chromeos/input_method/input_method_util.h"
26 #include "chromeos/dbus/dbus_thread_manager.h"
27 #include "content/public/browser/browser_thread.h"
21 28
22 // TODO(nona): Remove libibus dependency from this file. Then, write unit tests 29 // TODO(nona): Remove libibus dependency from this file. Then, write unit tests
23 // for all functions in this file. crbug.com/26334 30 // for all functions in this file. crbug.com/26334
24 #if defined(HAVE_IBUS) 31 #if defined(HAVE_IBUS)
25 #include <ibus.h> 32 #include <ibus.h>
26 #endif 33 #endif
27 34
28 namespace { 35 namespace {
29 36
30 // Finds a property which has |new_prop.key| from |prop_list|, and replaces the 37 // Finds a property which has |new_prop.key| from |prop_list|, and replaces the
(...skipping 15 matching lines...) Expand all
46 return false; 53 return false;
47 } 54 }
48 55
49 } // namespace 56 } // namespace
50 57
51 namespace chromeos { 58 namespace chromeos {
52 namespace input_method { 59 namespace input_method {
53 60
54 #if defined(HAVE_IBUS) 61 #if defined(HAVE_IBUS)
55 const char kPanelObjectKey[] = "panel-object"; 62 const char kPanelObjectKey[] = "panel-object";
63 const int kIBusDaemonRetryCount = 10;
56 64
57 namespace { 65 namespace {
58 66
59 const char* Or(const char* str1, const char* str2) { 67 const char* Or(const char* str1, const char* str2) {
60 return str1 ? str1 : str2; 68 return str1 ? str1 : str2;
61 } 69 }
62 70
63 // Returns true if |key| is blacklisted. 71 // Returns true if |key| is blacklisted.
64 bool PropertyKeyIsBlacklisted(const char* key) { 72 bool PropertyKeyIsBlacklisted(const char* key) {
65 // The list of input method property keys that we don't handle. 73 // The list of input method property keys that we don't handle.
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 std::stringstream stream; 358 std::stringstream stream;
351 for (int i = 0;; ++i) { 359 for (int i = 0;; ++i) {
352 IBusProperty* prop = ibus_prop_list_get(prop_list, i); 360 IBusProperty* prop = ibus_prop_list_get(prop_list, i);
353 if (!prop) 361 if (!prop)
354 break; 362 break;
355 stream << PrintProp(prop, tree_level); 363 stream << PrintProp(prop, tree_level);
356 } 364 }
357 return stream.str(); 365 return stream.str();
358 } 366 }
359 367
368 void MaybeResetIBusBusAndSetsInitializationDone(
369 const std::string& ibus_address,
370 IBusControllerImpl* controller) {
371 chromeos::DBusThreadManager::Get()->MaybeResetIBusBus(ibus_address);
372 controller->IBusDaemonInitializationDone();
373 }
374
375 // The implementation of FilePathWatcher::Delegate, used in
376 // StartAddressFileWatch function.
377 class IBusAddressFileWatcherDelegate
378 : public base::files::FilePathWatcher::Delegate {
379 public:
380 IBusAddressFileWatcherDelegate(const std::string& ibus_address,
381 IBusControllerImpl* controller,
382 base::files::FilePathWatcher* watcher)
383 : ibus_address_(ibus_address),
384 controller_(controller),
385 watcher_(watcher) {
386 DCHECK(controller);
387 DCHECK(watcher);
388 DCHECK(!ibus_address.empty());
389 }
390
391 virtual ~IBusAddressFileWatcherDelegate() {}
392
393 virtual void OnFilePathChanged(const FilePath& file_path) {
394 if (!watcher_)
395 return;
396 bool success = content::BrowserThread::PostTask(
397 content::BrowserThread::UI,
398 FROM_HERE,
399 base::Bind(&MaybeResetIBusBusAndSetsInitializationDone,
400 ibus_address_,
401 controller_));
402 DCHECK(success);
403 MessageLoop::current()->DeleteSoon(FROM_HERE, watcher_);
404 watcher_ = NULL;
405 }
406
407 private:
408 // The ibus-daemon address.
409 const std::string ibus_address_;
410 IBusControllerImpl* controller_;
411 base::files::FilePathWatcher* watcher_;
412
413 DISALLOW_COPY_AND_ASSIGN(IBusAddressFileWatcherDelegate);
414 };
415
416 void StartAddressFileWatch(const std::string& ibus_address,
417 IBusControllerImpl* controller) {
418 scoped_ptr<base::Environment> env(base::Environment::Create());
419 std::string address_file_path;
420 env->GetVar("IBUS_ADDRESS_FILE", &address_file_path);
Yusuke Sato 2012/05/01 07:06:55 Calling GetVar on FILE thread looks a bit scary. I
Seigo Nonaka 2012/05/02 05:12:10 Done.
421 DCHECK(!address_file_path.empty());
422
423 // The |watcher| instance will be released by |delegate|.
424 base::files::FilePathWatcher* watcher = new base::files::FilePathWatcher;
Yusuke Sato 2012/05/01 07:06:55 remove the previous instance here? see my comment
Seigo Nonaka 2012/05/02 05:12:10 Done.
425
426 // The |delegate| is owned by watcher.
427 IBusAddressFileWatcherDelegate* delegate = new IBusAddressFileWatcherDelegate(
428 ibus_address, controller, watcher);
429 bool result = watcher->Watch(FilePath(address_file_path), delegate);
430 DCHECK(result);
431 }
Yusuke Sato 2012/05/01 07:06:55 nit: space between 431 & 432.
Seigo Nonaka 2012/05/02 05:12:10 Done.
360 } // namespace 432 } // namespace
361 433
362 IBusControllerImpl::IBusControllerImpl() 434 IBusControllerImpl::IBusControllerImpl()
363 : ibus_(NULL), 435 : ibus_(NULL),
364 ibus_config_(NULL), 436 ibus_config_(NULL),
365 should_launch_daemon_(false), 437 process_handle_(base::kNullProcessHandle),
366 process_handle_(base::kNullProcessHandle) { 438 ibus_daemon_status_(IBUS_DAEMON_STOP),
439 ibus_launch_retry_count_(kIBusDaemonRetryCount),
440 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
367 } 441 }
368 442
369 IBusControllerImpl::~IBusControllerImpl() { 443 IBusControllerImpl::~IBusControllerImpl() {
370 // Disconnect signals so the handler functions will not be called with 444 // Disconnect signals so the handler functions will not be called with
371 // |this| which is already freed. 445 // |this| which is already freed.
372 if (ibus_) { 446 if (ibus_) {
373 g_signal_handlers_disconnect_by_func( 447 g_signal_handlers_disconnect_by_func(
374 ibus_, 448 ibus_,
375 reinterpret_cast<gpointer>(G_CALLBACK(BusConnectedThunk)), 449 reinterpret_cast<gpointer>(G_CALLBACK(BusConnectedThunk)),
376 this); 450 this);
(...skipping 21 matching lines...) Expand all
398 g_signal_handlers_disconnect_by_func( 472 g_signal_handlers_disconnect_by_func(
399 ibus_panel_service, 473 ibus_panel_service,
400 reinterpret_cast<gpointer>(G_CALLBACK(UpdatePropertyThunk)), 474 reinterpret_cast<gpointer>(G_CALLBACK(UpdatePropertyThunk)),
401 this); 475 this);
402 } 476 }
403 } 477 }
404 } 478 }
405 479
406 bool IBusControllerImpl::Start() { 480 bool IBusControllerImpl::Start() {
407 MaybeInitializeIBusBus(); 481 MaybeInitializeIBusBus();
408 should_launch_daemon_ = true;
409 if (IBusConnectionsAreAlive()) 482 if (IBusConnectionsAreAlive())
410 return true; 483 return true;
411 return MaybeLaunchIBusDaemon(); 484 if (ibus_daemon_status_ == IBUS_DAEMON_STOP ||
485 ibus_daemon_status_ == IBUS_DAEMON_SHUTTING_DOWN) {
486 return StartIBusDaemon();
487 }
488 return true;
412 } 489 }
413 490
414 void IBusControllerImpl::Reset() { 491 void IBusControllerImpl::Reset() {
415 if (!IBusConnectionsAreAlive()) 492 if (!IBusConnectionsAreAlive())
416 return; 493 return;
417 IBusInputContext* context = 494 IBusInputContext* context =
418 GetInputContext(current_input_context_path_, ibus_); 495 GetInputContext(current_input_context_path_, ibus_);
419 if (!context) 496 if (!context)
420 return; 497 return;
421 ibus_input_context_reset(context); 498 ibus_input_context_reset(context);
422 } 499 }
423 500
424 bool IBusControllerImpl::Stop() { 501 bool IBusControllerImpl::Stop() {
502 if (process_handle_ == base::kNullProcessHandle) {
Yusuke Sato 2012/05/01 07:06:55 You checked |ibus_daemon_status_| in Start() but c
Seigo Nonaka 2012/05/02 05:12:10 Done.
503 // The daemon hasn't been started yet.
504 return true;
505 }
506
507 ibus_daemon_status_ = IBUS_DAEMON_SHUTTING_DOWN;
508 // TODO(nona): Shutdown ibus-bus connection.
425 if (IBusConnectionsAreAlive()) { 509 if (IBusConnectionsAreAlive()) {
426 // Ask IBus to exit *asynchronously*. 510 // Ask IBus to exit *asynchronously*.
427 ibus_bus_exit_async(ibus_, 511 ibus_bus_exit_async(ibus_,
428 FALSE /* do not restart */, 512 FALSE /* do not restart */,
429 -1 /* timeout */, 513 -1 /* timeout */,
430 NULL /* cancellable */, 514 NULL /* cancellable */,
431 NULL /* callback */, 515 NULL /* callback */,
432 NULL /* user_data */); 516 NULL /* user_data */);
433 if (ibus_config_) { 517 if (ibus_config_) {
434 // Release |ibus_config_| unconditionally to make sure next 518 // Release |ibus_config_| unconditionally to make sure next
435 // IBusConnectionsAreAlive() call will return false. 519 // IBusConnectionsAreAlive() call will return false.
436 g_object_unref(ibus_config_); 520 g_object_unref(ibus_config_);
437 ibus_config_ = NULL; 521 ibus_config_ = NULL;
438 } 522 }
439 } else if (process_handle_ != base::kNullProcessHandle) { 523 } else {
524 ibus_daemon_status_ = IBUS_DAEMON_SHUTTING_DOWN;
Yusuke Sato 2012/05/01 07:06:55 nit: looks like this is unnecessary. see L.507.
Seigo Nonaka 2012/05/02 05:12:10 Done.
440 base::KillProcess(process_handle_, -1, false /* wait */); 525 base::KillProcess(process_handle_, -1, false /* wait */);
441 DVLOG(1) << "Killing ibus-daemon. PID=" 526 DVLOG(1) << "Killing ibus-daemon. PID="
442 << base::GetProcId(process_handle_); 527 << base::GetProcId(process_handle_);
443 } else {
444 // The daemon hasn't been started yet.
445 } 528 }
446
447 process_handle_ = base::kNullProcessHandle; 529 process_handle_ = base::kNullProcessHandle;
448 should_launch_daemon_ = false;
449 return true; 530 return true;
450 } 531 }
451 532
452 bool IBusControllerImpl::ChangeInputMethod(const std::string& id) { 533 bool IBusControllerImpl::ChangeInputMethod(const std::string& id) {
453 DCHECK(should_launch_daemon_); 534 DCHECK_EQ(IBUS_DAEMON_RUNNING, ibus_daemon_status_);
Yusuke Sato 2012/05/01 07:06:55 I think this DCHECK is harmful. Consider this case
Seigo Nonaka 2012/05/02 05:12:10 Done.
454 535
455 // Sanity checks. 536 // Sanity checks.
456 DCHECK(!InputMethodUtil::IsKeyboardLayout(id)); 537 DCHECK(!InputMethodUtil::IsKeyboardLayout(id));
457 if (!whitelist_.InputMethodIdIsWhitelisted(id) && 538 if (!whitelist_.InputMethodIdIsWhitelisted(id) &&
458 !InputMethodUtil::IsExtensionInputMethod(id)) 539 !InputMethodUtil::IsExtensionInputMethod(id))
459 return false; 540 return false;
460 541
461 // Clear input method properties unconditionally if |id| is not equal to 542 // Clear input method properties unconditionally if |id| is not equal to
462 // |current_input_method_id_|. 543 // |current_input_method_id_|.
463 // 544 //
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 966
886 // Notify the change. 967 // Notify the change.
887 if (!prop_list.empty()) { 968 if (!prop_list.empty()) {
888 for (size_t i = 0; i < prop_list.size(); ++i) { 969 for (size_t i = 0; i < prop_list.size(); ++i) {
889 FindAndUpdateProperty(prop_list[i], &current_property_list_); 970 FindAndUpdateProperty(prop_list[i], &current_property_list_);
890 } 971 }
891 FOR_EACH_OBSERVER(Observer, observers_, PropertyChanged()); 972 FOR_EACH_OBSERVER(Observer, observers_, PropertyChanged());
892 } 973 }
893 } 974 }
894 975
895 bool IBusControllerImpl::MaybeLaunchIBusDaemon() { 976 bool IBusControllerImpl::StartIBusDaemon() {
977 DCHECK_EQ(base::kNullProcessHandle, process_handle_);
Yusuke Sato 2012/05/01 07:06:55 move this to LaunchIBusDaemon()? you can check ibu
Seigo Nonaka 2012/05/02 05:12:10 Done.
978 ibus_daemon_status_ = IBUS_DAEMON_INITIALIZING;
979 const std::string ibus_address = base::StringPrintf(
980 "unix:abstract=/tmp/ibus-%0lX", base::RandUint64());
Yusuke Sato 2012/05/01 07:06:55 nit: It's not a file but a socket in an abstract n
Seigo Nonaka 2012/05/02 05:12:10 Done.
981
982 // Set up ibus-daemon address file watcher before launching ibus-daemon,
983 // because if watcher start after ibus-daemon, we may miss the ibus connection
984 // initialization.
985 bool success = content::BrowserThread::PostTaskAndReply(
986 content::BrowserThread::FILE,
987 FROM_HERE,
988 base::Bind(&StartAddressFileWatch,
989 ibus_address,
990 weak_ptr_factory_.GetWeakPtr()),
991 base::Bind(&IBusControllerImpl::LaunchIBusDaemon,
992 weak_ptr_factory_.GetWeakPtr(),
993 ibus_address));
994 DCHECK(success);
995 return true;
996 }
997
998 void IBusControllerImpl::LaunchIBusDaemon(const std::string& ibus_address) {
896 static const char kIBusDaemonPath[] = "/usr/bin/ibus-daemon"; 999 static const char kIBusDaemonPath[] = "/usr/bin/ibus-daemon";
897
898 if (process_handle_ != base::kNullProcessHandle) {
899 DVLOG(1) << "MaybeLaunchIBusDaemon: ibus-daemon is already running.";
900 return false;
901 }
902 if (!should_launch_daemon_)
903 return false;
904
905 // TODO(zork): Send output to /var/log/ibus.log 1000 // TODO(zork): Send output to /var/log/ibus.log
906 const std::string ibus_daemon_command_line = 1001 const std::string ibus_daemon_command_line =
907 base::StringPrintf("%s --panel=disable --cache=none --restart --replace", 1002 base::StringPrintf("%s --panel=disable --cache=none --restart --replace"
908 kIBusDaemonPath); 1003 " --address=%s",
1004 kIBusDaemonPath,
1005 ibus_address.c_str());
909 if (!LaunchProcess(ibus_daemon_command_line, 1006 if (!LaunchProcess(ibus_daemon_command_line,
910 &process_handle_, 1007 &process_handle_,
911 reinterpret_cast<GChildWatchFunc>(OnIBusDaemonExit))) { 1008 reinterpret_cast<GChildWatchFunc>(OnIBusDaemonExit))) {
912 DVLOG(1) << "Failed to launch " << ibus_daemon_command_line; 1009 DVLOG(1) << "Failed to launch " << ibus_daemon_command_line;
913 return false;
914 } 1010 }
915 return true;
916 } 1011 }
917 1012
918 bool IBusControllerImpl::LaunchProcess(const std::string& command_line, 1013 bool IBusControllerImpl::LaunchProcess(const std::string& command_line,
919 base::ProcessHandle* process_handle, 1014 base::ProcessHandle* process_handle,
920 GChildWatchFunc watch_func) { 1015 GChildWatchFunc watch_func) {
921 std::vector<std::string> argv; 1016 std::vector<std::string> argv;
922 base::ProcessHandle handle = base::kNullProcessHandle; 1017 base::ProcessHandle handle = base::kNullProcessHandle;
923 1018
924 base::SplitString(command_line, ' ', &argv); 1019 base::SplitString(command_line, ' ', &argv);
925 1020
926 if (!base::LaunchProcess(argv, base::LaunchOptions(), &handle)) { 1021 if (!base::LaunchProcess(argv, base::LaunchOptions(), &handle)) {
927 DVLOG(1) << "Could not launch: " << command_line; 1022 DVLOG(1) << "Could not launch: " << command_line;
928 return false; 1023 return false;
929 } 1024 }
930 1025
931 // g_child_watch_add is necessary to prevent the process from becoming a 1026 // g_child_watch_add is necessary to prevent the process from becoming a
932 // zombie. 1027 // zombie.
933 // TODO(yusukes): port g_child_watch_add to base/process_utils_posix.cc. 1028 // TODO(yusukes): port g_child_watch_add to base/process_utils_posix.cc.
934 const base::ProcessId pid = base::GetProcId(handle); 1029 const base::ProcessId pid = base::GetProcId(handle);
935 g_child_watch_add(pid, watch_func, this); 1030 g_child_watch_add(pid, watch_func, this);
936 1031
937 *process_handle = handle; 1032 *process_handle = handle;
938 DVLOG(1) << command_line << "is started. PID=" << pid; 1033 DVLOG(1) << command_line << "is started. PID=" << pid;
939 return true; 1034 return true;
940 } 1035 }
941 1036
1037 void IBusControllerImpl::IBusDaemonInitializationDone() {
1038 DCHECK_NE(IBUS_DAEMON_RUNNING, ibus_daemon_status_);
1039 if (ibus_daemon_status_ != IBUS_DAEMON_INITIALIZING) {
1040 // Corresponding to killing ibus-daemon under initializing, so do nothing.
1041 // TODO(nona): Shutdown ibus bus connection.
1042 return;
1043 }
1044 ibus_daemon_status_ = IBUS_DAEMON_RUNNING;
1045 // Reset retry count
Yusuke Sato 2012/05/01 07:06:55 nit: this looks obvious. remove
Seigo Nonaka 2012/05/02 05:12:10 Removed retry count from CL. Thanks. On 2012/05/01
1046 ibus_launch_retry_count_ = kIBusDaemonRetryCount;
1047 }
1048
942 // static 1049 // static
943 void IBusControllerImpl::SetInputMethodConfigCallback(GObject* source_object, 1050 void IBusControllerImpl::SetInputMethodConfigCallback(GObject* source_object,
944 GAsyncResult* res, 1051 GAsyncResult* res,
945 gpointer user_data) { 1052 gpointer user_data) {
946 IBusConfig* config = IBUS_CONFIG(user_data); 1053 IBusConfig* config = IBUS_CONFIG(user_data);
947 g_return_if_fail(config); 1054 g_return_if_fail(config);
948 1055
949 GError* error = NULL; 1056 GError* error = NULL;
950 const gboolean result = 1057 const gboolean result =
951 ibus_config_set_value_async_finish(config, res, &error); 1058 ibus_config_set_value_async_finish(config, res, &error);
952 1059
953 if (!result) { 1060 if (!result) {
954 std::string message = "(unknown error)"; 1061 std::string message = "(unknown error)";
955 if (error && error->message) { 1062 if (error && error->message) {
956 message = error->message; 1063 message = error->message;
957 } 1064 }
958 DVLOG(1) << "ibus_config_set_value_async failed: " << message; 1065 DVLOG(1) << "ibus_config_set_value_async failed: " << message;
959 } 1066 }
960 1067
961 if (error) 1068 if (error)
962 g_error_free(error); 1069 g_error_free(error);
963 g_object_unref(config); 1070 g_object_unref(config);
964 } 1071 }
965 1072
966 // static
967 void IBusControllerImpl::OnIBusDaemonExit(GPid pid, 1073 void IBusControllerImpl::OnIBusDaemonExit(GPid pid,
968 gint status, 1074 gint status,
969 IBusControllerImpl* controller) { 1075 IBusControllerImpl* controller) {
970 if (controller->process_handle_ != base::kNullProcessHandle && 1076 const IBusDaemonStatus on_exit_state = controller->ibus_daemon_status_;
971 base::GetProcId(controller->process_handle_) == pid) { 1077 controller->ibus_daemon_status_ = IBUS_DAEMON_STOP;
972 controller->process_handle_ = base::kNullProcessHandle; 1078
1079 if (controller->process_handle_ != base::kNullProcessHandle) {
1080 if (base::GetProcId(controller->process_handle_) == pid) {
1081 // Corresponding to shutting down ibus-daemon by exit message or crashing
1082 // ibus-daemon. So reset handler and try re-launch if necessary.
1083 controller->process_handle_ = base::kNullProcessHandle;
1084 } else {
1085 // Corresponding to ibus-daemon is re-launched during
Yusuke Sato 2012/05/01 07:06:55 question: when exactly could this path be taken? p
Seigo Nonaka 2012/05/02 05:12:10 I added the this condition path in code comment.
1086 // |ibus_daemon_status_| is IBUS_DAEMON_SHUTTING_DOWN. So this exit signal
1087 // is corresponds to old ibus-daemon's one and do not try re-launch.
1088 // TODO(nona): Shutdown ibus-bus connection.
1089 return;
Yusuke Sato 2012/05/01 07:06:55 should we assign STOP in this case? (see L.1077)
Seigo Nonaka 2012/05/02 05:12:10 Thanks moved L.1077 to L.1092 On 2012/05/01 07:06:
1090 }
973 } 1091 }
974 // Restart the daemon if needed. 1092
975 controller->MaybeLaunchIBusDaemon(); 1093 if (on_exit_state == IBUS_DAEMON_SHUTTING_DOWN) {
1094 // Normal exitting, so do nothing.
1095 return;
1096 }
1097
1098 DCHECK_NE(IBUS_DAEMON_STOP, on_exit_state);
Yusuke Sato 2012/05/01 07:06:55 (note: still checking if this DCHECK is valid.)
Seigo Nonaka 2012/05/02 05:12:10 Thanks, removed. On 2012/05/01 07:06:55, Yusuke Sa
1099
1100 if (on_exit_state == IBUS_DAEMON_INITIALIZING) {
1101 // TODO(nona): Remove current file watcher if exit on initializing state.
Yusuke Sato 2012/05/01 07:06:55 I guess it's not actually safe. please consider th
Seigo Nonaka 2012/05/02 05:12:10 Done.
1102 // It is safe to leave watcher insatnce if the ibus-daemon is crashed before
1103 // making address file.
1104 }
1105
1106 if (controller->ibus_launch_retry_count_ == 0) {
1107 LOG(FATAL) << "Give up re-launching ibus-daemon";
Yusuke Sato 2012/05/01 07:06:55 I don't think we need to reboot Chromebook here be
Seigo Nonaka 2012/05/02 05:12:10 Done.
1108 return;
1109 } else {
1110 LOG(ERROR) << "The ibus-daemon is crashed. Re-launching...";
1111 --controller->ibus_launch_retry_count_;
1112 controller->StartIBusDaemon();
1113 }
976 } 1114 }
977 #endif // defined(HAVE_IBUS) 1115 #endif // defined(HAVE_IBUS)
978 1116
979 // static 1117 // static
980 bool IBusControllerImpl::FindAndUpdatePropertyForTesting( 1118 bool IBusControllerImpl::FindAndUpdatePropertyForTesting(
981 const chromeos::input_method::InputMethodProperty& new_prop, 1119 const chromeos::input_method::InputMethodProperty& new_prop,
982 chromeos::input_method::InputMethodPropertyList* prop_list) { 1120 chromeos::input_method::InputMethodPropertyList* prop_list) {
983 return FindAndUpdateProperty(new_prop, prop_list); 1121 return FindAndUpdateProperty(new_prop, prop_list);
984 } 1122 }
985 1123
986 } // namespace input_method 1124 } // namespace input_method
987 } // namespace chromeos 1125 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698