Fix memory leak
[platform/core/uifw/dali-adaptor.git] / dali / internal / legacy / common / tizen-platform-abstraction.h
index 67b9a56..fe4b018 100644 (file)
@@ -1,8 +1,8 @@
-#ifndef __DALI_TIZEN_PLATFORM_ABSTRACTION_H__
-#define __DALI_TIZEN_PLATFORM_ABSTRACTION_H__
+#ifndef DALI_TIZEN_PLATFORM_ABSTRACTION_H
+#define DALI_TIZEN_PLATFORM_ABSTRACTION_H
 
 /*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 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.
  */
 
 // INTERNAL INCLUDES
+#include <dali/public-api/adaptor-framework/timer.h>
 #include <dali/public-api/dali-adaptor-common.h>
 
+
 // EXTERNAL INCLUDES
+#include <cstdint>
 #include <string>
+#include <memory>
 #include <dali/integration-api/platform-abstraction.h>
 
 namespace Dali
 {
 
+class CallbackBase;
+
 namespace TizenPlatform
 {
-
 class ResourceLoader;
 
 /**
@@ -92,18 +97,42 @@ public: // PlatformAbstraction overrides
   virtual bool SaveShaderBinaryFile( const std::string& filename, const unsigned char * buffer, unsigned int numBytes ) const;
 
   /**
+   * @copydoc PlatformAbstraction::StartTimer()
+   */
+  virtual uint32_t StartTimer( uint32_t milliseconds, CallbackBase* callback );
+
+  /**
+   * @copydoc PlatformAbstraction::CancelTimer()
+   */
+  virtual void CancelTimer ( uint32_t timerId );
+
+  /**
    * Sets path for data/resource storage.
    * @param[in] path data/resource storage path
    */
   void SetDataStoragePath( const std::string& path );
 
+  /**
+   * Clears the timers that have completed
+   */
+  void CleanupTimers();
+
 private:
 
+  struct TimerCallback;
+
+  /*
+   * Executes callback function and cleans up timer
+   */
+  void RunTimerFunction(TimerCallback& timerPtr);
+
   TizenPlatformAbstraction( const TizenPlatformAbstraction& ); ///< Undefined
   TizenPlatformAbstraction& operator=( const TizenPlatformAbstraction& ); ///< Undefined
 
   std::string mDataStoragePath;
 
+  std::vector< std::unique_ptr< TimerCallback > > mTimerPairsWaiting;
+  std::vector< std::unique_ptr< TimerCallback > > mTimerPairsSpent;
 };
 
 /**
@@ -125,4 +154,4 @@ bool SaveFile( const std::string& filename, const unsigned char * buffer, unsign
 
 }  // namespace Dali
 
-#endif // __DALI_TIZEN_PLATFORM_ABSTRACTION_H__
+#endif // DALI_TIZEN_PLATFORM_ABSTRACTION_H