Update change log and spec for wrt-plugins-tizen_0.4.20
[platform/framework/web/wrt-plugins-tizen.git] / src / Push / plugin_initializer.cpp
index b753d94..d5e506f 100644 (file)
@@ -1,73 +1,75 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
 
 
-#include <dpl/log/log.h>
-
 #include <Commons/plugin_initializer_def.h>
 #include <Commons/WrtAccess/WrtAccess.h>
-#include <Commons/Exception.h>
+
+#include <GlobalContextManager.h>
 
 #include "JSPushManager.h"
-#include "PushListenerManager.h"
 
-namespace DeviceAPI {
-namespace Push {
+#include <TimeTracer.h>
+#include <Logger.h>
 
 using namespace WrtDeviceApis;
 using namespace WrtDeviceApis::Commons;
 using namespace DeviceAPI::Common;
 
+namespace DeviceAPI {
+namespace Push {
+
 void on_widget_start_callback(int widgetId)
 {
-    LogDebug("[Tizen\\Push] on_widget_start_callback (" << widgetId << ")");
-
-       Try {
+    LogDebug("[Tizen\\Push] on_widget_start_callback (%d)", widgetId);
+       TIME_TRACER_INIT();
+    try {
         WrtAccessSingleton::Instance().initialize(widgetId);
-       } Catch (Exception) {
-               LogError("WrtAccess initialization failed");
-       }
+    } catch (...) {
+        LogError("WrtAccess initialization failed");
+    }
 }
 
 void on_widget_stop_callback(int widgetId)
 {
-    LogDebug("[Tizen\\Push] on_widget_stop_callback (" << widgetId << ")");
-
-       Try {
+    LogDebug("[Tizen\\Push] on_widget_stop_callback (%d)", widgetId);
+       TIME_TRACER_EXPORT_REPORT_TO(TIME_TRACER_EXPORT_FILE,"Push");
+       TIME_TRACER_RELEASE();
+    try {
         WrtAccessSingleton::Instance().deinitialize(widgetId);
-       } Catch (Exception) {
-               LogError("WrtAccess deinitialization failed");
-       }
+    } catch (...) {
+        LogError("WrtAccess deinitialization failed");
+    }
 }
 
 void on_frame_load_callback(const void * context)
 {
-    LogDebug("[Tizen\\Push] on_frame_load_callback (" << context << ")");
+    LogDebug("[Tizen\\Push] on_frame_load_callback (%p)", context);
+    GlobalContextManager::getInstance()->addGlobalContext(static_cast<JSContextRef>(context));
 }
 
 void on_frame_unload_callback(const void * context)
 {
-    LogDebug("[Tizen\\Push] on_frame_unload_callback (" << context << ")");
-
-       PushListenerManagerSingleton::Instance().unregisterContext(static_cast<JSContextRef>(context));
+    LogDebug("[Tizen\\Push] on_frame_unload_callback (%p)", context);
+    GlobalContextManager::getInstance()->removeGlobalContext(static_cast<JSContextRef>(context));
 }
 
 PLUGIN_ON_WIDGET_START(on_widget_start_callback)
 PLUGIN_ON_WIDGET_STOP(on_widget_stop_callback)
-
 PLUGIN_ON_FRAME_LOAD(on_frame_load_callback)
 PLUGIN_ON_FRAME_UNLOAD(on_frame_unload_callback)
 
@@ -78,6 +80,5 @@ PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
         NULL)
 PLUGIN_CLASS_MAP_END
 
-}
-}
-
+} // Push
+} // DeviceAPI