Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Unified Diff: Source/platform/SharedTimer.h

Issue 1162753003: Revert "Implement timers by posting delayed tasks" (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/platform/PlatformThreadData.cpp ('k') | Source/platform/SharedTimer.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/SharedTimer.h
diff --git a/Source/modules/webdatabase/sqlite/SQLiteTransaction.h b/Source/platform/SharedTimer.h
similarity index 54%
copy from Source/modules/webdatabase/sqlite/SQLiteTransaction.h
copy to Source/platform/SharedTimer.h
index d0034b8d43ea52c4fbcda4eaa88ec217b8696b0e..b9567f0bbcb20451fdbc80dd55b1dd613a60d98e 100644
--- a/Source/modules/webdatabase/sqlite/SQLiteTransaction.h
+++ b/Source/platform/SharedTimer.h
@@ -23,35 +23,53 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef SQLiteTransaction_h
-#define SQLiteTransaction_h
+#ifndef SharedTimer_h
+#define SharedTimer_h
+#include "platform/PlatformExport.h"
#include "wtf/FastAllocBase.h"
#include "wtf/Noncopyable.h"
namespace blink {
-class SQLiteDatabase;
+// Each thread has its own single instance of shared timer, which implements this interface.
+// This instance is shared by all timers in the thread.
+// Not intended to be used directly; use the Timer class instead.
+class PLATFORM_EXPORT SharedTimer {
+ WTF_MAKE_NONCOPYABLE(SharedTimer); WTF_MAKE_FAST_ALLOCATED(SharedTimer);
+public:
+ SharedTimer() { }
+ virtual ~SharedTimer() {}
+ virtual void setFiredFunction(void (*)()) = 0;
+
+ // The fire interval is in seconds relative to the current monotonic clock time.
+ virtual void setFireInterval(double) = 0;
+ virtual void stop() = 0;
+};
+
-class SQLiteTransaction {
- WTF_MAKE_NONCOPYABLE(SQLiteTransaction); WTF_MAKE_FAST_ALLOCATED(SQLiteTransaction);
+PLATFORM_EXPORT void setSharedTimerFiredFunction(void (*)());
+PLATFORM_EXPORT void setSharedTimerFireInterval(double);
+PLATFORM_EXPORT void stopSharedTimer();
+
+class PLATFORM_EXPORT MainThreadSharedTimer : public SharedTimer {
public:
- SQLiteTransaction(SQLiteDatabase& db, bool readOnly = false);
- ~SQLiteTransaction();
-
- void begin();
- void commit();
- void rollback();
- void stop();
-
- bool inProgress() const { return m_inProgress; }
- bool wasRolledBackBySqlite() const;
-private:
- SQLiteDatabase& m_db;
- bool m_inProgress;
- bool m_readOnly;
+ virtual void setFiredFunction(void (*function)()) override
+ {
+ setSharedTimerFiredFunction(function);
+ }
+
+ virtual void setFireInterval(double interval) override
+ {
+ setSharedTimerFireInterval(interval);
+ }
+
+ virtual void stop() override
+ {
+ stopSharedTimer();
+ }
};
} // namespace blink
-#endif // SQLiteTransation_H
+#endif // SharedTimer_h
« no previous file with comments | « Source/platform/PlatformThreadData.cpp ('k') | Source/platform/SharedTimer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698