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

Unified Diff: Source/platform/TaskSynchronizer.h

Issue 198673002: Rename DatabaseTaskSynchronizer to TaskSynchronizer and move it to platform/ (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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
Index: Source/platform/TaskSynchronizer.h
diff --git a/Source/platform/text/StringTruncator.h b/Source/platform/TaskSynchronizer.h
similarity index 63%
copy from Source/platform/text/StringTruncator.h
copy to Source/platform/TaskSynchronizer.h
index a1aff51fe4eec987443f9424884cf1f9ab6915aa..71fd44a525d6cc5c562566ac7bc1fba669aed2e1 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 {
+ 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

Powered by Google App Engine
This is Rietveld 408576698