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

Unified Diff: Source/modules/webdatabase/SQLCallbackWrapper.h

Issue 311273005: Oilpan: Prepare to move AbstractSQLStatement, SQLStatement, and SQLCallbackWrapper<T> to Oilpan hea… (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 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/modules/webdatabase/SQLCallbackWrapper.h
diff --git a/Source/modules/webdatabase/SQLCallbackWrapper.h b/Source/modules/webdatabase/SQLCallbackWrapper.h
index e630b0af976139d80bb4bba1b99ff3494ec76db2..d3701d4e345aacd8ac701551c348d1a7bdece264 100644
--- a/Source/modules/webdatabase/SQLCallbackWrapper.h
+++ b/Source/modules/webdatabase/SQLCallbackWrapper.h
@@ -40,7 +40,9 @@ namespace WebCore {
// - by destructing the enclosing wrapper - on any thread
// - by calling clear() - on any thread
// - by unwrapping and then dereferencing normally - on context thread only
+// Oilpan: ~T must be thread-independent.
template<typename T> class SQLCallbackWrapper {
+ DISALLOW_ALLOCATION();
public:
SQLCallbackWrapper(PassOwnPtr<T> callback, ExecutionContext* executionContext)
: m_callback(callback)
@@ -54,8 +56,19 @@ public:
clear();
}
+ // FIXME: Oilpan: Trace m_executionContext.
+ void trace(Visitor* visitor) { }
+
void clear()
{
+#if ENABLE(OILPAN)
+ // It's safe to call ~T in non-context-thread.
+ // Implementation classes of ExecutionContext are on-heap. Their
+ // destructors are called in their owner threads.
+ MutexLocker locker(m_mutex);
+ m_callback.clear();
+ m_executionContext.clear();
+#else
ExecutionContext* context;
OwnPtr<T> callback;
{
@@ -73,6 +86,7 @@ public:
callback = m_callback.release();
}
context->postTask(SafeReleaseTask::create(callback.release()));
+#endif
}
PassOwnPtr<T> unwrap()
@@ -87,6 +101,7 @@ public:
bool hasCallback() const { return m_callback; }
private:
+#if !ENABLE(OILPAN)
class SafeReleaseTask : public ExecutionContextTask {
public:
static PassOwnPtr<SafeReleaseTask> create(PassOwnPtr<T> callbackToRelease)
@@ -111,6 +126,7 @@ private:
OwnPtr<T> m_callbackToRelease;
};
+#endif
Mutex m_mutex;
OwnPtr<T> m_callback;
« no previous file with comments | « Source/modules/webdatabase/AbstractSQLTransactionBackend.h ('k') | Source/modules/webdatabase/SQLStatement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698