diff options
author | komatsu@chromium.org <komatsu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-14 06:34:06 +0000 |
---|---|---|
committer | komatsu@chromium.org <komatsu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-14 06:34:06 +0000 |
commit | 24a0f13195a9ff4bc4f250de42755af537c613a9 (patch) | |
tree | d5e7088a360bde33e3d30649d15ab41df95dcf4f /chromeos | |
parent | 5fa9f7485a1e4b1082a0e08b8c2f1160f8ced39a (diff) | |
download | chromium_src-24a0f13195a9ff4bc4f250de42755af537c613a9.zip chromium_src-24a0f13195a9ff4bc4f250de42755af537c613a9.tar.gz chromium_src-24a0f13195a9ff4bc4f250de42755af537c613a9.tar.bz2 |
Delete IBusEngineFactoryService.
IBusEngineFactoryService is no long necessary.
BUG=317535
Review URL: https://codereview.chromium.org/68603002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@235066 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos')
-rw-r--r-- | chromeos/chromeos.gyp | 4 | ||||
-rw-r--r-- | chromeos/dbus/ibus/ibus_engine_factory_service.cc | 168 | ||||
-rw-r--r-- | chromeos/dbus/ibus/ibus_engine_factory_service.h | 59 | ||||
-rw-r--r-- | chromeos/dbus/ibus/mock_ibus_engine_factory_service.cc | 63 | ||||
-rw-r--r-- | chromeos/dbus/ibus/mock_ibus_engine_factory_service.h | 55 | ||||
-rw-r--r-- | chromeos/ime/ibus_bridge.cc | 12 | ||||
-rw-r--r-- | chromeos/ime/ibus_bridge.h | 6 |
7 files changed, 7 insertions, 360 deletions
diff --git a/chromeos/chromeos.gyp b/chromeos/chromeos.gyp index 0e5211c..ea679d2 100644 --- a/chromeos/chromeos.gyp +++ b/chromeos/chromeos.gyp @@ -172,8 +172,6 @@ 'dbus/ibus/ibus_constants.h', 'dbus/ibus/ibus_engine_service.cc', 'dbus/ibus/ibus_engine_service.h', - 'dbus/ibus/ibus_engine_factory_service.cc', - 'dbus/ibus/ibus_engine_factory_service.h', 'dbus/ibus/ibus_object.cc', 'dbus/ibus/ibus_object.h', 'dbus/ibus/ibus_text.cc', @@ -435,8 +433,6 @@ 'dbus/fake_shill_manager_client.h', 'dbus/fake_update_engine_client.cc', 'dbus/fake_update_engine_client.h', - 'dbus/ibus/mock_ibus_engine_factory_service.cc', - 'dbus/ibus/mock_ibus_engine_factory_service.h', 'dbus/ibus/mock_ibus_engine_service.cc', 'dbus/ibus/mock_ibus_engine_service.h', 'ime/fake_input_method_delegate.cc', diff --git a/chromeos/dbus/ibus/ibus_engine_factory_service.cc b/chromeos/dbus/ibus/ibus_engine_factory_service.cc deleted file mode 100644 index b43fd49..0000000 --- a/chromeos/dbus/ibus/ibus_engine_factory_service.cc +++ /dev/null @@ -1,168 +0,0 @@ -// 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_engine_factory_service.h" - -#include <map> -#include <string> - -#include "base/strings/string_number_conversions.h" -#include "chromeos/dbus/ibus/ibus_constants.h" -#include "chromeos/ime/ibus_bridge.h" -#include "dbus/bus.h" -#include "dbus/exported_object.h" -#include "dbus/message.h" - -namespace chromeos { - -namespace { -const char* kObjectPathPrefix = "/org/freedesktop/IBus/Engine/"; -} // namespace - -class IBusEngineFactoryServiceImpl : public IBusEngineFactoryService { - public: - explicit IBusEngineFactoryServiceImpl(dbus::Bus* bus) - : bus_(bus), - object_path_id_(0), - weak_ptr_factory_(this) { - exported_object_ = bus_->GetExportedObject( - dbus::ObjectPath(ibus::engine_factory::kServicePath)); - - exported_object_->ExportMethod( - ibus::engine_factory::kServiceInterface, - ibus::engine_factory::kCreateEngineMethod, - base::Bind(&IBusEngineFactoryServiceImpl::CreateEngine, - weak_ptr_factory_.GetWeakPtr()), - base::Bind(&IBusEngineFactoryServiceImpl::CreateEngineExported, - weak_ptr_factory_.GetWeakPtr())); - } - - virtual ~IBusEngineFactoryServiceImpl() { - bus_->UnregisterExportedObject(dbus::ObjectPath( - ibus::engine_factory::kServicePath)); - } - - // IBusEngineFactoryService override. - virtual void SetCreateEngineHandler( - const std::string& engine_id, - const CreateEngineHandler& create_engine_handler) OVERRIDE { - DCHECK(create_engine_callback_map_[engine_id].is_null()); - create_engine_callback_map_[engine_id] = create_engine_handler; - } - - // IBusEngineFactoryService override. - virtual void UnsetCreateEngineHandler( - const std::string& engine_id) OVERRIDE { - create_engine_callback_map_[engine_id].Reset(); - } - - // IBusEngineFactoryService override. - virtual dbus::ObjectPath GenerateUniqueObjectPath() OVERRIDE { - return dbus::ObjectPath(kObjectPathPrefix + - base::IntToString(object_path_id_++)); - } - - private: - // Called when the ibus-daemon requires new engine instance. - void CreateEngine(dbus::MethodCall* method_call, - dbus::ExportedObject::ResponseSender response_sender) { - if (!method_call) { - LOG(ERROR) << "method call does not have any arguments."; - return; - } - dbus::MessageReader reader(method_call); - std::string engine_name; - - if (!reader.PopString(&engine_name)) { - LOG(ERROR) << "Expected argument is string."; - return; - } - if (create_engine_callback_map_[engine_name].is_null()) { - LOG(WARNING) << "The CreateEngine handler for " << engine_name - << " is NULL."; - } else { - create_engine_callback_map_[engine_name].Run( - base::Bind(&IBusEngineFactoryServiceImpl::CreateEngineSendReply, - weak_ptr_factory_.GetWeakPtr(), - base::Passed(dbus::Response::FromMethodCall(method_call)), - response_sender)); - } - } - - // Sends reply message for CreateEngine method call. - void CreateEngineSendReply( - scoped_ptr<dbus::Response> response, - const dbus::ExportedObject::ResponseSender response_sender, - const dbus::ObjectPath& path) { - dbus::MessageWriter writer(response.get()); - writer.AppendObjectPath(path); - response_sender.Run(response.Pass()); - } - - // Called when the CreateEngine method is exported. - void CreateEngineExported(const std::string& interface_name, - const std::string& method_name, - bool success) { - DCHECK(success) << "Failed to export: " - << interface_name << "." << method_name; - } - - // CreateEngine method call handler. - std::map<std::string, CreateEngineHandler> create_engine_callback_map_; - - dbus::Bus* bus_; - scoped_refptr<dbus::ExportedObject> exported_object_; - uint32 object_path_id_; - base::WeakPtrFactory<IBusEngineFactoryServiceImpl> weak_ptr_factory_; - - DISALLOW_COPY_AND_ASSIGN(IBusEngineFactoryServiceImpl); -}; - -// An implementation of IBusEngineFactoryService without ibus-daemon -// interaction. Currently this class is used only on linux desktop. -// TODO(nona): Use this on ChromeOS device once crbug.com/171351 is fixed. -class IBusEngineFactoryServiceDaemonlessImpl : public IBusEngineFactoryService { - public: - IBusEngineFactoryServiceDaemonlessImpl() - : object_path_id_(0) {} - virtual ~IBusEngineFactoryServiceDaemonlessImpl() {} - - // IBusEngineFactoryService override. - virtual void SetCreateEngineHandler( - const std::string& engine_id, - const CreateEngineHandler& create_engine_handler) OVERRIDE { - IBusBridge::Get()->SetCreateEngineHandler(engine_id, create_engine_handler); - } - - // IBusEngineFactoryService override. - virtual void UnsetCreateEngineHandler( - const std::string& engine_id) OVERRIDE { - IBusBridge::Get()->UnsetCreateEngineHandler(engine_id); - } - - // IBusEngineFactoryService override. - virtual dbus::ObjectPath GenerateUniqueObjectPath() OVERRIDE { - // ObjectPath is not used in non-ibus-daemon implementation. Passing dummy - // valid and unique dummy object path. - return dbus::ObjectPath("/dummy/object/path" + - base::IntToString(object_path_id_++)); - } - - private: - uint32 object_path_id_; - DISALLOW_COPY_AND_ASSIGN(IBusEngineFactoryServiceDaemonlessImpl); -}; - -IBusEngineFactoryService::IBusEngineFactoryService() { -} - -IBusEngineFactoryService::~IBusEngineFactoryService() { -} - -// static -IBusEngineFactoryService* IBusEngineFactoryService::Create() { - return new IBusEngineFactoryServiceDaemonlessImpl(); -} - -} // namespace chromeos diff --git a/chromeos/dbus/ibus/ibus_engine_factory_service.h b/chromeos/dbus/ibus/ibus_engine_factory_service.h deleted file mode 100644 index 868be1a..0000000 --- a/chromeos/dbus/ibus/ibus_engine_factory_service.h +++ /dev/null @@ -1,59 +0,0 @@ -// 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_ENGINE_FACTORY_SERVICE_H_ -#define CHROMEOS_DBUS_IBUS_IBUS_ENGINE_FACTORY_SERVICE_H_ - -#include <string> -#include "base/bind.h" -#include "base/callback.h" -#include "chromeos/chromeos_export.h" - -namespace dbus { -class Bus; -class ObjectPath; -} // namespace dbus - -namespace chromeos { - -// A class to make the actual DBus method call handling for IBusEngineFactory -// service. The exported method call is used by ibus-daemon to create engine -// service if the extension IME is enabled. -class CHROMEOS_EXPORT IBusEngineFactoryService { - public: - typedef base::Callback<void(const dbus::ObjectPath& path)> - CreateEngineResponseSender; - typedef base::Callback<void(const CreateEngineResponseSender& sender)> - CreateEngineHandler; - - virtual ~IBusEngineFactoryService(); - - // Sets CreateEngine method call handler for |engine_id|. If ibus-daemon calls - // CreateEngine message with |engine_id|, the |create_engine_handler| will be - // called. - virtual void SetCreateEngineHandler( - const std::string& engine_id, - const CreateEngineHandler& create_engine_handler) = 0; - - // Unsets CreateEngine method call handler for |engine_id|. - virtual void UnsetCreateEngineHandler(const std::string& engine_id) = 0; - - // Generates object path which is unique among all EngineServices. - virtual dbus::ObjectPath GenerateUniqueObjectPath() = 0; - - // Factory function, creates a new instance and returns ownership. - // For normal usage, accesses the singleton via DBusThreadManager::Get(). - static CHROMEOS_EXPORT IBusEngineFactoryService* Create(); - - protected: - // Create() should be used instead. - IBusEngineFactoryService(); - - private: - DISALLOW_COPY_AND_ASSIGN(IBusEngineFactoryService); -}; - -} // namespace chromeos - -#endif // CHROMEOS_DBUS_IBUS_IBUS_ENGINE_FACTORY_SERVICE_H_ diff --git a/chromeos/dbus/ibus/mock_ibus_engine_factory_service.cc b/chromeos/dbus/ibus/mock_ibus_engine_factory_service.cc deleted file mode 100644 index b419118..0000000 --- a/chromeos/dbus/ibus/mock_ibus_engine_factory_service.cc +++ /dev/null @@ -1,63 +0,0 @@ -// 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_engine_factory_service.h" - -#include "base/bind.h" - -namespace chromeos { - -MockIBusEngineFactoryService::MockIBusEngineFactoryService() - : set_create_engine_handler_call_count_(0), - unset_create_engine_handler_call_count_(0), - weak_ptr_factory_(this) { -} - -MockIBusEngineFactoryService::~MockIBusEngineFactoryService() { -} - -void MockIBusEngineFactoryService::SetCreateEngineHandler( - const std::string& engine_id, - const CreateEngineHandler& create_engine_handler) { - handler_map_[engine_id] = create_engine_handler; - set_create_engine_handler_call_count_++; -} - -void MockIBusEngineFactoryService::UnsetCreateEngineHandler( - const std::string& engine_id) { - unset_create_engine_handler_call_count_++; - handler_map_[engine_id].Reset(); -} - -dbus::ObjectPath MockIBusEngineFactoryService::GenerateUniqueObjectPath() { - return dbus::ObjectPath("/org/freedesktop/IBus/Engine/1"); -} - -bool MockIBusEngineFactoryService::CallCreateEngine( - const std::string& engine_id) { - if (handler_map_.find(engine_id) != handler_map_.end() && - !handler_map_[engine_id].is_null()) { - handler_map_[engine_id].Run( - base::Bind(&MockIBusEngineFactoryService::OnEngineCreated, - weak_ptr_factory_.GetWeakPtr(), - engine_id)); - return true; - } - return false; -} - -dbus::ObjectPath MockIBusEngineFactoryService::GetObjectPathByEngineId( - const std::string& engine_id) { - if (object_path_map_.find(engine_id) != object_path_map_.end()) - return dbus::ObjectPath(); - return object_path_map_[engine_id]; -} - -void MockIBusEngineFactoryService::OnEngineCreated( - const std::string& engine_id, - const dbus::ObjectPath& path) { - object_path_map_[engine_id] = path; -} - -} // namespace chromeos diff --git a/chromeos/dbus/ibus/mock_ibus_engine_factory_service.h b/chromeos/dbus/ibus/mock_ibus_engine_factory_service.h deleted file mode 100644 index 7fbb11d..0000000 --- a/chromeos/dbus/ibus/mock_ibus_engine_factory_service.h +++ /dev/null @@ -1,55 +0,0 @@ -// 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_ENGINE_FACTORY_SERVICE_H_ -#define CHROMEOS_DBUS_IBUS_MOCK_IBUS_ENGINE_FACTORY_SERVICE_H_ - -#include <map> -#include <string> -#include "base/basictypes.h" -#include "base/memory/weak_ptr.h" -#include "chromeos/dbus/ibus/ibus_engine_factory_service.h" -#include "dbus/object_path.h" - -namespace chromeos { -class MockIBusEngineFactoryService : public IBusEngineFactoryService { - public: - MockIBusEngineFactoryService(); - virtual ~MockIBusEngineFactoryService(); - - virtual void SetCreateEngineHandler( - const std::string& engine_id, - const CreateEngineHandler& create_engine_handler) OVERRIDE; - virtual void UnsetCreateEngineHandler( - const std::string& engine_id) OVERRIDE; - virtual dbus::ObjectPath GenerateUniqueObjectPath() OVERRIDE; - - bool CallCreateEngine(const std::string& engine_id); - - int set_create_engine_handler_call_count() const { - return set_create_engine_handler_call_count_; - } - - int unset_create_engine_handler_call_count() const { - return unset_create_engine_handler_call_count_; - } - - dbus::ObjectPath GetObjectPathByEngineId(const std::string& engine_id); - - private: - void OnEngineCreated(const std::string& engine_id, - const dbus::ObjectPath& path); - - std::map<std::string, CreateEngineHandler> handler_map_; - std::map<std::string, dbus::ObjectPath> object_path_map_; - int set_create_engine_handler_call_count_; - int unset_create_engine_handler_call_count_; - base::WeakPtrFactory<MockIBusEngineFactoryService> weak_ptr_factory_; - - DISALLOW_COPY_AND_ASSIGN(MockIBusEngineFactoryService); -}; - -} // namespace chromeos - -#endif // CHROMEOS_DBUS_IBUS_MOCK_IBUS_ENGINE_FACTORY_SERVICE_H_ diff --git a/chromeos/ime/ibus_bridge.cc b/chromeos/ime/ibus_bridge.cc index 9de5569..a52f6cd 100644 --- a/chromeos/ime/ibus_bridge.cc +++ b/chromeos/ime/ibus_bridge.cc @@ -10,10 +10,6 @@ namespace chromeos { -namespace { -void NoOpCreateEngineReply(const dbus::ObjectPath& unused_path) {} -} // namespace - static IBusBridge* g_ibus_bridge = NULL; // An implementation of IBusBridge. @@ -77,7 +73,7 @@ class IBusBridgeImpl : public IBusBridge { virtual void SetCreateEngineHandler( const std::string& engine_id, - const IBusEngineFactoryService::CreateEngineHandler& handler) OVERRIDE { + const CreateEngineHandler& handler) OVERRIDE { create_engine_handler_map_[engine_id] = handler; } @@ -92,8 +88,7 @@ class IBusBridgeImpl : public IBusBridge { // migrated to extension IME. if (create_engine_handler_map_[engine_id].is_null()) return; - create_engine_handler_map_[engine_id].Run( - base::Bind(&NoOpCreateEngineReply)); + create_engine_handler_map_[engine_id].Run(); } private: @@ -101,8 +96,7 @@ class IBusBridgeImpl : public IBusBridge { IBusEngineHandlerInterface* engine_handler_; IBusPanelCandidateWindowHandlerInterface* candidate_window_handler_; IBusPanelPropertyHandlerInterface* panel_handler_; - std::map<std::string, IBusEngineFactoryService::CreateEngineHandler> - create_engine_handler_map_; + std::map<std::string, CreateEngineHandler> create_engine_handler_map_; DISALLOW_COPY_AND_ASSIGN(IBusBridgeImpl); }; diff --git a/chromeos/ime/ibus_bridge.h b/chromeos/ime/ibus_bridge.h index 3efb988..fc193ea 100644 --- a/chromeos/ime/ibus_bridge.h +++ b/chromeos/ime/ibus_bridge.h @@ -8,8 +8,8 @@ #include <string> #include "base/basictypes.h" +#include "base/callback.h" #include "chromeos/chromeos_export.h" -#include "chromeos/dbus/ibus/ibus_engine_factory_service.h" #include "chromeos/ime/ime_constants.h" #include "chromeos/ime/input_method_property.h" @@ -176,6 +176,8 @@ class CHROMEOS_EXPORT IBusPanelPropertyHandlerInterface { // or EngineService) directly by using this class. class IBusBridge { public: + typedef base::Callback<void()> CreateEngineHandler; + virtual ~IBusBridge(); // Allocates the global instance. Must be called before any calls to Get(). @@ -227,7 +229,7 @@ class IBusBridge { // and |handler| must not be null. virtual void SetCreateEngineHandler( const std::string& engine_id, - const IBusEngineFactoryService::CreateEngineHandler& handler) = 0; + const CreateEngineHandler& handler) = 0; // Unsets create engine handler for |engine_id|. |engine_id| must not be // empty. |