gecko-dev/netwerk/ipc/NeckoTargetHolder.cpp
Kershaw Chang 7f73aa6ef7 Bug 1343743 - Part1: Refactoring for mNeckoTarget and ChannelEvent, r=mayhemer
This patch contains two parts below:
1. mNeckoTarget
Since almost all child channels in necko need mNeckoTarget to dispatch runnables to main thread, it seems worth to have a holder class of mNeckoTarget and ask child channels to inherit it.

2. ChannelEvent
A lot of classes in FTPChannelChild and HttpChannelChild inheriting ChannelEvent and override GetEventTarget. It should be worth to extract the same code and put it in the same space.
2017-06-12 00:21:00 +02:00

29 lines
693 B
C++

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set sw=2 ts=8 et tw=80 : */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "NeckoTargetHolder.h"
#include "nsContentUtils.h"
#include "nsILoadInfo.h"
namespace mozilla {
namespace net {
already_AddRefed<nsIEventTarget>
NeckoTargetHolder::GetNeckoTarget()
{
nsCOMPtr<nsIEventTarget> target = mNeckoTarget;
if (!target) {
target = do_GetMainThread();
}
return target.forget();
}
} // namespace net
} // namespace mozilla