Commit 78e32a56 authored by levin@chromium.org's avatar levin@chromium.org
Browse files

CrossThreadCopier needs to support ThreadSafeShared better.

https://bugs.webkit.org/show_bug.cgi?id=33698

Reviewed by Oliver Hunt.

JavaScriptCore:

* wtf/TypeTraits.cpp: Added tests for the new type traits.
* wtf/TypeTraits.h:
(WTF::IsSubclass): Determines if a class is a derived from another class.
(WTF::IsSubclassOfTemplate): Determines if a class is a derived from a
template class (with one parameter that is unknown).
(WTF::RemoveTemplate): Reveals the type for a template parameter.

WebCore:

Now the copier is able to handle types that derive from ThreadSafeShared.

No change functionality so no new tests.

* loader/WorkerThreadableLoader.cpp:
(WebCore::WorkerThreadableLoader::MainThreadBridge::cancel): Remove unnecessary cast.
(WebCore::WorkerThreadableLoader::MainThreadBridge::clearClientWrapper): Ditto.
* loader/WorkerThreadableLoader.h:
Change to use the derived class instead of the ThreadSafeShared version.
* platform/CrossThreadCopier.cpp:
Add the new template parameter throughout the classes and adjust the class that
handles ThreadSafeShared to allow for derived types.
* platform/CrossThreadCopier.h:
Add another template parameter to be able to detect classes that derive
from ThreadSafeShared.
* websockets/WorkerThreadableWebSocketChannel.cpp:
Removed unnecessary casts and changed a type to use the derived class instead of
the ThreadSafeShared version.
(WebCore::WorkerThreadableWebSocketChannel::Peer::Peer):
(WebCore::workerContextDidSend):
(WebCore::workerContextDidGetBufferedAmount):
(WebCore::workerContextDidConnect):
(WebCore::workerContextDidReceiveMessage):
(WebCore::workerContextDidClose):
(WebCore::WorkerThreadableWebSocketChannel::Bridge::setWebSocketChannel):
(WebCore::WorkerThreadableWebSocketChannel::Bridge::mainThreadCreateWebSocketChannel):
(WebCore::WorkerThreadableWebSocketChannel::Bridge::send):
(WebCore::WorkerThreadableWebSocketChannel::Bridge::bufferedAmount):
(WebCore::WorkerThreadableWebSocketChannel::Bridge::clearClientWrapper):
(WebCore::WorkerThreadableWebSocketChannel::Bridge::setMethodNotCompleted):
(WebCore::WorkerThreadableWebSocketChannel::Bridge::waitForMethodCompletion):
* websockets/WorkerThreadableWebSocketChannel.h:
(WebCore::WorkerThreadableWebSocketChannel::Peer::create): Changed a type to use the
derived class instead of the ThreadSafeShared version.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@53568 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent d98c4b2e
2010-01-19 David Levin <levin@chromium.org>
Reviewed by Oliver Hunt.
CrossThreadCopier needs to support ThreadSafeShared better.
https://bugs.webkit.org/show_bug.cgi?id=33698
* wtf/TypeTraits.cpp: Added tests for the new type traits.
* wtf/TypeTraits.h:
(WTF::IsSubclass): Determines if a class is a derived from another class.
(WTF::IsSubclassOfTemplate): Determines if a class is a derived from a
template class (with one parameter that is unknown).
(WTF::RemoveTemplate): Reveals the type for a template parameter.
2010-01-20 Steve Falkenburg <sfalken@apple.com>
 
Reviewed by Darin Adler and Adam Roben.
......
/*
* Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
* Copyright (C) 2009 Google Inc. All rights reserved.
* Copyright (C) 2009, 2010 Google Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
......@@ -101,6 +101,20 @@ COMPILE_ASSERT((!IsSameType<int, int*>::value), WTF_IsSameType_int_int_pointer_f
COMPILE_ASSERT((!IsSameType<bool, const bool>::value), WTF_IsSameType_const_change_false);
COMPILE_ASSERT((!IsSameType<bool, volatile bool>::value), WTF_IsSameType_volatile_change_false);
template <typename T>
class TestBaseClass {
};
class TestDerivedClass : public TestBaseClass<int> {
};
COMPILE_ASSERT((IsSubclass<TestDerivedClass, TestBaseClass<int> >::value), WTF_Test_IsSubclass_Derived_From_Base);
COMPILE_ASSERT((!IsSubclass<TestBaseClass<int>, TestDerivedClass>::value), WTF_Test_IsSubclass_Base_From_Derived);
COMPILE_ASSERT((IsSubclassOfTemplate<TestDerivedClass, TestBaseClass>::value), WTF_Test_IsSubclassOfTemplate_Base_From_Derived);
COMPILE_ASSERT((IsSameType<RemoveTemplate<TestBaseClass<int>, TestBaseClass>::Type, int>::value), WTF_Test_RemoveTemplate);
COMPILE_ASSERT((IsSameType<RemoveTemplate<int, TestBaseClass>::Type, int>::value), WTF_Test_RemoveTemplate_WithoutTemplate);
COMPILE_ASSERT((IsSameType<bool, RemoveConst<const bool>::Type>::value), WTF_test_RemoveConst_const_bool);
COMPILE_ASSERT((!IsSameType<bool, RemoveConst<volatile bool>::Type>::value), WTF_test_RemoveConst_volatile_bool);
......
/*
* Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
* Copyright (C) 2009 Google Inc. All rights reserved.
* Copyright (C) 2009, 2010 Google Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
......@@ -104,6 +104,40 @@ namespace WTF {
static const bool value = true;
};
template <typename T, typename U> class IsSubclass {
typedef char YesType;
struct NoType {
char padding[8];
};
static YesType subclassCheck(U*);
static NoType subclassCheck(...);
static T* t;
public:
static const bool value = sizeof(subclassCheck(t)) == sizeof(YesType);
};
template <typename T, template<class V> class U> class IsSubclassOfTemplate {
typedef char YesType;
struct NoType {
char padding[8];
};
template<typename W> static YesType subclassCheck(U<W>*);
static NoType subclassCheck(...);
static T* t;
public:
static const bool value = sizeof(subclassCheck(t)) == sizeof(YesType);
};
template <typename T, template <class V> class OuterTemplate> struct RemoveTemplate {
typedef T Type;
};
template <typename T, template <class V> class OuterTemplate> struct RemoveTemplate<OuterTemplate<T>, OuterTemplate> {
typedef T Type;
};
template <typename T> struct RemoveConst {
typedef T Type;
};
......
2010-01-19 David Levin <levin@chromium.org>
Reviewed by Oliver Hunt.
CrossThreadCopier needs to support ThreadSafeShared better.
https://bugs.webkit.org/show_bug.cgi?id=33698
Now the copier is able to handle types that derive from ThreadSafeShared.
No change functionality so no new tests.
* loader/WorkerThreadableLoader.cpp:
(WebCore::WorkerThreadableLoader::MainThreadBridge::cancel): Remove unnecessary cast.
(WebCore::WorkerThreadableLoader::MainThreadBridge::clearClientWrapper): Ditto.
* loader/WorkerThreadableLoader.h:
Change to use the derived class instead of the ThreadSafeShared version.
* platform/CrossThreadCopier.cpp:
Add the new template parameter throughout the classes and adjust the class that
handles ThreadSafeShared to allow for derived types.
* platform/CrossThreadCopier.h:
Add another template parameter to be able to detect classes that derive
from ThreadSafeShared.
* websockets/WorkerThreadableWebSocketChannel.cpp:
Removed unnecessary casts and changed a type to use the derived class instead of
the ThreadSafeShared version.
(WebCore::WorkerThreadableWebSocketChannel::Peer::Peer):
(WebCore::workerContextDidSend):
(WebCore::workerContextDidGetBufferedAmount):
(WebCore::workerContextDidConnect):
(WebCore::workerContextDidReceiveMessage):
(WebCore::workerContextDidClose):
(WebCore::WorkerThreadableWebSocketChannel::Bridge::setWebSocketChannel):
(WebCore::WorkerThreadableWebSocketChannel::Bridge::mainThreadCreateWebSocketChannel):
(WebCore::WorkerThreadableWebSocketChannel::Bridge::send):
(WebCore::WorkerThreadableWebSocketChannel::Bridge::bufferedAmount):
(WebCore::WorkerThreadableWebSocketChannel::Bridge::clearClientWrapper):
(WebCore::WorkerThreadableWebSocketChannel::Bridge::setMethodNotCompleted):
(WebCore::WorkerThreadableWebSocketChannel::Bridge::waitForMethodCompletion):
* websockets/WorkerThreadableWebSocketChannel.h:
(WebCore::WorkerThreadableWebSocketChannel::Peer::create): Changed a type to use the
derived class instead of the ThreadSafeShared version.
2010-01-20 Jon Honeycutt <jhoneycutt@apple.com>
 
MSAA: accSelect() is not implemented
/*
* Copyright (C) 2009 Google Inc. All rights reserved.
* Copyright (C) 2009, 2010 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
......@@ -147,7 +147,7 @@ void WorkerThreadableLoader::MainThreadBridge::mainThreadCancel(ScriptExecutionC
void WorkerThreadableLoader::MainThreadBridge::cancel()
{
m_loaderProxy.postTaskToLoader(createCallbackTask(&MainThreadBridge::mainThreadCancel, this));
ThreadableLoaderClientWrapper* clientWrapper = static_cast<ThreadableLoaderClientWrapper*>(m_workerClientWrapper.get());
ThreadableLoaderClientWrapper* clientWrapper = m_workerClientWrapper.get();
if (!clientWrapper->done()) {
// If the client hasn't reached a termination state, then transition it by sending a cancellation error.
// Note: no more client callbacks will be done after this method -- the clearClientWrapper() call ensures that.
......@@ -160,7 +160,7 @@ void WorkerThreadableLoader::MainThreadBridge::cancel()
void WorkerThreadableLoader::MainThreadBridge::clearClientWrapper()
{
static_cast<ThreadableLoaderClientWrapper*>(m_workerClientWrapper.get())->clearClient();
m_workerClientWrapper->clearClient();
}
static void workerContextDidSendData(ScriptExecutionContext* context, RefPtr<ThreadableLoaderClientWrapper> workerClientWrapper, unsigned long long bytesSent, unsigned long long totalBytesToBeSent)
......
......@@ -124,7 +124,7 @@ namespace WebCore {
// ThreadableLoaderClientWrapper is to be used on the worker context thread.
// The ref counting is done on either thread.
RefPtr<ThreadSafeShared<ThreadableLoaderClientWrapper> > m_workerClientWrapper;
RefPtr<ThreadableLoaderClientWrapper> m_workerClientWrapper;
// May be used on either thread.
WorkerLoaderProxy& m_loaderProxy;
......
......@@ -40,27 +40,27 @@
namespace WebCore {
CrossThreadCopierBase<false, KURL>::Type CrossThreadCopierBase<false, KURL>::copy(const KURL& url)
CrossThreadCopierBase<false, false, KURL>::Type CrossThreadCopierBase<false, false, KURL>::copy(const KURL& url)
{
return url.copy();
}
CrossThreadCopierBase<false, String>::Type CrossThreadCopierBase<false, String>::copy(const String& str)
CrossThreadCopierBase<false, false, String>::Type CrossThreadCopierBase<false, false, String>::copy(const String& str)
{
return str.crossThreadString();
}
CrossThreadCopierBase<false, ResourceError>::Type CrossThreadCopierBase<false, ResourceError>::copy(const ResourceError& error)
CrossThreadCopierBase<false, false, ResourceError>::Type CrossThreadCopierBase<false, false, ResourceError>::copy(const ResourceError& error)
{
return error.copy();
}
CrossThreadCopierBase<false, ResourceRequest>::Type CrossThreadCopierBase<false, ResourceRequest>::copy(const ResourceRequest& request)
CrossThreadCopierBase<false, false, ResourceRequest>::Type CrossThreadCopierBase<false, false, ResourceRequest>::copy(const ResourceRequest& request)
{
return request.copyData();
}
CrossThreadCopierBase<false, ResourceResponse>::Type CrossThreadCopierBase<false, ResourceResponse>::copy(const ResourceResponse& response)
CrossThreadCopierBase<false, false, ResourceResponse>::Type CrossThreadCopierBase<false, false, ResourceResponse>::copy(const ResourceResponse& response)
{
return response.copyData();
}
......
/*
* Copyright (C) 2009 Google Inc. All rights reserved.
* Copyright (C) 2009, 2010 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
......@@ -57,29 +57,30 @@ namespace WebCore {
}
};
template<bool isConvertibleToInteger, typename T> struct CrossThreadCopierBase;
template<bool isConvertibleToInteger, bool isThreadsafeShared, typename T> struct CrossThreadCopierBase;
// Integers get passed through without any changes.
template<typename T> struct CrossThreadCopierBase<true, T> : public CrossThreadCopierPassThrough<T> {
template<typename T> struct CrossThreadCopierBase<true, false, T> : public CrossThreadCopierPassThrough<T> {
};
// Pointers get passed through without any significant changes.
template<typename T> struct CrossThreadCopierBase<false, T*> : public CrossThreadCopierPassThrough<T*> {
template<typename T> struct CrossThreadCopierBase<false, false, T*> : public CrossThreadCopierPassThrough<T*> {
};
template<> struct CrossThreadCopierBase<false, ThreadableLoaderOptions> : public CrossThreadCopierPassThrough<ThreadableLoaderOptions> {
template<> struct CrossThreadCopierBase<false, false, ThreadableLoaderOptions> : public CrossThreadCopierPassThrough<ThreadableLoaderOptions> {
};
// Custom copy methods.
template<typename T> struct CrossThreadCopierBase<false, RefPtr<ThreadSafeShared<T> > > {
typedef PassRefPtr<T> Type;
static Type copy(const RefPtr<ThreadSafeShared<T> >& refPtr)
template<typename T> struct CrossThreadCopierBase<false, true, T> {
typedef typename WTF::RemoveTemplate<T, RefPtr>::Type RefCountedType;
typedef PassRefPtr<RefCountedType> Type;
static Type copy(const T& refPtr)
{
return PassRefPtr<T>(static_cast<T*>(refPtr.get()));
return refPtr.get();
}
};
template<typename T> struct CrossThreadCopierBase<false, PassOwnPtr<T> > {
template<typename T> struct CrossThreadCopierBase<false, false, PassOwnPtr<T> > {
typedef PassOwnPtr<T> Type;
static Type copy(const PassOwnPtr<T>& ownPtr)
{
......@@ -87,7 +88,7 @@ namespace WebCore {
}
};
template<typename T> struct CrossThreadCopierBase<false, std::auto_ptr<T> > {
template<typename T> struct CrossThreadCopierBase<false, false, std::auto_ptr<T> > {
typedef std::auto_ptr<T> Type;
static Type copy(const std::auto_ptr<T>& autoPtr)
{
......@@ -95,32 +96,34 @@ namespace WebCore {
}
};
template<> struct CrossThreadCopierBase<false, KURL> {
template<> struct CrossThreadCopierBase<false, false, KURL> {
typedef KURL Type;
static Type copy(const KURL&);
};
template<> struct CrossThreadCopierBase<false, String> {
template<> struct CrossThreadCopierBase<false, false, String> {
typedef String Type;
static Type copy(const String&);
};
template<> struct CrossThreadCopierBase<false, ResourceError> {
template<> struct CrossThreadCopierBase<false, false, ResourceError> {
typedef ResourceError Type;
static Type copy(const ResourceError&);
};
template<> struct CrossThreadCopierBase<false, ResourceRequest> {
template<> struct CrossThreadCopierBase<false, false, ResourceRequest> {
typedef std::auto_ptr<CrossThreadResourceRequestData> Type;
static Type copy(const ResourceRequest&);
};
template<> struct CrossThreadCopierBase<false, ResourceResponse> {
template<> struct CrossThreadCopierBase<false, false, ResourceResponse> {
typedef std::auto_ptr<CrossThreadResourceResponseData> Type;
static Type copy(const ResourceResponse&);
};
template<typename T> struct CrossThreadCopier : public CrossThreadCopierBase<WTF::IsConvertibleToInteger<T>::value, T> {
template<typename T> struct CrossThreadCopier : public CrossThreadCopierBase<WTF::IsConvertibleToInteger<T>::value,
WTF::IsSubclassOfTemplate<typename WTF::RemoveTemplate<T, RefPtr>::Type, ThreadSafeShared>::value,
T> {
};
} // namespace WebCore
......
/*
* Copyright (C) 2009 Google Inc. All rights reserved.
* Copyright (C) 2009, 2010 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
......@@ -94,7 +94,7 @@ void WorkerThreadableWebSocketChannel::disconnect()
m_bridge.clear();
}
WorkerThreadableWebSocketChannel::Peer::Peer(RefPtr<ThreadSafeShared<ThreadableWebSocketChannelClientWrapper> > clientWrapper, WorkerLoaderProxy& loaderProxy, ScriptExecutionContext* context, const String& taskMode, const KURL& url, const String& protocol)
WorkerThreadableWebSocketChannel::Peer::Peer(RefPtr<ThreadableWebSocketChannelClientWrapper> clientWrapper, WorkerLoaderProxy& loaderProxy, ScriptExecutionContext* context, const String& taskMode, const KURL& url, const String& protocol)
: m_workerClientWrapper(clientWrapper)
, m_loaderProxy(loaderProxy)
, m_mainWebSocketChannel(WebSocketChannel::create(context, this, url, protocol))
......@@ -118,10 +118,10 @@ void WorkerThreadableWebSocketChannel::Peer::connect()
m_mainWebSocketChannel->connect();
}
static void workerContextDidSend(ScriptExecutionContext* context, RefPtr<ThreadSafeShared<ThreadableWebSocketChannelClientWrapper> > workerClientWrapper, bool sent)
static void workerContextDidSend(ScriptExecutionContext* context, RefPtr<ThreadableWebSocketChannelClientWrapper> workerClientWrapper, bool sent)
{
ASSERT_UNUSED(context, context->isWorkerContext());
static_cast<ThreadableWebSocketChannelClientWrapper*>(workerClientWrapper.get())->setSent(sent);
workerClientWrapper->setSent(sent);
}
void WorkerThreadableWebSocketChannel::Peer::send(const String& message)
......@@ -133,10 +133,10 @@ void WorkerThreadableWebSocketChannel::Peer::send(const String& message)
m_loaderProxy.postTaskForModeToWorkerContext(createCallbackTask(&workerContextDidSend, m_workerClientWrapper, sent), m_taskMode);
}
static void workerContextDidGetBufferedAmount(ScriptExecutionContext* context, RefPtr<ThreadSafeShared<ThreadableWebSocketChannelClientWrapper> > workerClientWrapper, unsigned long bufferedAmount)
static void workerContextDidGetBufferedAmount(ScriptExecutionContext* context, RefPtr<ThreadableWebSocketChannelClientWrapper> workerClientWrapper, unsigned long bufferedAmount)
{
ASSERT_UNUSED(context, context->isWorkerContext());
static_cast<ThreadableWebSocketChannelClientWrapper*>(workerClientWrapper.get())->setBufferedAmount(bufferedAmount);
workerClientWrapper->setBufferedAmount(bufferedAmount);
}
void WorkerThreadableWebSocketChannel::Peer::bufferedAmount()
......@@ -166,10 +166,10 @@ void WorkerThreadableWebSocketChannel::Peer::disconnect()
m_mainWebSocketChannel = 0;
}
static void workerContextDidConnect(ScriptExecutionContext* context, RefPtr<ThreadSafeShared<ThreadableWebSocketChannelClientWrapper> > workerClientWrapper)
static void workerContextDidConnect(ScriptExecutionContext* context, RefPtr<ThreadableWebSocketChannelClientWrapper> workerClientWrapper)
{
ASSERT_UNUSED(context, context->isWorkerContext());
static_cast<ThreadableWebSocketChannelClientWrapper*>(workerClientWrapper.get())->didConnect();
workerClientWrapper->didConnect();
}
void WorkerThreadableWebSocketChannel::Peer::didConnect()
......@@ -178,10 +178,10 @@ void WorkerThreadableWebSocketChannel::Peer::didConnect()
m_loaderProxy.postTaskForModeToWorkerContext(createCallbackTask(&workerContextDidConnect, m_workerClientWrapper), m_taskMode);
}
static void workerContextDidReceiveMessage(ScriptExecutionContext* context, RefPtr<ThreadSafeShared<ThreadableWebSocketChannelClientWrapper> > workerClientWrapper, const String& message)
static void workerContextDidReceiveMessage(ScriptExecutionContext* context, RefPtr<ThreadableWebSocketChannelClientWrapper> workerClientWrapper, const String& message)
{
ASSERT_UNUSED(context, context->isWorkerContext());
static_cast<ThreadableWebSocketChannelClientWrapper*>(workerClientWrapper.get())->didReceiveMessage(message);
workerClientWrapper->didReceiveMessage(message);
}
void WorkerThreadableWebSocketChannel::Peer::didReceiveMessage(const String& message)
......@@ -190,10 +190,10 @@ void WorkerThreadableWebSocketChannel::Peer::didReceiveMessage(const String& mes
m_loaderProxy.postTaskForModeToWorkerContext(createCallbackTask(&workerContextDidReceiveMessage, m_workerClientWrapper, message), m_taskMode);
}
static void workerContextDidClose(ScriptExecutionContext* context, RefPtr<ThreadSafeShared<ThreadableWebSocketChannelClientWrapper> > workerClientWrapper)
static void workerContextDidClose(ScriptExecutionContext* context, RefPtr<ThreadableWebSocketChannelClientWrapper> workerClientWrapper)
{
ASSERT_UNUSED(context, context->isWorkerContext());
static_cast<ThreadableWebSocketChannelClientWrapper*>(workerClientWrapper.get())->didClose();
workerClientWrapper->didClose();
}
void WorkerThreadableWebSocketChannel::Peer::didClose()
......@@ -203,14 +203,14 @@ void WorkerThreadableWebSocketChannel::Peer::didClose()
m_loaderProxy.postTaskForModeToWorkerContext(createCallbackTask(&workerContextDidClose, m_workerClientWrapper), m_taskMode);
}
void WorkerThreadableWebSocketChannel::Bridge::setWebSocketChannel(ScriptExecutionContext* context, Bridge* thisPtr, Peer* peer, RefPtr<ThreadSafeShared<ThreadableWebSocketChannelClientWrapper> > workerClientWrapper)
void WorkerThreadableWebSocketChannel::Bridge::setWebSocketChannel(ScriptExecutionContext* context, Bridge* thisPtr, Peer* peer, RefPtr<ThreadableWebSocketChannelClientWrapper> workerClientWrapper)
{
ASSERT_UNUSED(context, context->isWorkerContext());
thisPtr->m_peer = peer;
static_cast<ThreadableWebSocketChannelClientWrapper*>(workerClientWrapper.get())->setSyncMethodDone();
workerClientWrapper->setSyncMethodDone();
}
void WorkerThreadableWebSocketChannel::Bridge::mainThreadCreateWebSocketChannel(ScriptExecutionContext* context, Bridge* thisPtr, RefPtr<ThreadSafeShared<ThreadableWebSocketChannelClientWrapper> > clientWrapper, const String& taskMode, const KURL& url, const String& protocol)
void WorkerThreadableWebSocketChannel::Bridge::mainThreadCreateWebSocketChannel(ScriptExecutionContext* context, Bridge* thisPtr, RefPtr<ThreadableWebSocketChannelClientWrapper> clientWrapper, const String& taskMode, const KURL& url, const String& protocol)
{
ASSERT(isMainThread());
ASSERT_UNUSED(context, context->isDocument());
......@@ -271,7 +271,7 @@ bool WorkerThreadableWebSocketChannel::Bridge::send(const String& message)
setMethodNotCompleted();
m_loaderProxy.postTaskToLoader(createCallbackTask(&WorkerThreadableWebSocketChannel::mainThreadSend, m_peer, message));
waitForMethodCompletion();
ThreadableWebSocketChannelClientWrapper* clientWrapper = static_cast<ThreadableWebSocketChannelClientWrapper*>(m_workerClientWrapper.get());
ThreadableWebSocketChannelClientWrapper* clientWrapper = m_workerClientWrapper.get();
return clientWrapper && clientWrapper->sent();
}
......@@ -292,7 +292,7 @@ unsigned long WorkerThreadableWebSocketChannel::Bridge::bufferedAmount()
setMethodNotCompleted();
m_loaderProxy.postTaskToLoader(createCallbackTask(&WorkerThreadableWebSocketChannel::mainThreadBufferedAmount, m_peer));
waitForMethodCompletion();
ThreadableWebSocketChannelClientWrapper* clientWrapper = static_cast<ThreadableWebSocketChannelClientWrapper*>(m_workerClientWrapper.get());
ThreadableWebSocketChannelClientWrapper* clientWrapper = m_workerClientWrapper.get();
if (clientWrapper)
return clientWrapper->bufferedAmount();
return 0;
......@@ -335,13 +335,13 @@ void WorkerThreadableWebSocketChannel::Bridge::disconnect()
void WorkerThreadableWebSocketChannel::Bridge::clearClientWrapper()
{
static_cast<ThreadableWebSocketChannelClientWrapper*>(m_workerClientWrapper.get())->clearClient();
m_workerClientWrapper->clearClient();
}
void WorkerThreadableWebSocketChannel::Bridge::setMethodNotCompleted()
{
ASSERT(m_workerClientWrapper);
static_cast<ThreadableWebSocketChannelClientWrapper*>(m_workerClientWrapper.get())->clearSyncMethodDone();
m_workerClientWrapper->clearSyncMethodDone();
}
void WorkerThreadableWebSocketChannel::Bridge::waitForMethodCompletion()
......@@ -350,10 +350,10 @@ void WorkerThreadableWebSocketChannel::Bridge::waitForMethodCompletion()
return;
WorkerRunLoop& runLoop = m_workerContext->thread()->runLoop();
MessageQueueWaitResult result = MessageQueueMessageReceived;
ThreadableWebSocketChannelClientWrapper* clientWrapper = static_cast<ThreadableWebSocketChannelClientWrapper*>(m_workerClientWrapper.get());
ThreadableWebSocketChannelClientWrapper* clientWrapper = m_workerClientWrapper.get();
while (clientWrapper && !clientWrapper->syncMethodDone() && result != MessageQueueTerminated) {
result = runLoop.runInMode(m_workerContext.get(), m_taskMode);
clientWrapper = static_cast<ThreadableWebSocketChannelClientWrapper*>(m_workerClientWrapper.get());
clientWrapper = m_workerClientWrapper.get();
}
}
......
/*
* Copyright (C) 2009 Google Inc. All rights reserved.
* Copyright (C) 2009, 2010 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
......@@ -77,7 +77,7 @@ private:
// lifetimes.
class Peer : public WebSocketChannelClient, public Noncopyable {
public:
static Peer* create(RefPtr<ThreadSafeShared<ThreadableWebSocketChannelClientWrapper> > clientWrapper, WorkerLoaderProxy& loaderProxy, ScriptExecutionContext* context, const String& taskMode, const KURL& url, const String& protocol)
static Peer* create(RefPtr<ThreadableWebSocketChannelClientWrapper> clientWrapper, WorkerLoaderProxy& loaderProxy, ScriptExecutionContext* context, const String& taskMode, const KURL& url, const String& protocol)
{
return new Peer(clientWrapper, loaderProxy, context, taskMode, url, protocol);
}
......@@ -94,9 +94,9 @@ private:
virtual void didClose();
private:
Peer(RefPtr<ThreadSafeShared<ThreadableWebSocketChannelClientWrapper> >, WorkerLoaderProxy&, ScriptExecutionContext*, const String& taskMode, const KURL&, const String& protocol);
Peer(RefPtr<ThreadableWebSocketChannelClientWrapper>, WorkerLoaderProxy&, ScriptExecutionContext*, const String& taskMode, const KURL&, const String& protocol);
RefPtr<ThreadSafeShared<ThreadableWebSocketChannelClientWrapper> > m_workerClientWrapper;
RefPtr<ThreadableWebSocketChannelClientWrapper> m_workerClientWrapper;
WorkerLoaderProxy& m_loaderProxy;
RefPtr<ThreadableWebSocketChannel> m_mainWebSocketChannel;
String m_taskMode;
......@@ -117,10 +117,10 @@ private:
using RefCounted<Bridge>::deref;
private:
static void setWebSocketChannel(ScriptExecutionContext*, Bridge* thisPtr, Peer*, RefPtr<ThreadSafeShared<ThreadableWebSocketChannelClientWrapper> >);
static void setWebSocketChannel(ScriptExecutionContext*, Bridge* thisPtr, Peer*, RefPtr<ThreadableWebSocketChannelClientWrapper>);
// Executed on the main thread to create a Peer for this bridge.
static void mainThreadCreateWebSocketChannel(ScriptExecutionContext*, Bridge* thisPtr, RefPtr<ThreadSafeShared<ThreadableWebSocketChannelClientWrapper> >, const String& taskMode, const KURL&, const String& protocol);
static void mainThreadCreateWebSocketChannel(ScriptExecutionContext*, Bridge* thisPtr, RefPtr<ThreadableWebSocketChannelClientWrapper>, const String& taskMode, const KURL&, const String& protocol);
// Executed on the worker context's thread.
void clearClientWrapper();
......@@ -128,7 +128,7 @@ private:
void setMethodNotCompleted();
void waitForMethodCompletion();
RefPtr<ThreadSafeShared<ThreadableWebSocketChannelClientWrapper> > m_workerClientWrapper;
RefPtr<ThreadableWebSocketChannelClientWrapper> m_workerClientWrapper;
RefPtr<WorkerContext> m_workerContext;
WorkerLoaderProxy& m_loaderProxy;
String m_taskMode;
......
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