Index: Source/platform/TaskSynchronizer.h |
diff --git a/Source/platform/text/StringTruncator.h b/Source/platform/TaskSynchronizer.h |
similarity index 64% |
copy from Source/platform/text/StringTruncator.h |
copy to Source/platform/TaskSynchronizer.h |
index a1aff51fe4eec987443f9424884cf1f9ab6915aa..df8aa5b0f56ab2c3512e31608b01e836a28d1b5e 100644 |
--- a/Source/platform/text/StringTruncator.h |
+++ b/Source/platform/TaskSynchronizer.h |
@@ -1,5 +1,5 @@ |
/* |
- * Copyright (C) 2005, 2006, 2007 Apple Inc. All rights reserved. |
+ * Copyright (C) 2007, 2008, 2013 Apple Inc. All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
@@ -26,25 +26,41 @@ |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
-#ifndef StringTruncator_h |
-#define StringTruncator_h |
+#ifndef TaskSynchronizer_h |
+#define TaskSynchronizer_h |
-#include "platform/PlatformExport.h" |
-#include "wtf/Forward.h" |
+#include "wtf/Noncopyable.h" |
+#include "wtf/Threading.h" |
+#include "wtf/ThreadingPrimitives.h" |
namespace WebCore { |
-class Font; |
- |
-class PLATFORM_EXPORT StringTruncator { |
+// TaskSynchronizer can be used to wait for task completion. |
+class TaskSynchronizer { |
tkent
2014/04/01 05:39:37
Need PLATFORM_EXPORT
|
+ WTF_MAKE_NONCOPYABLE(TaskSynchronizer); |
public: |
- enum EnableRoundingHacksOrNot { DisableRoundingHacks, EnableRoundingHacks }; |
+ TaskSynchronizer(); |
+ |
+ // Called from a thread that waits for the task completion. |
+ void waitForTaskCompletion(); |
+ |
+ // Called from a thread that executes the task. |
+ void taskCompleted(); |
+ |
+#ifndef NDEBUG |
+ bool hasCheckedForTermination() const { return m_hasCheckedForTermination; } |
+ void setHasCheckedForTermination() { m_hasCheckedForTermination = true; } |
+#endif |
- static String centerTruncate(const String&, float maxWidth, const Font&, EnableRoundingHacksOrNot = DisableRoundingHacks); |
- static String rightTruncate(const String&, float maxWidth, const Font&, EnableRoundingHacksOrNot = DisableRoundingHacks); |
- static float width(const String&, const Font&, EnableRoundingHacksOrNot = DisableRoundingHacks); |
+private: |
+ bool m_taskCompleted; |
+ Mutex m_synchronousMutex; |
+ ThreadCondition m_synchronousCondition; |
+#ifndef NDEBUG |
+ bool m_hasCheckedForTermination; |
+#endif |
}; |
} // namespace WebCore |
-#endif // !defined(StringTruncator_h) |
+#endif // TaskSynchronizer_h |