From: Halton Huo Date: Tue, 3 Jun 2014 10:26:30 +0000 (+0800) Subject: Remove deperacated wrapper ExtensionAdapter X-Git-Tag: accepted/tizen/common/20140630.080101~18^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=59f6554d9927e4ec938488e39c9c96f655b1f9ef;p=platform%2Fframework%2Fweb%2Ftizen-extensions-crosswalk.git Remove deperacated wrapper ExtensionAdapter --- diff --git a/application/application.gyp b/application/application.gyp index 0cf4f5a..780dda2 100644 --- a/application/application.gyp +++ b/application/application.gyp @@ -7,8 +7,6 @@ 'target_name': 'tizen_application', 'type': 'loadable_module', 'sources': [ - '../common/extension.cc', - '../common/extension.h', 'application.cc', 'application.h', 'application_api.js', diff --git a/bluetooth/bluetooth.gyp b/bluetooth/bluetooth.gyp index 727cf34..b4db8b2 100644 --- a/bluetooth/bluetooth.gyp +++ b/bluetooth/bluetooth.gyp @@ -17,8 +17,6 @@ '../common/pkg-config.gypi', ], 'sources': [ - '../common/extension.cc', - '../common/extension.h', 'bluetooth_api.js', 'bluetooth_extension.cc', 'bluetooth_extension.h', diff --git a/bookmark/bookmark.gyp b/bookmark/bookmark.gyp index 8180881..20626bc 100644 --- a/bookmark/bookmark.gyp +++ b/bookmark/bookmark.gyp @@ -15,8 +15,6 @@ 'bookmark_extension.h', 'bookmark_instance.cc', 'bookmark_instance.h', - '../common/extension.h', - '../common/extension.cc', ], # Evas.h is used in favorites.h. diff --git a/callhistory/callhistory.gyp b/callhistory/callhistory.gyp index 1e2b33d..480e994 100644 --- a/callhistory/callhistory.gyp +++ b/callhistory/callhistory.gyp @@ -23,8 +23,6 @@ 'callhistory.h', 'callhistory_mobile.cc', 'callhistory_props.h', - '../common/extension.cc', - '../common/extension.h', ], }], ], diff --git a/common/common.gypi b/common/common.gypi index 7b5e045..1bd688b 100644 --- a/common/common.gypi +++ b/common/common.gypi @@ -64,8 +64,8 @@ '<(SHARED_INTERMEDIATE_DIR)', ], 'sources': [ - 'extension_adapter.cc', - 'extension_adapter.h', + 'extension.cc', + 'extension.h', 'picojson.h', 'utils.h', 'XW_Extension.h', diff --git a/common/extension_adapter.cc b/common/extension_adapter.cc deleted file mode 100644 index 5f3efd5..0000000 --- a/common/extension_adapter.cc +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright (c) 2013 Intel Corporation. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "common/extension_adapter.h" - -#include -#include "common/XW_Extension_EntryPoints.h" - -namespace { - -XW_Extension g_extension = 0; - -const XW_CoreInterface* g_core = NULL; -const XW_MessagingInterface* g_messaging = NULL; -const XW_Internal_SyncMessagingInterface* g_sync_messaging = NULL; -const XW_Internal_EntryPointsInterface* g_entry_points = NULL; - -} // namespace - -namespace internal { - -int32_t InitializeExtension(XW_Extension extension, - XW_GetInterface get_interface, - const char* name, - const char* api, - const char** entry_points, - XW_CreatedInstanceCallback created, - XW_DestroyedInstanceCallback destroyed, - XW_HandleMessageCallback handle_message, - XW_HandleSyncMessageCallback handle_sync_message) { - if (g_extension != 0) { - std::cerr << "Can't initialize same extension multiple times!\n"; - return XW_ERROR; - } - - g_extension = extension; - - g_core = reinterpret_cast( - get_interface(XW_CORE_INTERFACE)); - if (!g_core) { - std::cerr << "Can't initialize extension: error getting Core interface.\n"; - return XW_ERROR; - } - g_core->SetExtensionName(extension, name); - g_core->SetJavaScriptAPI(extension, api); - g_core->RegisterInstanceCallbacks(extension, created, destroyed); - - g_messaging = reinterpret_cast( - get_interface(XW_MESSAGING_INTERFACE)); - if (!g_messaging) { - std::cerr << - "Can't initialize extension: error getting Messaging interface.\n"; - return XW_ERROR; - } - g_messaging->Register(extension, handle_message); - - g_sync_messaging = - reinterpret_cast( - get_interface(XW_INTERNAL_SYNC_MESSAGING_INTERFACE)); - if (!g_sync_messaging) { - std::cerr << - "Can't initialize extension: error getting Messaging interface.\n"; - return XW_ERROR; - } - g_sync_messaging->Register(extension, handle_sync_message); - - g_entry_points = reinterpret_cast( - get_interface(XW_INTERNAL_ENTRY_POINTS_INTERFACE)); - if (!g_entry_points) { - std::cerr << "NOTE: Entry points interface not available in this version " - << "of Crosswalk, ignoring entry point data for extensions.\n"; - } else { - g_entry_points->SetExtraJSEntryPoints(extension, entry_points); - } - - return XW_OK; -} - -void PostMessage(XW_Instance instance, const char* message) { - g_messaging->PostMessage(instance, message); -} - -void SetSyncReply(XW_Instance instance, const char* reply) { - g_sync_messaging->SetSyncReply(instance, reply); -} - -} // namespace internal diff --git a/common/extension_adapter.h b/common/extension_adapter.h deleted file mode 100644 index 651c3fa..0000000 --- a/common/extension_adapter.h +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright (c) 2013 Intel Corporation. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef COMMON_EXTENSION_ADAPTER_H_ -#define COMMON_EXTENSION_ADAPTER_H_ - -#include -#include -#include "common/XW_Extension.h" -#include "common/XW_Extension_SyncMessage.h" - -namespace internal { - -int32_t InitializeExtension(XW_Extension extension, - XW_GetInterface get_interface, - const char* name, - const char* api, - const char** entry_points, - XW_CreatedInstanceCallback created, - XW_DestroyedInstanceCallback destroyed, - XW_HandleMessageCallback handle_message, - XW_HandleSyncMessageCallback handle_sync_message); - -void PostMessage(XW_Instance instance, const char* message); -void SetSyncReply(XW_Instance instance, const char* reply); - -} // namespace internal - -class ContextAPI { - public: - explicit ContextAPI(XW_Instance instance) : instance_(instance) {} - - void PostMessage(const char* message) { - internal::PostMessage(instance_, message); - } - void SetSyncReply(const char* reply) { - internal::SetSyncReply(instance_, reply); - } - - private: - XW_Instance instance_; -}; - -template -class ExtensionAdapter { - public: - static int32_t Initialize(XW_Extension extension, - XW_GetInterface get_interface); - - private: - static void DidCreateInstance(XW_Instance instance); - static void DidDestroyInstance(XW_Instance instance); - - static void HandleMessage(XW_Instance instance, const char* message); - static void HandleSyncMessage(XW_Instance instance, const char* message); - - typedef std::map InstanceMap; - static InstanceMap g_instances; -}; - -template -typename ExtensionAdapter::InstanceMap ExtensionAdapter::g_instances; - -template -int32_t ExtensionAdapter::Initialize(XW_Extension extension, - XW_GetInterface get_interface) { - return internal::InitializeExtension( - extension, get_interface, T::name, T::GetJavaScript(), T::entry_points, - DidCreateInstance, DidDestroyInstance, HandleMessage, HandleSyncMessage); -} - -template -void ExtensionAdapter::DidCreateInstance(XW_Instance instance) { - g_instances[instance] = new T(new ContextAPI(instance)); -} - -template -void ExtensionAdapter::DidDestroyInstance(XW_Instance instance) { - delete g_instances[instance]; - g_instances.erase(instance); -} - -template -void ExtensionAdapter::HandleMessage(XW_Instance instance, - const char* message) { - g_instances[instance]->HandleMessage(message); -} - - -template -void ExtensionAdapter::HandleSyncMessage(XW_Instance instance, - const char* message) { - g_instances[instance]->HandleSyncMessage(message); -} - -#define DEFINE_XWALK_EXTENSION(NAME) \ - int32_t XW_Initialize(XW_Extension extension, \ - XW_GetInterface get_interface) { \ - return ExtensionAdapter::Initialize(extension, get_interface); \ - } - -#endif // COMMON_EXTENSION_ADAPTER_H_ diff --git a/content/content.gyp b/content/content.gyp index c6fcf71..1d6a63b 100644 --- a/content/content.gyp +++ b/content/content.gyp @@ -19,8 +19,6 @@ 'content_filter.h', 'content_instance.cc', 'content_instance.h', - '../common/extension.cc', - '../common/extension.h', ], 'includes': [ '../common/pkg-config.gypi', diff --git a/download/download.gyp b/download/download.gyp index 7c66428..9ef1cfb 100644 --- a/download/download.gyp +++ b/download/download.gyp @@ -7,8 +7,6 @@ 'target_name': 'tizen_download', 'type': 'loadable_module', 'sources': [ - '../common/extension.cc', - '../common/extension.h', 'download_api.js', 'download_extension.cc', 'download_extension.h', diff --git a/filesystem/filesystem.gyp b/filesystem/filesystem.gyp index 8efc984..0f711a3 100644 --- a/filesystem/filesystem.gyp +++ b/filesystem/filesystem.gyp @@ -13,8 +13,6 @@ ], }, 'sources': [ - '../common/extension.cc', - '../common/extension.h', 'filesystem_api.js', 'filesystem_extension.cc', 'filesystem_extension.h', diff --git a/mediaserver/mediaserver.gyp b/mediaserver/mediaserver.gyp index 3ef371d..7c9b437 100644 --- a/mediaserver/mediaserver.gyp +++ b/mediaserver/mediaserver.gyp @@ -28,8 +28,6 @@ 'mediaserver_instance.h', 'mediaserver_manager.cc', 'mediaserver_manager.h', - '../common/extension.cc', - '../common/extension.h', ], 'includes': [ '../common/pkg-config.gypi', diff --git a/messageport/messageport.gyp b/messageport/messageport.gyp index 8ca1606..6488774 100644 --- a/messageport/messageport.gyp +++ b/messageport/messageport.gyp @@ -21,8 +21,6 @@ 'messageport_extension.h', 'messageport_instance.cc', 'messageport_instance.h', - '../common/extension.cc', - '../common/extension.h', ], }, ], diff --git a/network_bearer_selection/network_bearer_selection.gyp b/network_bearer_selection/network_bearer_selection.gyp index 1e90327..38f6111 100644 --- a/network_bearer_selection/network_bearer_selection.gyp +++ b/network_bearer_selection/network_bearer_selection.gyp @@ -7,8 +7,6 @@ 'target_name': 'tizen_network_bearer_selection', 'type': 'loadable_module', 'sources': [ - '../common/extension.cc', - '../common/extension.h', 'network_bearer_selection_api.js', 'network_bearer_selection_connection_tizen.cc', 'network_bearer_selection_connection_tizen.h', diff --git a/notification/notification.gyp b/notification/notification.gyp index 5f9aa90..d4b3636 100644 --- a/notification/notification.gyp +++ b/notification/notification.gyp @@ -23,8 +23,6 @@ 'notification_parameters.h', 'picojson_helpers.cc', 'picojson_helpers.h', - '../common/extension.h', - '../common/extension.cc', ], 'conditions': [ diff --git a/power/power.gyp b/power/power.gyp index 5db284e..991e944 100644 --- a/power/power.gyp +++ b/power/power.gyp @@ -17,8 +17,6 @@ 'power_instance_tizen.cc', 'power_instance_tizen.h', 'power_types.h', - '../common/extension.h', - '../common/extension.cc', ], 'includes': [ '../common/pkg-config.gypi', diff --git a/speech/speech.gyp b/speech/speech.gyp index 897552e..95d5555 100644 --- a/speech/speech.gyp +++ b/speech/speech.gyp @@ -28,8 +28,6 @@ 'speech_extension.h', 'speech_instance.cc', 'speech_instance.h', - '../common/extension.cc', - '../common/extension.h', ], }, { diff --git a/system_info/system_info.gyp b/system_info/system_info.gyp index 3b77757..a6cb437 100644 --- a/system_info/system_info.gyp +++ b/system_info/system_info.gyp @@ -102,8 +102,6 @@ 'system_info_wifi_network.h', 'system_info_wifi_network_desktop.cc', 'system_info_wifi_network_tizen.cc', - '../common/extension.cc', - '../common/extension.h', ], }, ], diff --git a/system_setting/system_setting.gyp b/system_setting/system_setting.gyp index b16d21a..fb95789 100644 --- a/system_setting/system_setting.gyp +++ b/system_setting/system_setting.gyp @@ -14,8 +14,6 @@ 'system_setting_instance.h', 'system_setting_instance_desktop.cc', 'system_setting_instance_tizen.cc', - '../common/extension.h', - '../common/extension.cc', ], 'conditions': [ ['tizen == 1', { diff --git a/time/time.gyp b/time/time.gyp index 651bff1..638ac5b 100644 --- a/time/time.gyp +++ b/time/time.gyp @@ -20,8 +20,6 @@ 'time_extension.h', 'time_instance.cc', 'time_instance.h', - '../common/extension.h', - '../common/extension.cc', ], 'conditions': [ [ 'tizen == 1', { diff --git a/tizen/tizen.gyp b/tizen/tizen.gyp index c434cff..fe811e8 100644 --- a/tizen/tizen.gyp +++ b/tizen/tizen.gyp @@ -11,8 +11,6 @@ 'tizen_api.js', 'tizen_extension.cc', 'tizen_extension.h', - '../common/extension.cc', - '../common/extension.h', ], }, ], diff --git a/utils/utils.gyp b/utils/utils.gyp index 0133bf5..cb3480f 100644 --- a/utils/utils.gyp +++ b/utils/utils.gyp @@ -10,8 +10,6 @@ 'utils_api.js', 'utils_extension.cc', 'utils_extension.h', - '../common/extension.cc', - '../common/extension.h', ], }, ],