Add entry point information for extensions using old adapter
authorCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Wed, 23 Oct 2013 21:02:36 +0000 (19:02 -0200)
committerCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Wed, 23 Oct 2013 21:04:25 +0000 (19:04 -0200)
Entry point information is used by Crosswalk to know what symbols
can trigger the load of the extension, in case it decides to load on
demand. The extension name is implicitly an entry point, so we just
set the extra entry points.

This should cause no changes if the Crosswalk doesn't support the
interface for setting entry points yet -- like Crosswalk 1.

12 files changed:
bluetooth/bluetooth_context.cc
bluetooth/bluetooth_context.h
common/extension_adapter.cc
common/extension_adapter.h
download/download_context.cc
download/download_context.h
filesystem/filesystem_context.cc
filesystem/filesystem_context.h
network_bearer_selection/network_bearer_selection_context.cc
network_bearer_selection/network_bearer_selection_context.h
system_info/system_info_context.cc
system_info/system_info_context.h

index c92b0fc..6f0bae2 100644 (file)
@@ -27,6 +27,8 @@ BluetoothContext::BluetoothContext(ContextAPI* api)
 
 const char BluetoothContext::name[] = "tizen.bluetooth";
 
+const char* BluetoothContext::entry_points[] = { NULL };
+
 extern const char kSource_bluetooth_api[];
 
 const char* BluetoothContext::GetJavaScript() {
index c3b0a1e..3d0faff 100644 (file)
@@ -89,6 +89,7 @@ class BluetoothContext {
   // ExtensionAdapter implementation.
   static const char name[];
   static const char* GetJavaScript();
+  static const char* entry_points[];
   void HandleMessage(const char* message);
   void HandleSyncMessage(const char* message);
 
index c1b501a..5f3efd5 100644 (file)
@@ -5,6 +5,7 @@
 #include "common/extension_adapter.h"
 
 #include <iostream>
+#include "common/XW_Extension_EntryPoints.h"
 
 namespace {
 
@@ -13,6 +14,7 @@ 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
 
@@ -22,6 +24,7 @@ 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,
@@ -62,6 +65,15 @@ int32_t InitializeExtension(XW_Extension extension,
   }
   g_sync_messaging->Register(extension, handle_sync_message);
 
+  g_entry_points = reinterpret_cast<const XW_Internal_EntryPointsInterface*>(
+      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;
 }
 
index 76638ad..651c3fa 100644 (file)
 namespace internal {
 
 int32_t InitializeExtension(XW_Extension extension,
-                         XW_GetInterface get_interface,
-                         const char* name,
-                         const char* api,
-                         XW_CreatedInstanceCallback created,
-                         XW_DestroyedInstanceCallback destroyed,
-                         XW_HandleMessageCallback handle_message,
-                         XW_HandleSyncMessageCallback handle_sync_message);
+                            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);
@@ -65,7 +66,7 @@ template <class T>
 int32_t ExtensionAdapter<T>::Initialize(XW_Extension extension,
                                         XW_GetInterface get_interface) {
   return internal::InitializeExtension(
-      extension, get_interface, T::name, T::GetJavaScript(),
+      extension, get_interface, T::name, T::GetJavaScript(), T::entry_points,
       DidCreateInstance, DidDestroyInstance, HandleMessage, HandleSyncMessage);
 }
 
index 8142697..ec9d08a 100644 (file)
@@ -46,6 +46,11 @@ DownloadContext::~DownloadContext() {
 
 const char DownloadContext::name[] = "tizen.download";
 
+const char* DownloadContext::entry_points[] = {
+  "tizen.DownloadRequest",
+  NULL
+};
+
 // This will be generated from download_api.js.
 extern const char kSource_download_api[];
 
index 65f4a90..8461e0c 100644 (file)
@@ -27,6 +27,7 @@ class DownloadContext {
   // ExtensionAdapter implementation.
   static const char name[];
   static const char* GetJavaScript();
+  static const char* entry_points[];
   void HandleMessage(const char* message);
   void HandleSyncMessage(const char* message);
 
index 673cd83..ff62918 100644 (file)
@@ -52,6 +52,8 @@ FilesystemContext::~FilesystemContext() {
 
 const char FilesystemContext::name[] = "tizen.filesystem";
 
+const char* FilesystemContext::entry_points[] = { NULL };
+
 extern const char kSource_filesystem_api[];
 
 const char* FilesystemContext::GetJavaScript() {
index ac03f41..4dbde8d 100644 (file)
@@ -20,6 +20,7 @@ class FilesystemContext {
   /* ExtensionAdapter implementation */
   static const char name[];
   static const char* GetJavaScript();
+  static const char* entry_points[];
   void HandleMessage(const char* message);
   void HandleSyncMessage(const char* message);
 
index 260ac42..45e67b2 100644 (file)
@@ -17,6 +17,8 @@ NetworkBearerSelectionContext::NetworkBearerSelectionContext(ContextAPI* api)
 const char NetworkBearerSelectionContext::name[] =
     "tizen.networkbearerselection";
 
+const char* NetworkBearerSelectionContext::entry_points[] = { NULL };
+
 const char* NetworkBearerSelectionContext::GetJavaScript() {
   return kSource_network_bearer_selection_api;
 }
index f4dde45..4b3a8be 100644 (file)
@@ -24,6 +24,7 @@ class NetworkBearerSelectionContext {
   // ExtensionAdapter implementation.
   static const char name[];
   static const char* GetJavaScript();
+  static const char* entry_points[];
   void HandleMessage(const char* message);
   void HandleSyncMessage(const char* message) {}
 
index 61e465d..1f62973 100644 (file)
@@ -72,6 +72,7 @@ SystemInfoContext::~SystemInfoContext() {
 }
 
 const char SystemInfoContext::name[] = "tizen.systeminfo";
+const char* SystemInfoContext::entry_points[] = { NULL };
 
 // This will be generated from system_info_api.js.
 extern const char kSource_system_info_api[];
index 8db178d..7e53887 100644 (file)
@@ -29,6 +29,7 @@ class SystemInfoContext {
   // ExtensionAdapter implementation.
   static const char name[];
   static const char* GetJavaScript();
+  static const char* entry_points[];
   static SysInfoClassMap classes_;
   void HandleMessage(const char* message);
   void HandleSyncMessage(const char* message);