diff options
author | nona@chromium.org <nona@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-05 09:43:31 +0000 |
---|---|---|
committer | nona@chromium.org <nona@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-05 09:43:31 +0000 |
commit | 25fe2045a3249e4fa300a148fcbbebe566bf5145 (patch) | |
tree | 741e3388ea3ba621448e9957646d0cbda47e01c3 /chromeos/dbus | |
parent | 229c2d087843c785aac9f50ffaf78bbe1fc6cf8d (diff) | |
download | chromium_src-25fe2045a3249e4fa300a148fcbbebe566bf5145.zip chromium_src-25fe2045a3249e4fa300a148fcbbebe566bf5145.tar.gz chromium_src-25fe2045a3249e4fa300a148fcbbebe566bf5145.tar.bz2 |
Introduce IBusConfigClient with empty implementation.
The actual implementation will be done with http://codereview.chromium.org/11273114/.
BUG=158265
TEST=ran chromeos_unittests, unit_tests
Review URL: https://chromiumcodereview.appspot.com/11271040
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@165912 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos/dbus')
-rw-r--r-- | chromeos/dbus/ibus/ibus_config_client.cc | 107 | ||||
-rw-r--r-- | chromeos/dbus/ibus/ibus_config_client.h | 75 | ||||
-rw-r--r-- | chromeos/dbus/ibus/mock_ibus_config_client.cc | 39 | ||||
-rw-r--r-- | chromeos/dbus/ibus/mock_ibus_config_client.h | 45 |
4 files changed, 266 insertions, 0 deletions
diff --git a/chromeos/dbus/ibus/ibus_config_client.cc b/chromeos/dbus/ibus/ibus_config_client.cc new file mode 100644 index 0000000..b357b1c2 --- /dev/null +++ b/chromeos/dbus/ibus/ibus_config_client.cc @@ -0,0 +1,107 @@ +// 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/dbus/ibus/ibus_config_client.h" + +#include "base/bind.h" +#include "base/callback.h" +#include "chromeos/dbus/ibus/ibus_constants.h" +#include "chromeos/dbus/ibus/ibus_component.h" +#include "dbus/bus.h" +#include "dbus/message.h" +#include "dbus/object_path.h" +#include "dbus/object_proxy.h" + +namespace chromeos { + +namespace { + +// The IBusConfigClient implementation. +class IBusConfigClientImpl : public IBusConfigClient { + public: + explicit IBusConfigClientImpl(dbus::Bus* bus) { + } + + virtual ~IBusConfigClientImpl() {} + + // IBusConfigClient override. + virtual void SetStringValue(const std::string& section, + const std::string& key, + const std::string& value, + const ErrorCallback& error_callback) OVERRIDE { + } + + // IBusConfigClient override. + virtual void SetIntValue(const std::string& section, + const std::string& key, + int value, + const ErrorCallback& error_callback) OVERRIDE { + } + + // IBusConfigClient override. + virtual void SetBoolValue(const std::string& section, + const std::string& key, + bool value, + const ErrorCallback& error_callback) OVERRIDE { + } + + // IBusConfigClient override. + virtual void SetStringListValue( + const std::string& section, + const std::string& key, + const std::vector<std::string>& value, + const ErrorCallback& error_callback) OVERRIDE { + } + + private: + DISALLOW_COPY_AND_ASSIGN(IBusConfigClientImpl); +}; + +// A stub implementation of IBusConfigClient. +class IBusConfigClientStubImpl : public IBusConfigClient { + public: + IBusConfigClientStubImpl() {} + virtual ~IBusConfigClientStubImpl() {} + virtual void SetStringValue(const std::string& section, + const std::string& key, + const std::string& value, + const ErrorCallback& error_callback) OVERRIDE {} + virtual void SetIntValue(const std::string& section, + const std::string& key, + int value, + const ErrorCallback& error_callback) OVERRIDE {} + virtual void SetBoolValue(const std::string& section, + const std::string& key, + bool value, + const ErrorCallback& error_callback) OVERRIDE {} + virtual void SetStringListValue( + const std::string& section, + const std::string& key, + const std::vector<std::string>& value, + const ErrorCallback& error_callback) OVERRIDE {} + + private: + DISALLOW_COPY_AND_ASSIGN(IBusConfigClientStubImpl); +}; + +} // namespace + +/////////////////////////////////////////////////////////////////////////////// +// IBusConfigClient + +IBusConfigClient::IBusConfigClient() {} + +IBusConfigClient::~IBusConfigClient() {} + +// static +IBusConfigClient* IBusConfigClient::Create(DBusClientImplementationType type, + dbus::Bus* bus) { + if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) { + return new IBusConfigClientImpl(bus); + } + DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); + return new IBusConfigClientStubImpl(); +} + +} // namespace chromeos diff --git a/chromeos/dbus/ibus/ibus_config_client.h b/chromeos/dbus/ibus/ibus_config_client.h new file mode 100644 index 0000000..cb7e91b --- /dev/null +++ b/chromeos/dbus/ibus/ibus_config_client.h @@ -0,0 +1,75 @@ +// 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_DBUS_IBUS_IBUS_CONFIG_CLIENT_H_ +#define CHROMEOS_DBUS_IBUS_IBUS_CONFIG_CLIENT_H_ + +#include <string> +#include <vector> + +#include "base/basictypes.h" +#include "base/callback.h" +#include "chromeos/chromeos_export.h" +#include "chromeos/dbus/dbus_client_implementation_type.h" +#include "dbus/object_path.h" + +namespace dbus { +class Bus; +} // namespace dbus + +namespace chromeos { + +namespace ibus { +class IBusComponent; +} // namespace ibus + +class IBusInputContextClient; + +// A class to make the actual DBus calls for IBusConfig service. +class CHROMEOS_EXPORT IBusConfigClient { + public: + typedef base::Callback<void()> ErrorCallback; + virtual ~IBusConfigClient(); + + // Requests the IBusConfig to set a string value. + virtual void SetStringValue(const std::string& section, + const std::string& key, + const std::string& value, + const ErrorCallback& error_callback) = 0; + + // Requests the IBusConfig to set a integer value. + virtual void SetIntValue(const std::string& section, + const std::string& key, + int value, + const ErrorCallback& error_callback) = 0; + + // Requests the IBusConfig to set a boolean value. + virtual void SetBoolValue(const std::string& section, + const std::string& key, + bool value, + const ErrorCallback& error_callback) = 0; + + // Requests the IBusConfig to set multiple string values. + virtual void SetStringListValue(const std::string& section, + const std::string& key, + const std::vector<std::string>& value, + const ErrorCallback& error_callback) = 0; + + // Factory function, creates a new instance and returns ownership. + // For normal usage, access the singleton via DBusThreadManager::Get(). + static CHROMEOS_EXPORT IBusConfigClient* Create( + DBusClientImplementationType type, + dbus::Bus* bus); + + protected: + // Create() should be used instead. + IBusConfigClient(); + + private: + DISALLOW_COPY_AND_ASSIGN(IBusConfigClient); +}; + +} // namespace chromeos + +#endif // CHROMEOS_DBUS_IBUS_IBUS_CLIENT_H_ diff --git a/chromeos/dbus/ibus/mock_ibus_config_client.cc b/chromeos/dbus/ibus/mock_ibus_config_client.cc new file mode 100644 index 0000000..7baa3e6 --- /dev/null +++ b/chromeos/dbus/ibus/mock_ibus_config_client.cc @@ -0,0 +1,39 @@ +// 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/dbus/ibus/mock_ibus_config_client.h" + +namespace chromeos { + +MockIBusConfigClient::MockIBusConfigClient() { +} + +MockIBusConfigClient::~MockIBusConfigClient() {} + +void MockIBusConfigClient::SetStringValue(const std::string& key, + const std::string& section, + const std::string& value, + const ErrorCallback& error_callback) { +} + +void MockIBusConfigClient::SetIntValue(const std::string& key, + const std::string& section, + int value, + const ErrorCallback& error_callback) { +} + +void MockIBusConfigClient::SetBoolValue(const std::string& key, + const std::string& section, + bool value, + const ErrorCallback& error_callback) { +} + +void MockIBusConfigClient::SetStringListValue( + const std::string& key, + const std::string& section, + const std::vector<std::string>& value, + const ErrorCallback& error_callback) { +} + +} // namespace chromeos diff --git a/chromeos/dbus/ibus/mock_ibus_config_client.h b/chromeos/dbus/ibus/mock_ibus_config_client.h new file mode 100644 index 0000000..456a7c1 --- /dev/null +++ b/chromeos/dbus/ibus/mock_ibus_config_client.h @@ -0,0 +1,45 @@ +// 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_DBUS_IBUS_MOCK_IBUS_CONFIG_CLIENT_H_ +#define CHROMEOS_DBUS_IBUS_MOCK_IBUS_CONFIG_CLIENT_H_ + +#include <string> + +#include "chromeos/dbus/ibus/ibus_config_client.h" + +namespace chromeos { + +class MockIBusConfigClient : public IBusConfigClient { + public: + MockIBusConfigClient(); + virtual ~MockIBusConfigClient(); + + virtual void SetStringValue(const std::string& key, + const std::string& section, + const std::string& value, + const ErrorCallback& error_callback) OVERRIDE; + + virtual void SetIntValue(const std::string& key, + const std::string& section, + int value, + const ErrorCallback& error_callback) OVERRIDE; + + virtual void SetBoolValue(const std::string& key, + const std::string& section, + bool value, + const ErrorCallback& error_callback) OVERRIDE; + + virtual void SetStringListValue(const std::string& key, + const std::string& section, + const std::vector<std::string>& value, + const ErrorCallback& error_callback) OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(MockIBusConfigClient); +}; + +} // namespace chromeos + +#endif // CHROMEOS_DBUS_IBUS_MOCK_IBUS_CLIENT_H_ |