diff options
author | nona@chromium.org <nona@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-30 09:14:43 +0000 |
---|---|---|
committer | nona@chromium.org <nona@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-30 09:14:43 +0000 |
commit | 1da6d26f09f93e77ae35538783db87f367347bd3 (patch) | |
tree | 0295cde7dc56f75bd8df01d0fe800735815ab080 /chromeos/ime | |
parent | 0e5c81fa046e2f9cb63204260068a73555e660b6 (diff) | |
download | chromium_src-1da6d26f09f93e77ae35538783db87f367347bd3.zip chromium_src-1da6d26f09f93e77ae35538783db87f367347bd3.tar.gz chromium_src-1da6d26f09f93e77ae35538783db87f367347bd3.tar.bz2 |
Introduce empty IBusDaemonController class.
This class is substitue of IBusController.
BUG=170671
TEST=None
Review URL: https://chromiumcodereview.appspot.com/12041006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@179570 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos/ime')
-rw-r--r-- | chromeos/ime/ibus_daemon_controller.cc | 104 | ||||
-rw-r--r-- | chromeos/ime/ibus_daemon_controller.h | 59 |
2 files changed, 163 insertions, 0 deletions
diff --git a/chromeos/ime/ibus_daemon_controller.cc b/chromeos/ime/ibus_daemon_controller.cc new file mode 100644 index 0000000..925bdf7 --- /dev/null +++ b/chromeos/ime/ibus_daemon_controller.cc @@ -0,0 +1,104 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chromeos/ime/ibus_daemon_controller.h" + +#include "base/chromeos/chromeos_version.h" +#include "base/logging.h" +#include "base/threading/thread_checker.h" + +namespace chromeos { + +namespace { + +IBusDaemonController* g_ibus_daemon_controller = NULL; + +// The implementation of IBusDaemonController. +class IBusDaemonControllerImpl : public IBusDaemonController { + public: + IBusDaemonControllerImpl() {} + + ~IBusDaemonControllerImpl() {} + + // IBusDaemonController override: + void Initialize( + const scoped_refptr<base::SequencedTaskRunner>& ui_task_runner, + const scoped_refptr<base::SequencedTaskRunner>& file_task_runner) { + DCHECK(thread_checker_.CalledOnValidThread()); + // TODO(nona): Implement this. + } + + // IBusDaemonController override: + void AddObserver(Observer* observer) { + DCHECK(thread_checker_.CalledOnValidThread()); + // TODO(nona): Implement this. + } + + // IBusDaemonController override: + void RemoveObserver(Observer* observer) { + DCHECK(thread_checker_.CalledOnValidThread()); + // TODO(nona): Implement this. + } + + // IBusDaemonController override: + bool Start() OVERRIDE { + DCHECK(thread_checker_.CalledOnValidThread()); + // TODO(nona): Implement this. + return true; + } + + // IBusDaemonController override: + bool Stop() OVERRIDE { + DCHECK(thread_checker_.CalledOnValidThread()); + // TODO(nona): Implement this. + return true; + } + + private: + base::ThreadChecker thread_checker_; + DISALLOW_COPY_AND_ASSIGN(IBusDaemonControllerImpl); +}; + +// The stub implementation of IBusDaemonController. +class IBusDaemonControllerStubImpl : public IBusDaemonController { + public: + IBusDaemonControllerStubImpl() {} + virtual ~IBusDaemonControllerStubImpl() {} + + // IBusDaemonController overrides: + void Initialize( + const scoped_refptr<base::SequencedTaskRunner>& ui_runner, + const scoped_refptr<base::SequencedTaskRunner>& file_runner) OVERRIDE {} + virtual void AddObserver(Observer* observer) OVERRIDE {} + virtual void RemoveObserver(Observer* observer) OVERRIDE {} + virtual bool Start() OVERRIDE { return true; } + virtual bool Stop() OVERRIDE { return true; } + + private: + DISALLOW_COPY_AND_ASSIGN(IBusDaemonControllerStubImpl); +}; + +} // namespace + +/////////////////////////////////////////////////////////////////////////////// +// IBusDaemonController + +IBusDaemonController::IBusDaemonController() { +} + +IBusDaemonController::~IBusDaemonController() { +} + +IBusDaemonController* IBusDaemonController::GetInstance() { + if (!g_ibus_daemon_controller) { + if (base::chromeos::IsRunningOnChromeOS()) { + g_ibus_daemon_controller = new IBusDaemonControllerImpl(); + } else { + g_ibus_daemon_controller = new IBusDaemonControllerStubImpl(); + } + } + return g_ibus_daemon_controller; +} + +} // namespace chromeos diff --git a/chromeos/ime/ibus_daemon_controller.h b/chromeos/ime/ibus_daemon_controller.h new file mode 100644 index 0000000..faa4b52 --- /dev/null +++ b/chromeos/ime/ibus_daemon_controller.h @@ -0,0 +1,59 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROMEOS_IME_IBUS_DAEMON_CONTROLLER_H_ +#define CHROMEOS_IME_IBUS_DAEMON_CONTROLLER_H_ + +#include "base/memory/ref_counted.h" +#include "base/sequenced_task_runner.h" +#include "chromeos/chromeos_export.h" + +namespace chromeos { + +// IBusDaemonController is used to start/stop ibus-daemon process. This class is +// also watching ibus-daemon process and if it is crashed, re-launch it +// automatically. This class is managed as Singleton. +class CHROMEOS_EXPORT IBusDaemonController { + public: + class Observer { + public: + // Called when the connection with ibus-daemon is established. + virtual void OnConnected() = 0; + + // Called when the connection with ibus-daemon is lost. + virtual void OnDisconnected() = 0; + }; + + virtual ~IBusDaemonController(); + + // Initializes IBusDaemonController. ibus-daemon related file handling is + // posted to |file_task_runner|. + virtual void Initialize( + const scoped_refptr<base::SequencedTaskRunner>& ui_task_runner, + const scoped_refptr<base::SequencedTaskRunner>& file_task_runner) = 0; + + virtual void AddObserver(Observer* observer) = 0; + virtual void RemoveObserver(Observer* observer) = 0; + + // Starts ibus-daemon. + virtual bool Start() = 0; + + // Stops ibus-daemon. + virtual bool Stop() = 0; + + // Returns actual implementation of IBusDaemonController. If the browser is + // not running on the Chrome OS device, this function returns stub + // implementation. + static CHROMEOS_EXPORT IBusDaemonController* GetInstance(); + + protected: + // IBusDaemonController is managed as singleton. USe GetInstance instead. + IBusDaemonController(); + + DISALLOW_COPY_AND_ASSIGN(IBusDaemonController); +}; + +} // namespace chromeos + +#endif // CHROMEOS_IME_IBUS_DAEMON_CONTROLLER_H_ |