зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1408333 Get rid of nsIIPCBackgroundChildCreateCallback - part 17 - HttpBackgroundChannel, r=asuth
This commit is contained in:
Родитель
7e8feb3cb9
Коммит
be83c65dce
|
@ -15,7 +15,6 @@
|
|||
#include "mozilla/ipc/PBackgroundChild.h"
|
||||
#include "mozilla/IntegerPrintfMacros.h"
|
||||
#include "mozilla/Unused.h"
|
||||
#include "nsIIPCBackgroundChildCreateCallback.h"
|
||||
#include "nsSocketTransportService2.h"
|
||||
|
||||
using mozilla::ipc::BackgroundChild;
|
||||
|
@ -24,66 +23,6 @@ using mozilla::ipc::IPCResult;
|
|||
namespace mozilla {
|
||||
namespace net {
|
||||
|
||||
// Callbacks for PBackgroundChild creation
|
||||
class BackgroundChannelCreateCallback final
|
||||
: public nsIIPCBackgroundChildCreateCallback
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIIPCBACKGROUNDCHILDCREATECALLBACK
|
||||
|
||||
explicit BackgroundChannelCreateCallback(HttpBackgroundChannelChild* aBgChild)
|
||||
: mBgChild(aBgChild)
|
||||
{
|
||||
MOZ_ASSERT(OnSocketThread());
|
||||
MOZ_ASSERT(aBgChild);
|
||||
}
|
||||
|
||||
private:
|
||||
virtual ~BackgroundChannelCreateCallback() { }
|
||||
|
||||
RefPtr<HttpBackgroundChannelChild> mBgChild;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS(BackgroundChannelCreateCallback,
|
||||
nsIIPCBackgroundChildCreateCallback)
|
||||
|
||||
void
|
||||
BackgroundChannelCreateCallback::ActorCreated(PBackgroundChild* aActor)
|
||||
{
|
||||
MOZ_ASSERT(OnSocketThread());
|
||||
MOZ_ASSERT(aActor);
|
||||
MOZ_ASSERT(mBgChild);
|
||||
|
||||
if (!mBgChild->mChannelChild) {
|
||||
// HttpChannelChild is closed during PBackground creation,
|
||||
// abort the rest of steps.
|
||||
return;
|
||||
}
|
||||
|
||||
const uint64_t channelId = mBgChild->mChannelChild->ChannelId();
|
||||
if (!aActor->SendPHttpBackgroundChannelConstructor(mBgChild,
|
||||
channelId)) {
|
||||
ActorFailed();
|
||||
return;
|
||||
}
|
||||
|
||||
// hold extra reference for IPDL
|
||||
RefPtr<HttpBackgroundChannelChild> child = mBgChild;
|
||||
Unused << child.forget().take();
|
||||
|
||||
mBgChild->mChannelChild->OnBackgroundChildReady(mBgChild);
|
||||
}
|
||||
|
||||
void
|
||||
BackgroundChannelCreateCallback::ActorFailed()
|
||||
{
|
||||
MOZ_ASSERT(OnSocketThread());
|
||||
MOZ_ASSERT(mBgChild);
|
||||
|
||||
mBgChild->OnBackgroundChannelCreationFailed();
|
||||
}
|
||||
|
||||
// HttpBackgroundChannelChild
|
||||
HttpBackgroundChannelChild::HttpBackgroundChannelChild()
|
||||
{
|
||||
|
@ -147,29 +86,29 @@ HttpBackgroundChannelChild::OnStartRequestReceived()
|
|||
MOZ_ASSERT(mQueuedRunnables.IsEmpty());
|
||||
}
|
||||
|
||||
void
|
||||
HttpBackgroundChannelChild::OnBackgroundChannelCreationFailed()
|
||||
{
|
||||
LOG(("HttpBackgroundChannelChild::OnBackgroundChannelCreationFailed"
|
||||
" [this=%p]\n", this));
|
||||
MOZ_ASSERT(OnSocketThread());
|
||||
|
||||
if (mChannelChild) {
|
||||
RefPtr<HttpChannelChild> channelChild = mChannelChild.forget();
|
||||
channelChild->OnBackgroundChildDestroyed(this);
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
HttpBackgroundChannelChild::CreateBackgroundChannel()
|
||||
{
|
||||
LOG(("HttpBackgroundChannelChild::CreateBackgroundChannel [this=%p]\n", this));
|
||||
MOZ_ASSERT(OnSocketThread());
|
||||
MOZ_ASSERT(mChannelChild);
|
||||
|
||||
RefPtr<BackgroundChannelCreateCallback> callback =
|
||||
new BackgroundChannelCreateCallback(this);
|
||||
PBackgroundChild* actorChild = BackgroundChild::GetOrCreateForCurrentThread();
|
||||
if (NS_WARN_IF(!actorChild)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return BackgroundChild::GetOrCreateForCurrentThread(callback);
|
||||
const uint64_t channelId = mChannelChild->ChannelId();
|
||||
if (!actorChild->SendPHttpBackgroundChannelConstructor(this, channelId)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// hold extra reference for IPDL
|
||||
RefPtr<HttpBackgroundChannelChild> self = this;
|
||||
Unused << self.forget().take();
|
||||
|
||||
mChannelChild->OnBackgroundChildReady(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -40,9 +40,6 @@ public:
|
|||
// Enqueued messages in background channel will be flushed.
|
||||
void OnStartRequestReceived();
|
||||
|
||||
// Callback while failed to create PBackground IPC channel.
|
||||
void OnBackgroundChannelCreationFailed();
|
||||
|
||||
protected:
|
||||
IPCResult RecvOnTransportAndData(const nsresult& aChannelStatus,
|
||||
const nsresult& aTransportStatus,
|
||||
|
|
Загрузка…
Ссылка в новой задаче