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

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

Issue 103473002: Manage WebSQL callbacks with OwnPtr instead of refcounting (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix RefPtr/OwnPtr transition gcc errors Created 7 years 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/modules/webdatabase/DatabaseSync.cpp ('k') | Source/modules/webdatabase/SQLStatement.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/webdatabase/SQLCallbackWrapper.h
diff --git a/Source/modules/webdatabase/SQLCallbackWrapper.h b/Source/modules/webdatabase/SQLCallbackWrapper.h
index 6343194507e994b95b217626731b9e05589f378d..e630b0af976139d80bb4bba1b99ff3494ec76db2 100644
--- a/Source/modules/webdatabase/SQLCallbackWrapper.h
+++ b/Source/modules/webdatabase/SQLCallbackWrapper.h
@@ -42,7 +42,7 @@ namespace WebCore {
// - by unwrapping and then dereferencing normally - on context thread only
template<typename T> class SQLCallbackWrapper {
public:
- SQLCallbackWrapper(PassRefPtr<T> callback, ExecutionContext* executionContext)
+ SQLCallbackWrapper(PassOwnPtr<T> callback, ExecutionContext* executionContext)
: m_callback(callback)
, m_executionContext(m_callback ? executionContext : 0)
{
@@ -57,7 +57,7 @@ public:
void clear()
{
ExecutionContext* context;
- T* callback;
+ OwnPtr<T> callback;
{
MutexLocker locker(m_mutex);
if (!m_callback) {
@@ -65,21 +65,21 @@ public:
return;
}
if (m_executionContext->isContextThread()) {
- m_callback = 0;
- m_executionContext = 0;
+ m_callback.clear();
+ m_executionContext.clear();
return;
}
context = m_executionContext.release().leakRef();
- callback = m_callback.release().leakRef();
+ callback = m_callback.release();
}
- context->postTask(SafeReleaseTask::create(callback));
+ context->postTask(SafeReleaseTask::create(callback.release()));
}
- PassRefPtr<T> unwrap()
+ PassOwnPtr<T> unwrap()
{
MutexLocker locker(m_mutex);
ASSERT(!m_callback || m_executionContext->isContextThread());
- m_executionContext = 0;
+ m_executionContext.clear();
return m_callback.release();
}
@@ -89,7 +89,7 @@ public:
private:
class SafeReleaseTask : public ExecutionContextTask {
public:
- static PassOwnPtr<SafeReleaseTask> create(T* callbackToRelease)
+ static PassOwnPtr<SafeReleaseTask> create(PassOwnPtr<T> callbackToRelease)
{
return adoptPtr(new SafeReleaseTask(callbackToRelease));
}
@@ -97,23 +97,23 @@ private:
virtual void performTask(ExecutionContext* context)
{
ASSERT(m_callbackToRelease && context && context->isContextThread());
- m_callbackToRelease->deref();
+ m_callbackToRelease.clear();
context->deref();
}
virtual bool isCleanupTask() const { return true; }
private:
- explicit SafeReleaseTask(T* callbackToRelease)
+ explicit SafeReleaseTask(PassOwnPtr<T> callbackToRelease)
: m_callbackToRelease(callbackToRelease)
{
}
- T* m_callbackToRelease;
+ OwnPtr<T> m_callbackToRelease;
};
Mutex m_mutex;
- RefPtr<T> m_callback;
+ OwnPtr<T> m_callback;
RefPtr<ExecutionContext> m_executionContext;
};
« no previous file with comments | « Source/modules/webdatabase/DatabaseSync.cpp ('k') | Source/modules/webdatabase/SQLStatement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698