Commit cb0f1c1b authored by haraken@chromium.org's avatar haraken@chromium.org

Oilpan: Move ThreadableWebSocketChannelClientWrapper to Oilpan's heap

This is a preparation for moving WebSocketChannelClient to the heap.

This CL adds a template specialization to CrossThreadCopier.h so that ThreadableWebSocketChannelClientWrapper* can be passed to createCallbackTask().

BUG=340522

Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=174956

Review URL: https://codereview.chromium.org/267323004

git-svn-id: svn://svn.chromium.org/blink/trunk@175782 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent bf70ca39
...@@ -57,8 +57,14 @@ template<typename T> struct CrossThreadTaskTraits<PassOwnPtr<T> > { ...@@ -57,8 +57,14 @@ template<typename T> struct CrossThreadTaskTraits<PassOwnPtr<T> > {
typedef PassOwnPtr<T> ParamType; typedef PassOwnPtr<T> ParamType;
}; };
// FIXME: Oilpan: Using a RawPtr is not safe.
// We need to move ExecutionContextTask to the heap and make this a Member.
template<typename T> struct CrossThreadTaskTraits<RawPtr<T> > {
typedef RawPtr<T> ParamType;
};
template<typename P1, typename MP1> template<typename P1, typename MP1>
class CrossThreadTask1 : public ExecutionContextTask { class GC_PLUGIN_IGNORE("crbug.com/378192") CrossThreadTask1 : public ExecutionContextTask {
public: public:
typedef void (*Method)(ExecutionContext*, MP1); typedef void (*Method)(ExecutionContext*, MP1);
typedef CrossThreadTask1<P1, MP1> CrossThreadTask; typedef CrossThreadTask1<P1, MP1> CrossThreadTask;
...@@ -87,7 +93,7 @@ private: ...@@ -87,7 +93,7 @@ private:
}; };
template<typename P1, typename MP1, typename P2, typename MP2> template<typename P1, typename MP1, typename P2, typename MP2>
class CrossThreadTask2 : public ExecutionContextTask { class GC_PLUGIN_IGNORE("crbug.com/378192") CrossThreadTask2 : public ExecutionContextTask {
public: public:
typedef void (*Method)(ExecutionContext*, MP1, MP2); typedef void (*Method)(ExecutionContext*, MP1, MP2);
typedef CrossThreadTask2<P1, MP1, P2, MP2> CrossThreadTask; typedef CrossThreadTask2<P1, MP1, P2, MP2> CrossThreadTask;
...@@ -119,7 +125,7 @@ private: ...@@ -119,7 +125,7 @@ private:
}; };
template<typename P1, typename MP1, typename P2, typename MP2, typename P3, typename MP3> template<typename P1, typename MP1, typename P2, typename MP2, typename P3, typename MP3>
class CrossThreadTask3 : public ExecutionContextTask { class GC_PLUGIN_IGNORE("crbug.com/378192") CrossThreadTask3 : public ExecutionContextTask {
public: public:
typedef void (*Method)(ExecutionContext*, MP1, MP2, MP3); typedef void (*Method)(ExecutionContext*, MP1, MP2, MP3);
typedef CrossThreadTask3<P1, MP1, P2, MP2, P3, MP3> CrossThreadTask; typedef CrossThreadTask3<P1, MP1, P2, MP2, P3, MP3> CrossThreadTask;
...@@ -154,7 +160,7 @@ private: ...@@ -154,7 +160,7 @@ private:
}; };
template<typename P1, typename MP1, typename P2, typename MP2, typename P3, typename MP3, typename P4, typename MP4> template<typename P1, typename MP1, typename P2, typename MP2, typename P3, typename MP3, typename P4, typename MP4>
class CrossThreadTask4 : public ExecutionContextTask { class GC_PLUGIN_IGNORE("crbug.com/378192") CrossThreadTask4 : public ExecutionContextTask {
public: public:
typedef void (*Method)(ExecutionContext*, MP1, MP2, MP3, MP4); typedef void (*Method)(ExecutionContext*, MP1, MP2, MP3, MP4);
typedef CrossThreadTask4<P1, MP1, P2, MP2, P3, MP3, P4, MP4> CrossThreadTask; typedef CrossThreadTask4<P1, MP1, P2, MP2, P3, MP3, P4, MP4> CrossThreadTask;
...@@ -192,7 +198,7 @@ private: ...@@ -192,7 +198,7 @@ private:
}; };
template<typename P1, typename MP1, typename P2, typename MP2, typename P3, typename MP3, typename P4, typename MP4, typename P5, typename MP5> template<typename P1, typename MP1, typename P2, typename MP2, typename P3, typename MP3, typename P4, typename MP4, typename P5, typename MP5>
class CrossThreadTask5 : public ExecutionContextTask { class GC_PLUGIN_IGNORE("crbug.com/378192") CrossThreadTask5 : public ExecutionContextTask {
public: public:
typedef void (*Method)(ExecutionContext*, MP1, MP2, MP3, MP4, MP5); typedef void (*Method)(ExecutionContext*, MP1, MP2, MP3, MP4, MP5);
typedef CrossThreadTask5<P1, MP1, P2, MP2, P3, MP3, P4, MP4, P5, MP5> CrossThreadTask; typedef CrossThreadTask5<P1, MP1, P2, MP2, P3, MP3, P4, MP4, P5, MP5> CrossThreadTask;
...@@ -233,7 +239,7 @@ private: ...@@ -233,7 +239,7 @@ private:
}; };
template<typename P1, typename MP1, typename P2, typename MP2, typename P3, typename MP3, typename P4, typename MP4, typename P5, typename MP5, typename P6, typename MP6> template<typename P1, typename MP1, typename P2, typename MP2, typename P3, typename MP3, typename P4, typename MP4, typename P5, typename MP5, typename P6, typename MP6>
class CrossThreadTask6 : public ExecutionContextTask { class GC_PLUGIN_IGNORE("crbug.com/378192") CrossThreadTask6 : public ExecutionContextTask {
public: public:
typedef void (*Method)(ExecutionContext*, MP1, MP2, MP3, MP4, MP5, MP6); typedef void (*Method)(ExecutionContext*, MP1, MP2, MP3, MP4, MP5, MP6);
typedef CrossThreadTask6<P1, MP1, P2, MP2, P3, MP3, P4, MP4, P5, MP5, P6, MP6> CrossThreadTask; typedef CrossThreadTask6<P1, MP1, P2, MP2, P3, MP3, P4, MP4, P5, MP5, P6, MP6> CrossThreadTask;
...@@ -277,7 +283,7 @@ private: ...@@ -277,7 +283,7 @@ private:
}; };
template<typename P1, typename MP1, typename P2, typename MP2, typename P3, typename MP3, typename P4, typename MP4, typename P5, typename MP5, typename P6, typename MP6, typename P7, typename MP7> template<typename P1, typename MP1, typename P2, typename MP2, typename P3, typename MP3, typename P4, typename MP4, typename P5, typename MP5, typename P6, typename MP6, typename P7, typename MP7>
class CrossThreadTask7 : public ExecutionContextTask { class GC_PLUGIN_IGNORE("crbug.com/378192") CrossThreadTask7 : public ExecutionContextTask {
public: public:
typedef void (*Method)(ExecutionContext*, MP1, MP2, MP3, MP4, MP5, MP6, MP7); typedef void (*Method)(ExecutionContext*, MP1, MP2, MP3, MP4, MP5, MP6, MP7);
typedef CrossThreadTask7<P1, MP1, P2, MP2, P3, MP3, P4, MP4, P5, MP5, P6, MP6, P7, MP7> CrossThreadTask; typedef CrossThreadTask7<P1, MP1, P2, MP2, P3, MP3, P4, MP4, P5, MP5, P6, MP6, P7, MP7> CrossThreadTask;
...@@ -324,7 +330,7 @@ private: ...@@ -324,7 +330,7 @@ private:
}; };
template<typename P1, typename MP1, typename P2, typename MP2, typename P3, typename MP3, typename P4, typename MP4, typename P5, typename MP5, typename P6, typename MP6, typename P7, typename MP7, typename P8, typename MP8> template<typename P1, typename MP1, typename P2, typename MP2, typename P3, typename MP3, typename P4, typename MP4, typename P5, typename MP5, typename P6, typename MP6, typename P7, typename MP7, typename P8, typename MP8>
class CrossThreadTask8 : public ExecutionContextTask { class GC_PLUGIN_IGNORE("crbug.com/378192") CrossThreadTask8 : public ExecutionContextTask {
public: public:
typedef void (*Method)(ExecutionContext*, MP1, MP2, MP3, MP4, MP5, MP6, MP7, MP8); typedef void (*Method)(ExecutionContext*, MP1, MP2, MP3, MP4, MP5, MP6, MP7, MP8);
typedef CrossThreadTask8<P1, MP1, P2, MP2, P3, MP3, P4, MP4, P5, MP5, P6, MP6, P7, MP7, P8, MP8> CrossThreadTask; typedef CrossThreadTask8<P1, MP1, P2, MP2, P3, MP3, P4, MP4, P5, MP5, P6, MP6, P7, MP7, P8, MP8> CrossThreadTask;
......
...@@ -45,9 +45,13 @@ ThreadableWebSocketChannelClientWrapper::ThreadableWebSocketChannelClientWrapper ...@@ -45,9 +45,13 @@ ThreadableWebSocketChannelClientWrapper::ThreadableWebSocketChannelClientWrapper
{ {
} }
PassRefPtr<ThreadableWebSocketChannelClientWrapper> ThreadableWebSocketChannelClientWrapper::create(WebSocketChannelClient* client) ThreadableWebSocketChannelClientWrapper::~ThreadableWebSocketChannelClientWrapper()
{ {
return adoptRef(new ThreadableWebSocketChannelClientWrapper(client)); }
PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientWrapper> ThreadableWebSocketChannelClientWrapper::create(WebSocketChannelClient* client)
{
return adoptRefWillBeNoop(new ThreadableWebSocketChannelClientWrapper(client));
} }
String ThreadableWebSocketChannelClientWrapper::subprotocol() const String ThreadableWebSocketChannelClientWrapper::subprotocol() const
...@@ -151,49 +155,49 @@ void ThreadableWebSocketChannelClientWrapper::processPendingTasks() ...@@ -151,49 +155,49 @@ void ThreadableWebSocketChannelClientWrapper::processPendingTasks()
(*iter)->performTask(0); (*iter)->performTask(0);
} }
void ThreadableWebSocketChannelClientWrapper::didConnectCallback(ExecutionContext* context, PassRefPtr<ThreadableWebSocketChannelClientWrapper> wrapper) void ThreadableWebSocketChannelClientWrapper::didConnectCallback(ExecutionContext* context, PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientWrapper> wrapper)
{ {
ASSERT_UNUSED(context, !context); ASSERT_UNUSED(context, !context);
if (wrapper->m_client) if (wrapper->m_client)
wrapper->m_client->didConnect(); wrapper->m_client->didConnect();
} }
void ThreadableWebSocketChannelClientWrapper::didReceiveMessageCallback(ExecutionContext* context, PassRefPtr<ThreadableWebSocketChannelClientWrapper> wrapper, const String& message) void ThreadableWebSocketChannelClientWrapper::didReceiveMessageCallback(ExecutionContext* context, PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientWrapper> wrapper, const String& message)
{ {
ASSERT_UNUSED(context, !context); ASSERT_UNUSED(context, !context);
if (wrapper->m_client) if (wrapper->m_client)
wrapper->m_client->didReceiveMessage(message); wrapper->m_client->didReceiveMessage(message);
} }
void ThreadableWebSocketChannelClientWrapper::didReceiveBinaryDataCallback(ExecutionContext* context, PassRefPtr<ThreadableWebSocketChannelClientWrapper> wrapper, PassOwnPtr<Vector<char> > binaryData) void ThreadableWebSocketChannelClientWrapper::didReceiveBinaryDataCallback(ExecutionContext* context, PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientWrapper> wrapper, PassOwnPtr<Vector<char> > binaryData)
{ {
ASSERT_UNUSED(context, !context); ASSERT_UNUSED(context, !context);
if (wrapper->m_client) if (wrapper->m_client)
wrapper->m_client->didReceiveBinaryData(binaryData); wrapper->m_client->didReceiveBinaryData(binaryData);
} }
void ThreadableWebSocketChannelClientWrapper::didUpdateBufferedAmountCallback(ExecutionContext* context, PassRefPtr<ThreadableWebSocketChannelClientWrapper> wrapper, unsigned long bufferedAmount) void ThreadableWebSocketChannelClientWrapper::didUpdateBufferedAmountCallback(ExecutionContext* context, PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientWrapper> wrapper, unsigned long bufferedAmount)
{ {
ASSERT_UNUSED(context, !context); ASSERT_UNUSED(context, !context);
if (wrapper->m_client) if (wrapper->m_client)
wrapper->m_client->didUpdateBufferedAmount(bufferedAmount); wrapper->m_client->didUpdateBufferedAmount(bufferedAmount);
} }
void ThreadableWebSocketChannelClientWrapper::didStartClosingHandshakeCallback(ExecutionContext* context, PassRefPtr<ThreadableWebSocketChannelClientWrapper> wrapper) void ThreadableWebSocketChannelClientWrapper::didStartClosingHandshakeCallback(ExecutionContext* context, PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientWrapper> wrapper)
{ {
ASSERT_UNUSED(context, !context); ASSERT_UNUSED(context, !context);
if (wrapper->m_client) if (wrapper->m_client)
wrapper->m_client->didStartClosingHandshake(); wrapper->m_client->didStartClosingHandshake();
} }
void ThreadableWebSocketChannelClientWrapper::didCloseCallback(ExecutionContext* context, PassRefPtr<ThreadableWebSocketChannelClientWrapper> wrapper, unsigned long unhandledBufferedAmount, WebSocketChannelClient::ClosingHandshakeCompletionStatus closingHandshakeCompletion, unsigned short code, const String& reason) void ThreadableWebSocketChannelClientWrapper::didCloseCallback(ExecutionContext* context, PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientWrapper> wrapper, unsigned long unhandledBufferedAmount, WebSocketChannelClient::ClosingHandshakeCompletionStatus closingHandshakeCompletion, unsigned short code, const String& reason)
{ {
ASSERT_UNUSED(context, !context); ASSERT_UNUSED(context, !context);
if (wrapper->m_client) if (wrapper->m_client)
wrapper->m_client->didClose(unhandledBufferedAmount, closingHandshakeCompletion, code, reason); wrapper->m_client->didClose(unhandledBufferedAmount, closingHandshakeCompletion, code, reason);
} }
void ThreadableWebSocketChannelClientWrapper::didReceiveMessageErrorCallback(ExecutionContext* context, PassRefPtr<ThreadableWebSocketChannelClientWrapper> wrapper) void ThreadableWebSocketChannelClientWrapper::didReceiveMessageErrorCallback(ExecutionContext* context, PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientWrapper> wrapper)
{ {
ASSERT_UNUSED(context, !context); ASSERT_UNUSED(context, !context);
if (wrapper->m_client) if (wrapper->m_client)
......
...@@ -45,9 +45,10 @@ namespace WebCore { ...@@ -45,9 +45,10 @@ namespace WebCore {
class ExecutionContext; class ExecutionContext;
class WebSocketChannelClient; class WebSocketChannelClient;
class ThreadableWebSocketChannelClientWrapper : public ThreadSafeRefCounted<ThreadableWebSocketChannelClientWrapper> { class ThreadableWebSocketChannelClientWrapper : public ThreadSafeRefCountedWillBeGarbageCollectedFinalized<ThreadableWebSocketChannelClientWrapper> {
public: public:
static PassRefPtr<ThreadableWebSocketChannelClientWrapper> create(WebSocketChannelClient*); static PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientWrapper> create(WebSocketChannelClient*);
~ThreadableWebSocketChannelClientWrapper();
// Subprotocol and extensions will be available when didConnect() callback is invoked. // Subprotocol and extensions will be available when didConnect() callback is invoked.
String subprotocol() const; String subprotocol() const;
...@@ -68,18 +69,20 @@ public: ...@@ -68,18 +69,20 @@ public:
void suspend(); void suspend();
void resume(); void resume();
void trace(Visitor*) { }
private: private:
ThreadableWebSocketChannelClientWrapper(WebSocketChannelClient*); ThreadableWebSocketChannelClientWrapper(WebSocketChannelClient*);
void processPendingTasks(); void processPendingTasks();
static void didConnectCallback(ExecutionContext*, PassRefPtr<ThreadableWebSocketChannelClientWrapper>); static void didConnectCallback(ExecutionContext*, PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientWrapper>);
static void didReceiveMessageCallback(ExecutionContext*, PassRefPtr<ThreadableWebSocketChannelClientWrapper>, const String& message); static void didReceiveMessageCallback(ExecutionContext*, PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientWrapper>, const String& message);
static void didReceiveBinaryDataCallback(ExecutionContext*, PassRefPtr<ThreadableWebSocketChannelClientWrapper>, PassOwnPtr<Vector<char> >); static void didReceiveBinaryDataCallback(ExecutionContext*, PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientWrapper>, PassOwnPtr<Vector<char> >);
static void didUpdateBufferedAmountCallback(ExecutionContext*, PassRefPtr<ThreadableWebSocketChannelClientWrapper>, unsigned long bufferedAmount); static void didUpdateBufferedAmountCallback(ExecutionContext*, PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientWrapper>, unsigned long bufferedAmount);
static void didStartClosingHandshakeCallback(ExecutionContext*, PassRefPtr<ThreadableWebSocketChannelClientWrapper>); static void didStartClosingHandshakeCallback(ExecutionContext*, PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientWrapper>);
static void didCloseCallback(ExecutionContext*, PassRefPtr<ThreadableWebSocketChannelClientWrapper>, unsigned long unhandledBufferedAmount, WebSocketChannelClient::ClosingHandshakeCompletionStatus, unsigned short code, const String& reason); static void didCloseCallback(ExecutionContext*, PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientWrapper>, unsigned long unhandledBufferedAmount, WebSocketChannelClient::ClosingHandshakeCompletionStatus, unsigned short code, const String& reason);
static void didReceiveMessageErrorCallback(ExecutionContext*, PassRefPtr<ThreadableWebSocketChannelClientWrapper>); static void didReceiveMessageErrorCallback(ExecutionContext*, PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientWrapper>);
WebSocketChannelClient* m_client; WebSocketChannelClient* m_client;
// ThreadSafeRefCounted must not have String member variables. // ThreadSafeRefCounted must not have String member variables.
......
...@@ -90,6 +90,8 @@ public: ...@@ -90,6 +90,8 @@ public:
virtual void suspend() OVERRIDE; virtual void suspend() OVERRIDE;
virtual void resume() OVERRIDE; virtual void resume() OVERRIDE;
virtual void trace(Visitor*) OVERRIDE;
// Generated by the bridge. The Peer is destructed by an async call from // Generated by the bridge. The Peer is destructed by an async call from
// Bridge, and may outlive the bridge. All methods of this class must // Bridge, and may outlive the bridge. All methods of this class must
// be called on the main thread. // be called on the main thread.
...@@ -100,7 +102,7 @@ public: ...@@ -100,7 +102,7 @@ public:
// sourceURLAtConnection and lineNumberAtConnection parameters may // sourceURLAtConnection and lineNumberAtConnection parameters may
// be shown when the connection fails. // be shown when the connection fails.
static void initialize(ExecutionContext*, PassRefPtr<WeakReference<Peer> >, WorkerLoaderProxy*, PassRefPtr<ThreadableWebSocketChannelClientWrapper>, const String& sourceURLAtConnection, unsigned lineNumberAtConnection, PassOwnPtr<ThreadableWebSocketChannelSyncHelper>); static void initialize(ExecutionContext*, PassRefPtr<WeakReference<Peer> >, WorkerLoaderProxy*, PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientWrapper>, const String& sourceURLAtConnection, unsigned lineNumberAtConnection, PassOwnPtr<ThreadableWebSocketChannelSyncHelper>);
void destroy(); void destroy();
void connect(const KURL&, const String& protocol); void connect(const KURL&, const String& protocol);
...@@ -124,9 +126,9 @@ public: ...@@ -124,9 +126,9 @@ public:
virtual void didReceiveMessageError() OVERRIDE; virtual void didReceiveMessageError() OVERRIDE;
private: private:
Peer(PassRefPtr<WeakReference<Peer> >, PassRefPtr<ThreadableWebSocketChannelClientWrapper>, WorkerLoaderProxy&, ExecutionContext*, const String& sourceURL, unsigned lineNumber, PassOwnPtr<ThreadableWebSocketChannelSyncHelper>); Peer(PassRefPtr<WeakReference<Peer> >, PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientWrapper>, WorkerLoaderProxy&, ExecutionContext*, const String& sourceURL, unsigned lineNumber, PassOwnPtr<ThreadableWebSocketChannelSyncHelper>);
const RefPtr<ThreadableWebSocketChannelClientWrapper> m_workerClientWrapper; const RefPtrWillBePersistent<ThreadableWebSocketChannelClientWrapper> m_workerClientWrapper;
WorkerLoaderProxy& m_loaderProxy; WorkerLoaderProxy& m_loaderProxy;
RefPtrWillBePersistent<WebSocketChannel> m_mainWebSocketChannel; RefPtrWillBePersistent<WebSocketChannel> m_mainWebSocketChannel;
OwnPtr<ThreadableWebSocketChannelSyncHelper> m_syncHelper; OwnPtr<ThreadableWebSocketChannelSyncHelper> m_syncHelper;
...@@ -137,7 +139,7 @@ private: ...@@ -137,7 +139,7 @@ private:
// Bridge for Peer. Running on the worker thread. // Bridge for Peer. Running on the worker thread.
class Bridge : public RefCounted<Bridge> { class Bridge : public RefCounted<Bridge> {
public: public:
static PassRefPtr<Bridge> create(PassRefPtr<ThreadableWebSocketChannelClientWrapper> workerClientWrapper, WorkerGlobalScope& workerGlobalScope) static PassRefPtr<Bridge> create(PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientWrapper> workerClientWrapper, WorkerGlobalScope& workerGlobalScope)
{ {
return adoptRef(new Bridge(workerClientWrapper, workerGlobalScope)); return adoptRef(new Bridge(workerClientWrapper, workerGlobalScope));
} }
...@@ -157,9 +159,9 @@ private: ...@@ -157,9 +159,9 @@ private:
void resume(); void resume();
private: private:
Bridge(PassRefPtr<ThreadableWebSocketChannelClientWrapper>, WorkerGlobalScope&); Bridge(PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientWrapper>, WorkerGlobalScope&);
static void setWebSocketChannel(ExecutionContext*, Bridge* thisPtr, Peer*, PassRefPtr<ThreadableWebSocketChannelClientWrapper>); static void setWebSocketChannel(ExecutionContext*, Bridge* thisPtr, Peer*, PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientWrapper>);
// Executed on the worker context's thread. // Executed on the worker context's thread.
void clearClientWrapper(); void clearClientWrapper();
...@@ -171,7 +173,7 @@ private: ...@@ -171,7 +173,7 @@ private:
bool hasTerminatedPeer() { return !m_syncHelper; } bool hasTerminatedPeer() { return !m_syncHelper; }
const RefPtr<ThreadableWebSocketChannelClientWrapper> m_workerClientWrapper; const RefPtrWillBePersistent<ThreadableWebSocketChannelClientWrapper> m_workerClientWrapper;
RefPtrWillBePersistent<WorkerGlobalScope> m_workerGlobalScope; RefPtrWillBePersistent<WorkerGlobalScope> m_workerGlobalScope;
WorkerLoaderProxy& m_loaderProxy; WorkerLoaderProxy& m_loaderProxy;
ThreadableWebSocketChannelSyncHelper* m_syncHelper; ThreadableWebSocketChannelSyncHelper* m_syncHelper;
...@@ -180,7 +182,7 @@ private: ...@@ -180,7 +182,7 @@ private:
WorkerThreadableWebSocketChannel(WorkerGlobalScope&, WebSocketChannelClient*, const String& sourceURL, unsigned lineNumber); WorkerThreadableWebSocketChannel(WorkerGlobalScope&, WebSocketChannelClient*, const String& sourceURL, unsigned lineNumber);
const RefPtr<ThreadableWebSocketChannelClientWrapper> m_workerClientWrapper; const RefPtrWillBeMember<ThreadableWebSocketChannelClientWrapper> m_workerClientWrapper;
RefPtr<Bridge> m_bridge; RefPtr<Bridge> m_bridge;
String m_sourceURLAtConnection; String m_sourceURLAtConnection;
unsigned m_lineNumberAtConnection; unsigned m_lineNumberAtConnection;
......
...@@ -40,27 +40,27 @@ ...@@ -40,27 +40,27 @@
namespace WebCore { namespace WebCore {
CrossThreadCopierBase<false, false, KURL>::Type CrossThreadCopierBase<false, false, KURL>::copy(const KURL& url) CrossThreadCopierBase<false, false, false, KURL>::Type CrossThreadCopierBase<false, false, false, KURL>::copy(const KURL& url)
{ {
return url.copy(); return url.copy();
} }
CrossThreadCopierBase<false, false, String>::Type CrossThreadCopierBase<false, false, String>::copy(const String& str) CrossThreadCopierBase<false, false, false, String>::Type CrossThreadCopierBase<false, false, false, String>::copy(const String& str)
{ {
return str.isolatedCopy(); return str.isolatedCopy();
} }
CrossThreadCopierBase<false, false, ResourceError>::Type CrossThreadCopierBase<false, false, ResourceError>::copy(const ResourceError& error) CrossThreadCopierBase<false, false, false, ResourceError>::Type CrossThreadCopierBase<false, false, false, ResourceError>::copy(const ResourceError& error)
{ {
return error.copy(); return error.copy();
} }
CrossThreadCopierBase<false, false, ResourceRequest>::Type CrossThreadCopierBase<false, false, ResourceRequest>::copy(const ResourceRequest& request) CrossThreadCopierBase<false, false, false, ResourceRequest>::Type CrossThreadCopierBase<false, false, false, ResourceRequest>::copy(const ResourceRequest& request)
{ {
return request.copyData(); return request.copyData();
} }
CrossThreadCopierBase<false, false, ResourceResponse>::Type CrossThreadCopierBase<false, false, ResourceResponse>::copy(const ResourceResponse& response) CrossThreadCopierBase<false, false, false, ResourceResponse>::Type CrossThreadCopierBase<false, false, false, ResourceResponse>::copy(const ResourceResponse& response)
{ {
return response.copyData(); return response.copyData();
} }
...@@ -89,7 +89,7 @@ COMPILE_ASSERT((WTF::IsSameType< ...@@ -89,7 +89,7 @@ COMPILE_ASSERT((WTF::IsSameType<
// Add a generic specialization which will let's us verify that no other template matches. // Add a generic specialization which will let's us verify that no other template matches.
template<typename T> struct CrossThreadCopierBase<false, false, T> { template<typename T> struct CrossThreadCopierBase<false, false, false, T> {
typedef int Type; typedef int Type;
}; };
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#define CrossThreadCopier_h #define CrossThreadCopier_h
#include "platform/PlatformExport.h" #include "platform/PlatformExport.h"
#include "platform/heap/Handle.h"
#include "wtf/Assertions.h" #include "wtf/Assertions.h"
#include "wtf/Forward.h" #include "wtf/Forward.h"
#include "wtf/PassOwnPtr.h" #include "wtf/PassOwnPtr.h"
...@@ -61,28 +62,28 @@ namespace WebCore { ...@@ -61,28 +62,28 @@ namespace WebCore {
} }
}; };
template<bool isConvertibleToInteger, bool isThreadSafeRefCounted, typename T> struct CrossThreadCopierBase; template<bool isConvertibleToInteger, bool isThreadSafeRefCounted, bool isGarbageCollected, typename T> struct CrossThreadCopierBase;
// Integers get passed through without any changes. // Integers get passed through without any changes.
template<typename T> struct CrossThreadCopierBase<true, false, T> : public CrossThreadCopierPassThrough<T> { template<typename T> struct CrossThreadCopierBase<true, false, false, T> : public CrossThreadCopierPassThrough<T> {
}; };
// To allow a type to be passed across threads using its copy constructor, add a forward declaration of the type and // To allow a type to be passed across threads using its copy constructor, add a forward declaration of the type and
// a CopyThreadCopierBase<false, false, TypeName> : public CrossThreadCopierPassThrough<TypeName> { }; to this file. // a CopyThreadCopierBase<false, false, TypeName> : public CrossThreadCopierPassThrough<TypeName> { }; to this file.
template<> struct CrossThreadCopierBase<false, false, ThreadableLoaderOptions> : public CrossThreadCopierPassThrough<ThreadableLoaderOptions> { template<> struct CrossThreadCopierBase<false, false, false, ThreadableLoaderOptions> : public CrossThreadCopierPassThrough<ThreadableLoaderOptions> {
}; };
template<> struct CrossThreadCopierBase<false, false, ResourceLoaderOptions> : public CrossThreadCopierPassThrough<ResourceLoaderOptions> { template<> struct CrossThreadCopierBase<false, false, false, ResourceLoaderOptions> : public CrossThreadCopierPassThrough<ResourceLoaderOptions> {
}; };
template<> struct CrossThreadCopierBase<false, false, IntRect> : public CrossThreadCopierPassThrough<IntRect> { template<> struct CrossThreadCopierBase<false, false, false, IntRect> : public CrossThreadCopierPassThrough<IntRect> {
}; };
template<> struct CrossThreadCopierBase<false, false, IntSize> : public CrossThreadCopierPassThrough<IntSize> { template<> struct CrossThreadCopierBase<false, false, false, IntSize> : public CrossThreadCopierPassThrough<IntSize> {
}; };
// Custom copy methods. // Custom copy methods.
template<typename T> struct CrossThreadCopierBase<false, true, T> { template<typename T> struct CrossThreadCopierBase<false, true, false, T> {
typedef typename WTF::RemoveTemplate<T, RefPtr>::Type TypeWithoutRefPtr; typedef typename WTF::RemoveTemplate<T, RefPtr>::Type TypeWithoutRefPtr;
typedef typename WTF::RemoveTemplate<TypeWithoutRefPtr, PassRefPtr>::Type TypeWithoutPassRefPtr; typedef typename WTF::RemoveTemplate<TypeWithoutRefPtr, PassRefPtr>::Type TypeWithoutPassRefPtr;
typedef typename WTF::RemovePointer<TypeWithoutPassRefPtr>::Type RefCountedType; typedef typename WTF::RemovePointer<TypeWithoutPassRefPtr>::Type RefCountedType;
...@@ -100,7 +101,7 @@ namespace WebCore { ...@@ -100,7 +101,7 @@ namespace WebCore {
} }
}; };
template<typename T> struct CrossThreadCopierBase<false, false, PassOwnPtr<T> > { template<typename T> struct CrossThreadCopierBase<false, false, false, PassOwnPtr<T> > {
typedef PassOwnPtr<T> Type; typedef PassOwnPtr<T> Type;
static Type copy(Type ownPtr) static Type copy(Type ownPtr)
{ {
...@@ -108,36 +109,46 @@ namespace WebCore { ...@@ -108,36 +109,46 @@ namespace WebCore {
} }
}; };
template<> struct CrossThreadCopierBase<false, false, KURL> { template<> struct CrossThreadCopierBase<false, false, false, KURL> {
typedef KURL Type; typedef KURL Type;
PLATFORM_EXPORT static Type copy(const KURL&); PLATFORM_EXPORT static Type copy(const KURL&);
}; };
template<> struct CrossThreadCopierBase<false, false, String> { template<> struct CrossThreadCopierBase<false, false, false, String> {
typedef String Type; typedef String Type;
PLATFORM_EXPORT static Type copy(const String&); PLATFORM_EXPORT static Type copy(const String&);
}; };
template<> struct CrossThreadCopierBase<false, false, ResourceError> { template<> struct CrossThreadCopierBase<false, false, false, ResourceError> {
typedef ResourceError Type; typedef ResourceError Type;
PLATFORM_EXPORT static Type copy(const ResourceError&); PLATFORM_EXPORT static Type copy(const ResourceError&);
}; };
template<> struct CrossThreadCopierBase<false, false, ResourceRequest> { template<> struct CrossThreadCopierBase<false, false, false, ResourceRequest> {
typedef PassOwnPtr<CrossThreadResourceRequestData> Type; typedef PassOwnPtr<CrossThreadResourceRequestData> Type;
PLATFORM_EXPORT static Type copy(const ResourceRequest&); PLATFORM_EXPORT static Type copy(const ResourceRequest&);
}; };
template<> struct CrossThreadCopierBase<false, false, ResourceResponse> { template<> struct CrossThreadCopierBase<false, false, false, ResourceResponse> {
typedef PassOwnPtr<CrossThreadResourceResponseData> Type; typedef PassOwnPtr<CrossThreadResourceResponseData> Type;
PLATFORM_EXPORT static Type copy(const ResourceResponse&); PLATFORM_EXPORT static Type copy(const ResourceResponse&);
}; };
template<typename T> struct CrossThreadCopierBase<false, false, true, T> {
typedef typename WTF::RemovePointer<T>::Type TypeWithoutPointer;
typedef PassRefPtrWillBeRawPtr<TypeWithoutPointer> Type;
static Type copy(const T& ptr)
{
return ptr;
}
};
template<typename T> struct CrossThreadCopier : public CrossThreadCopierBase<WTF::IsConvertibleToInteger<T>::value, template<typename T> struct CrossThreadCopier : public CrossThreadCopierBase<WTF::IsConvertibleToInteger<T>::value,
WTF::IsSubclassOfTemplate<typename WTF::RemoveTemplate<T, RefPtr>::Type, ThreadSafeRefCounted>::value WTF::IsSubclassOfTemplate<typename WTF::RemoveTemplate<T, RefPtr>::Type, ThreadSafeRefCounted>::value
|| WTF::IsSubclassOfTemplate<typename WTF::RemovePointer<T>::Type, ThreadSafeRefCounted>::value || WTF::IsSubclassOfTemplate<typename WTF::RemovePointer<T>::Type, ThreadSafeRefCounted>::value
|| WTF::IsSubclassOfTemplate<typename WTF::RemoveTemplate<T, PassRefPtr>::Type, ThreadSafeRefCounted>::value, || WTF::IsSubclassOfTemplate<typename WTF::RemoveTemplate<T, PassRefPtr>::Type, ThreadSafeRefCounted>::value,
T> { WTF::IsSubclassOfTemplate<typename WTF::RemovePointer<T>::Type, GarbageCollected>::value,
T> {
}; };
template<typename T> struct AllowCrossThreadAccessWrapper { template<typename T> struct AllowCrossThreadAccessWrapper {
...@@ -148,7 +159,7 @@ namespace WebCore { ...@@ -148,7 +159,7 @@ namespace WebCore {
T* m_value; T* m_value;
}; };
template<typename T> struct CrossThreadCopierBase<false, false, AllowCrossThreadAccessWrapper<T> > { template<typename T> struct CrossThreadCopierBase<false, false, false, AllowCrossThreadAccessWrapper<T> > {
typedef T* Type; typedef T* Type;
static Type copy(const AllowCrossThreadAccessWrapper<T>& wrapper) { return wrapper.value(); } static Type copy(const AllowCrossThreadAccessWrapper<T>& wrapper) { return wrapper.value(); }
}; };
...@@ -168,7 +179,7 @@ namespace WebCore { ...@@ -168,7 +179,7 @@ namespace WebCore {
T* m_value; T* m_value;
}; };
template<typename T> struct CrossThreadCopierBase<false, false, AllowAccessLaterWrapper<T> > { template<typename T> struct CrossThreadCopierBase<false, false, false, AllowAccessLaterWrapper<T> > {
typedef T* Type; typedef T* Type;
static Type copy(const AllowAccessLaterWrapper<T>& wrapper) { return wrapper.value(); } static Type copy(const AllowAccessLaterWrapper<T>& wrapper) { return wrapper.value(); }
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment