зеркало из https://github.com/mozilla/gecko-dev.git
Simplify ImageBridgeChild asynchronous initialization. (bug 1298938 part 2, r=mattwoodrow)
--HG-- extra : rebase_source : 1bdb57079ca7f3b4c2be6d1bcd5dd3f0ee0c92c1
This commit is contained in:
Родитель
82339b2d66
Коммит
d1ef6f2696
|
@ -521,13 +521,6 @@ ImageBridgeChild::CreateCanvasClientSync(SynchronousTask* aTask,
|
|||
*outResult = CreateCanvasClientNow(aType, aFlags);
|
||||
}
|
||||
|
||||
static void ConnectImageBridge(ImageBridgeChild * child, ImageBridgeParent * parent)
|
||||
{
|
||||
MessageLoop *parentMsgLoop = parent->GetMessageLoop();
|
||||
ipc::MessageChannel *parentChannel = parent->GetIPCChannel();
|
||||
child->Open(parentChannel, parentMsgLoop, mozilla::ipc::ChildSide);
|
||||
}
|
||||
|
||||
ImageBridgeChild::ImageBridgeChild()
|
||||
: mShuttingDown(false)
|
||||
, mFwdTransactionId(0)
|
||||
|
@ -872,16 +865,10 @@ void
|
|||
ImageBridgeChild::SendImageBridgeThreadId()
|
||||
{
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
SendImageBridgeThreadId(gettid());
|
||||
PImageBridgeChild::SendImageBridgeThreadId(gettid());
|
||||
#endif
|
||||
}
|
||||
|
||||
static void CallSendImageBridgeThreadId(ImageBridgeChild* aImageBridgeChild)
|
||||
{
|
||||
MOZ_ASSERT(InImageBridgeChildThread());
|
||||
aImageBridgeChild->SendImageBridgeThreadId();
|
||||
}
|
||||
|
||||
bool
|
||||
ImageBridgeChild::InitForContent(Endpoint<PImageBridgeChild>&& aEndpoint)
|
||||
{
|
||||
|
@ -894,22 +881,37 @@ ImageBridgeChild::InitForContent(Endpoint<PImageBridgeChild>&& aEndpoint)
|
|||
return false;
|
||||
}
|
||||
|
||||
sImageBridgeChildSingleton = new ImageBridgeChild();
|
||||
RefPtr<ImageBridgeChild> child = new ImageBridgeChild();
|
||||
|
||||
MessageLoop* loop = sImageBridgeChildSingleton->GetMessageLoop();
|
||||
sImageBridgeChildSingleton = child;
|
||||
|
||||
loop->PostTask(NewRunnableMethod<Endpoint<PImageBridgeChild>&&>(
|
||||
sImageBridgeChildSingleton, &ImageBridgeChild::Bind, Move(aEndpoint)));
|
||||
loop->PostTask(NewRunnableFunction(
|
||||
CallSendImageBridgeThreadId, sImageBridgeChildSingleton.get()));
|
||||
RefPtr<Runnable> runnable = NewRunnableMethod<Endpoint<PImageBridgeChild>&&>(
|
||||
child,
|
||||
&ImageBridgeChild::Bind,
|
||||
Move(aEndpoint));
|
||||
child->GetMessageLoop()->PostTask(runnable.forget());
|
||||
|
||||
return sImageBridgeChildSingleton;
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
ImageBridgeChild::Bind(Endpoint<PImageBridgeChild>&& aEndpoint)
|
||||
{
|
||||
aEndpoint.Bind(this);
|
||||
if (!aEndpoint.Bind(this)) {
|
||||
return;
|
||||
}
|
||||
|
||||
SendImageBridgeThreadId();
|
||||
}
|
||||
|
||||
void
|
||||
ImageBridgeChild::BindSameProcess(RefPtr<ImageBridgeParent> aParent)
|
||||
{
|
||||
MessageLoop *parentMsgLoop = aParent->GetMessageLoop();
|
||||
ipc::MessageChannel *parentChannel = aParent->GetIPCChannel();
|
||||
Open(parentChannel, parentMsgLoop, mozilla::ipc::ChildSide);
|
||||
|
||||
SendImageBridgeThreadId();
|
||||
}
|
||||
|
||||
void ImageBridgeChild::ShutDown()
|
||||
|
@ -959,13 +961,16 @@ ImageBridgeChild::InitSameProcess()
|
|||
sImageBridgeChildThread->Start();
|
||||
}
|
||||
|
||||
sImageBridgeChildSingleton = new ImageBridgeChild();
|
||||
RefPtr<ImageBridgeChild> child = new ImageBridgeChild();
|
||||
RefPtr<ImageBridgeParent> parent = ImageBridgeParent::CreateSameProcess();
|
||||
|
||||
sImageBridgeChildSingleton->ConnectAsync(parent);
|
||||
sImageBridgeChildSingleton->GetMessageLoop()->PostTask(
|
||||
NewRunnableFunction(CallSendImageBridgeThreadId,
|
||||
sImageBridgeChildSingleton.get()));
|
||||
sImageBridgeChildSingleton = child;
|
||||
|
||||
RefPtr<Runnable> runnable = WrapRunnable(
|
||||
child,
|
||||
&ImageBridgeChild::BindSameProcess,
|
||||
parent);
|
||||
child->GetMessageLoop()->PostTask(runnable.forget());
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
|
@ -998,12 +1003,6 @@ MessageLoop * ImageBridgeChild::GetMessageLoop() const
|
|||
return sImageBridgeChildThread ? sImageBridgeChildThread->message_loop() : nullptr;
|
||||
}
|
||||
|
||||
void ImageBridgeChild::ConnectAsync(ImageBridgeParent* aParent)
|
||||
{
|
||||
GetMessageLoop()->PostTask(NewRunnableFunction(&ConnectImageBridge,
|
||||
this, aParent));
|
||||
}
|
||||
|
||||
void
|
||||
ImageBridgeChild::IdentifyCompositorTextureHost(const TextureFactoryIdentifier& aIdentifier)
|
||||
{
|
||||
|
|
|
@ -160,14 +160,6 @@ public:
|
|||
static ImageBridgeChild* GetSingleton();
|
||||
|
||||
|
||||
/**
|
||||
* Dispatches a task to the ImageBridgeChild thread to do the connection
|
||||
*/
|
||||
void ConnectAsync(ImageBridgeParent* aParent);
|
||||
|
||||
using PImageBridgeChild::SendImageBridgeThreadId;
|
||||
void SendImageBridgeThreadId();
|
||||
|
||||
static void IdentifyCompositorTextureHost(const TextureFactoryIdentifier& aIdentifier);
|
||||
|
||||
void BeginTransaction();
|
||||
|
@ -402,6 +394,9 @@ protected:
|
|||
bool aUnsafe);
|
||||
|
||||
void Bind(Endpoint<PImageBridgeChild>&& aEndpoint);
|
||||
void BindSameProcess(RefPtr<ImageBridgeParent> aParent);
|
||||
|
||||
void SendImageBridgeThreadId();
|
||||
|
||||
private:
|
||||
CompositableTransaction* mTxn;
|
||||
|
|
Загрузка…
Ссылка в новой задаче