зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1519636 - Reformat recent changes to the Google coding style r=Ehsan
# ignore-this-changeset Differential Revision: https://phabricator.services.mozilla.com/D58175 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
4a2545c164
Коммит
c521758c5e
|
@ -31,7 +31,7 @@ class PresShell;
|
|||
namespace dom {
|
||||
class DOMStringList;
|
||||
class Element;
|
||||
}
|
||||
} // namespace dom
|
||||
|
||||
namespace a11y {
|
||||
|
||||
|
|
|
@ -262,7 +262,7 @@ int main(int argc, char* argv[], char* envp[]) {
|
|||
// argc & argv will be updated with the values passing from the
|
||||
// chrome process. With the new values, this function
|
||||
// continues the reset of the code acting as a content process.
|
||||
if(gBootstrap->XRE_ForkServer(&argc, &argv)) {
|
||||
if (gBootstrap->XRE_ForkServer(&argc, &argv)) {
|
||||
// Return from the fork server in the fork server process.
|
||||
// Stop the fork server.
|
||||
gBootstrap->NS_LogTerm();
|
||||
|
|
|
@ -65,11 +65,11 @@ LauncherVoidResultWithLineInfo InitializeDllBlocklistOOP(
|
|||
// safely make its ntdll calls.
|
||||
|
||||
HMODULE ourModule;
|
||||
#if defined(_MSC_VER)
|
||||
# if defined(_MSC_VER)
|
||||
ourModule = reinterpret_cast<HMODULE>(&__ImageBase);
|
||||
#else
|
||||
# else
|
||||
ourModule = ::GetModuleHandleW(nullptr);
|
||||
#endif // defined(_MSC_VER)
|
||||
# endif // defined(_MSC_VER)
|
||||
|
||||
mozilla::nt::PEHeaders ourExeImage(ourModule);
|
||||
if (!ourExeImage) {
|
||||
|
@ -84,7 +84,7 @@ LauncherVoidResultWithLineInfo InitializeDllBlocklistOOP(
|
|||
return importDirRestored;
|
||||
}
|
||||
|
||||
Maybe<Span<IMAGE_THUNK_DATA>> ntdllThunks =
|
||||
Maybe<Span<IMAGE_THUNK_DATA> > ntdllThunks =
|
||||
ourExeImage.GetIATThunksForModule("ntdll.dll");
|
||||
if (!ntdllThunks) {
|
||||
return LAUNCHER_ERROR_FROM_WIN32(ERROR_INVALID_DATA);
|
||||
|
|
|
@ -57,7 +57,12 @@ class ContentPrincipal final : public BasePrincipal {
|
|||
|
||||
virtual nsresult PopulateJSONObject(Json::Value& aObject) override;
|
||||
// Serializable keys are the valid enum fields the serialization supports
|
||||
enum SerializableKeys : uint8_t { eURI = 0, eDomain, eSuffix, eMax = eSuffix };
|
||||
enum SerializableKeys : uint8_t {
|
||||
eURI = 0,
|
||||
eDomain,
|
||||
eSuffix,
|
||||
eMax = eSuffix
|
||||
};
|
||||
typedef mozilla::BasePrincipal::KeyValT<SerializableKeys> KeyVal;
|
||||
|
||||
static already_AddRefed<BasePrincipal> FromProperties(
|
||||
|
|
|
@ -37,7 +37,6 @@ namespace dom {
|
|||
|
||||
class ChildSHistory : public nsISupports, public nsWrapperCache {
|
||||
public:
|
||||
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(ChildSHistory)
|
||||
nsISupports* GetParentObject() const;
|
||||
|
|
|
@ -188,19 +188,19 @@ class Optional : public Optional_base<T, T> {
|
|||
};
|
||||
|
||||
template <typename T>
|
||||
class Optional<JS::Handle<T> >
|
||||
: public Optional_base<JS::Handle<T>, JS::Rooted<T> > {
|
||||
class Optional<JS::Handle<T>>
|
||||
: public Optional_base<JS::Handle<T>, JS::Rooted<T>> {
|
||||
public:
|
||||
MOZ_ALLOW_TEMPORARY Optional()
|
||||
: Optional_base<JS::Handle<T>, JS::Rooted<T> >() {}
|
||||
: Optional_base<JS::Handle<T>, JS::Rooted<T>>() {}
|
||||
|
||||
explicit Optional(JSContext* cx)
|
||||
: Optional_base<JS::Handle<T>, JS::Rooted<T> >() {
|
||||
: Optional_base<JS::Handle<T>, JS::Rooted<T>>() {
|
||||
this->Construct(cx);
|
||||
}
|
||||
|
||||
Optional(JSContext* cx, const T& aValue)
|
||||
: Optional_base<JS::Handle<T>, JS::Rooted<T> >(cx, aValue) {}
|
||||
: Optional_base<JS::Handle<T>, JS::Rooted<T>>(cx, aValue) {}
|
||||
|
||||
// Override the const Value() to return the right thing so we're not
|
||||
// returning references to temporaries.
|
||||
|
@ -249,7 +249,7 @@ class Optional<JS::Value> {
|
|||
template <typename U>
|
||||
class NonNull;
|
||||
template <typename T>
|
||||
class Optional<NonNull<T> > : public Optional_base<T, NonNull<T> > {
|
||||
class Optional<NonNull<T>> : public Optional_base<T, NonNull<T>> {
|
||||
public:
|
||||
// We want our Value to actually return a non-const reference, even
|
||||
// if we're const. At least for things that are normally pointer
|
||||
|
@ -264,7 +264,7 @@ class Optional<NonNull<T> > : public Optional_base<T, NonNull<T> > {
|
|||
// A specialization of Optional for OwningNonNull that lets us get a
|
||||
// T& from Value()
|
||||
template <typename T>
|
||||
class Optional<OwningNonNull<T> > : public Optional_base<T, OwningNonNull<T> > {
|
||||
class Optional<OwningNonNull<T>> : public Optional_base<T, OwningNonNull<T>> {
|
||||
public:
|
||||
// We want our Value to actually return a non-const reference, even
|
||||
// if we're const. At least for things that are normally pointer
|
||||
|
@ -412,8 +412,10 @@ template <typename T>
|
|||
class Sequence : public FallibleTArray<T> {
|
||||
public:
|
||||
Sequence() : FallibleTArray<T>() {}
|
||||
MOZ_IMPLICIT Sequence(FallibleTArray<T>&& aArray) : FallibleTArray<T>(std::move(aArray)) {}
|
||||
MOZ_IMPLICIT Sequence(nsTArray<T>&& aArray) : FallibleTArray<T>(std::move(aArray)) {}
|
||||
MOZ_IMPLICIT Sequence(FallibleTArray<T>&& aArray)
|
||||
: FallibleTArray<T>(std::move(aArray)) {}
|
||||
MOZ_IMPLICIT Sequence(nsTArray<T>&& aArray)
|
||||
: FallibleTArray<T>(std::move(aArray)) {}
|
||||
};
|
||||
|
||||
inline nsWrapperCache* GetWrapperCache(nsWrapperCache* cache) { return cache; }
|
||||
|
|
|
@ -27,7 +27,8 @@ class WrapperCachedNonISupportsTestInterface final : public nsWrapperCache {
|
|||
public:
|
||||
WrapperCachedNonISupportsTestInterface() {}
|
||||
|
||||
static already_AddRefed<WrapperCachedNonISupportsTestInterface> Constructor(const GlobalObject& aGlobalObject);
|
||||
static already_AddRefed<WrapperCachedNonISupportsTestInterface> Constructor(
|
||||
const GlobalObject& aGlobalObject);
|
||||
|
||||
protected:
|
||||
~WrapperCachedNonISupportsTestInterface() {}
|
||||
|
|
|
@ -28,8 +28,8 @@ class LSSnapshotInitInfo;
|
|||
class LSWriteAndNotifyInfo;
|
||||
class SnapshotWriteOptimizer;
|
||||
|
||||
template <typename> class Optional;
|
||||
|
||||
template <typename>
|
||||
class Optional;
|
||||
|
||||
class LSSnapshot final : public nsIRunnable {
|
||||
public:
|
||||
|
|
|
@ -13,7 +13,8 @@
|
|||
class mozIStorageStatement;
|
||||
|
||||
namespace IPC {
|
||||
template <typename> struct ParamTraits;
|
||||
template <typename>
|
||||
struct ParamTraits;
|
||||
}
|
||||
|
||||
namespace mozilla {
|
||||
|
|
|
@ -114,7 +114,8 @@ void FileBlockCache::Flush() {
|
|||
// Dispatch a task so we won't clear the arrays while PerformBlockIOs() is
|
||||
// dropping the data lock and cause InvalidArrayIndex.
|
||||
RefPtr<FileBlockCache> self = this;
|
||||
mBackgroundET->Dispatch(NS_NewRunnableFunction("FileBlockCache::Flush", [self]() {
|
||||
mBackgroundET->Dispatch(
|
||||
NS_NewRunnableFunction("FileBlockCache::Flush", [self]() {
|
||||
MutexAutoLock mon(self->mDataMutex);
|
||||
// Just discard pending changes, assume MediaCache won't read from
|
||||
// blocks it hasn't written to.
|
||||
|
@ -175,16 +176,17 @@ void FileBlockCache::Close() {
|
|||
}
|
||||
|
||||
// Let the thread close the FD, and then trigger its own shutdown.
|
||||
// Note that mBackgroundET is now empty, so no other task will be posted there.
|
||||
// Also mBackgroundET and mFD are empty and therefore can be reused immediately.
|
||||
nsresult rv = thread->Dispatch(
|
||||
NS_NewRunnableFunction(
|
||||
"FileBlockCache::Close",
|
||||
// Note that mBackgroundET is now empty, so no other task will be posted
|
||||
// there. Also mBackgroundET and mFD are empty and therefore can be reused
|
||||
// immediately.
|
||||
nsresult rv = thread->Dispatch(NS_NewRunnableFunction("FileBlockCache::Close",
|
||||
[thread, fd] {
|
||||
if (fd) {
|
||||
CloseFD(fd);
|
||||
}
|
||||
// No need to shutdown background task queues.
|
||||
// No need to shutdown
|
||||
// background task
|
||||
// queues.
|
||||
}),
|
||||
NS_DISPATCH_EVENT_MAY_BLOCK);
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
|
|
|
@ -363,8 +363,7 @@ void HLSTrackDemuxer::UpdateMediaInfo(int index) {
|
|||
audioInfo->mBitDepth = audioInfoObj->BitDepth();
|
||||
audioInfo->mMimeType =
|
||||
NS_ConvertUTF16toUTF8(audioInfoObj->MimeType()->ToString());
|
||||
audioInfo->mDuration =
|
||||
TimeUnit::FromMicroseconds(audioInfoObj->Duration());
|
||||
audioInfo->mDuration = TimeUnit::FromMicroseconds(audioInfoObj->Duration());
|
||||
jni::ByteArray::LocalRef csdBytes = audioInfoObj->CodecSpecificData();
|
||||
if (csdBytes) {
|
||||
auto&& csd = csdBytes->GetElements();
|
||||
|
@ -389,11 +388,9 @@ void HLSTrackDemuxer::UpdateMediaInfo(int index) {
|
|||
videoInfo->mDisplay.height = videoInfoObj->PictureHeight();
|
||||
videoInfo->mMimeType =
|
||||
NS_ConvertUTF16toUTF8(videoInfoObj->MimeType()->ToString());
|
||||
videoInfo->mDuration =
|
||||
TimeUnit::FromMicroseconds(videoInfoObj->Duration());
|
||||
HLS_DEBUG("HLSTrackDemuxer",
|
||||
"Update video info (%d) / I(%dx%d) / D(%dx%d)", index,
|
||||
videoInfo->mImage.width, videoInfo->mImage.height,
|
||||
videoInfo->mDuration = TimeUnit::FromMicroseconds(videoInfoObj->Duration());
|
||||
HLS_DEBUG("HLSTrackDemuxer", "Update video info (%d) / I(%dx%d) / D(%dx%d)",
|
||||
index, videoInfo->mImage.width, videoInfo->mImage.height,
|
||||
videoInfo->mDisplay.width, videoInfo->mDisplay.height);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,8 @@ typedef mozilla::Pair<nsCString, mozilla::Maybe<nsString>>
|
|||
|
||||
class nsContentSecurityUtils {
|
||||
public:
|
||||
static FilenameTypeAndDetails FilenameToFilenameType(const nsString& fileName);
|
||||
static FilenameTypeAndDetails FilenameToFilenameType(
|
||||
const nsString& fileName);
|
||||
static bool IsEvalAllowed(JSContext* cx, bool aIsSystemPrincipal,
|
||||
const nsAString& aScript);
|
||||
static void NotifyEvalUsage(bool aIsSystemPrincipal,
|
||||
|
|
|
@ -53,7 +53,8 @@ struct ScaleFactors2D {
|
|||
return ScaleFactor<src, dst>(xScale);
|
||||
}
|
||||
|
||||
ScaleFactors2D<src, dst>& operator=(const ScaleFactors2D<src, dst>&) = default;
|
||||
ScaleFactors2D<src, dst>& operator=(const ScaleFactors2D<src, dst>&) =
|
||||
default;
|
||||
|
||||
bool operator==(const ScaleFactors2D<src, dst>& aOther) const {
|
||||
return xScale == aOther.xScale && yScale == aOther.yScale;
|
||||
|
|
|
@ -86,7 +86,8 @@ class ImageDecoderListener final : public nsIStreamListener,
|
|||
: mURI(aURI),
|
||||
mImage(nullptr),
|
||||
mCallback(aCallback),
|
||||
mObserver(aObserver ? new NotificationObserverWrapper(aObserver) : nullptr) {
|
||||
mObserver(aObserver ? new NotificationObserverWrapper(aObserver)
|
||||
: nullptr) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
}
|
||||
|
||||
|
|
|
@ -13,8 +13,7 @@
|
|||
|
||||
using namespace mozilla;
|
||||
|
||||
static bool
|
||||
UseForkServer(int argc, char* argv[]) {
|
||||
static bool UseForkServer(int argc, char* argv[]) {
|
||||
#if defined(MOZ_ENABLE_FORKSERVER)
|
||||
return strcmp(argv[argc - 1], "forkserver") == 0;
|
||||
#else
|
||||
|
@ -22,8 +21,8 @@ UseForkServer(int argc, char* argv[]) {
|
|||
#endif
|
||||
}
|
||||
|
||||
static int
|
||||
RunForkServer(Bootstrap::UniquePtr&& bootstrap, int argc, char* argv[]) {
|
||||
static int RunForkServer(Bootstrap::UniquePtr&& bootstrap, int argc,
|
||||
char* argv[]) {
|
||||
#if defined(MOZ_ENABLE_FORKSERVER)
|
||||
int ret = 0;
|
||||
|
||||
|
@ -38,7 +37,7 @@ RunForkServer(Bootstrap::UniquePtr&& bootstrap, int argc, char* argv[]) {
|
|||
// argc & argv will be updated with the values passing from the
|
||||
// chrome process. With the new values, this function
|
||||
// continues the reset of the code acting as a content process.
|
||||
if(bootstrap->XRE_ForkServer(&argc, &argv)) {
|
||||
if (bootstrap->XRE_ForkServer(&argc, &argv)) {
|
||||
// Return from the fork server in the fork server process.
|
||||
// Stop the fork server.
|
||||
} else {
|
||||
|
|
|
@ -44,15 +44,15 @@
|
|||
#include "mozilla/ipc/EnvironmentMap.h"
|
||||
|
||||
#if defined(MOZ_ENABLE_FORKSERVER)
|
||||
#include "nsString.h"
|
||||
#include "mozilla/Tuple.h"
|
||||
#include "mozilla/ipc/FileDescriptorShuffle.h"
|
||||
# include "nsString.h"
|
||||
# include "mozilla/Tuple.h"
|
||||
# include "mozilla/ipc/FileDescriptorShuffle.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace ipc {
|
||||
class FileDescriptor;
|
||||
}
|
||||
}
|
||||
} // namespace mozilla
|
||||
#endif
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
|
@ -195,7 +195,7 @@ EnvironmentArray BuildEnvironmentArray(const environment_map& env_vars_to_set);
|
|||
* and second step, that is why two steps.
|
||||
*/
|
||||
class AppProcessBuilder {
|
||||
public:
|
||||
public:
|
||||
AppProcessBuilder();
|
||||
// This function will fork a new process for use as a
|
||||
// content processes.
|
||||
|
@ -209,10 +209,10 @@ public:
|
|||
// The message loop may allocate resources like file descriptors.
|
||||
// If this function is called before the end of the loop, the
|
||||
// reosurces may be destroyed while the loop is still alive.
|
||||
void InitAppProcess(int *argcp, char*** argvp);
|
||||
void InitAppProcess(int* argcp, char*** argvp);
|
||||
|
||||
private:
|
||||
void ReplaceArguments(int *argcp, char*** argvp);
|
||||
private:
|
||||
void ReplaceArguments(int* argcp, char*** argvp);
|
||||
|
||||
mozilla::ipc::FileDescriptorShuffle shuffle_;
|
||||
std::vector<std::string> argv_;
|
||||
|
|
|
@ -14,18 +14,18 @@
|
|||
#include "algorithm"
|
||||
|
||||
#if defined(MOZ_ENABLE_FORKSERVER)
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
# include <stdlib.h>
|
||||
# include <sys/types.h>
|
||||
# include <sys/stat.h>
|
||||
# include <fcntl.h>
|
||||
# if defined(DEBUG)
|
||||
#include "base/message_loop.h"
|
||||
# include "base/message_loop.h"
|
||||
# endif
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "mozilla/ipc/ForkServiceChild.h"
|
||||
# include "mozilla/DebugOnly.h"
|
||||
# include "mozilla/ipc/ForkServiceChild.h"
|
||||
|
||||
#include "mozilla/Unused.h"
|
||||
#include "mozilla/ScopeExit.h"
|
||||
# include "mozilla/Unused.h"
|
||||
# include "mozilla/ScopeExit.h"
|
||||
|
||||
using namespace mozilla::ipc;
|
||||
#endif
|
||||
|
@ -51,16 +51,14 @@ namespace base {
|
|||
#if defined(MOZ_ENABLE_FORKSERVER)
|
||||
static mozilla::StaticAutoPtr<std::vector<int> > sNoCloseFDs;
|
||||
|
||||
void
|
||||
RegisterForkServerNoCloseFD(int fd) {
|
||||
void RegisterForkServerNoCloseFD(int fd) {
|
||||
if (!sNoCloseFDs) {
|
||||
sNoCloseFDs = new std::vector<int>();
|
||||
}
|
||||
sNoCloseFDs->push_back(fd);
|
||||
}
|
||||
|
||||
static bool
|
||||
IsNoCloseFd(int fd) {
|
||||
static bool IsNoCloseFd(int fd) {
|
||||
if (!sNoCloseFDs) {
|
||||
return false;
|
||||
}
|
||||
|
@ -68,19 +66,17 @@ IsNoCloseFd(int fd) {
|
|||
[fd](int regfd) -> bool { return regfd == fd; });
|
||||
}
|
||||
|
||||
AppProcessBuilder::AppProcessBuilder() {
|
||||
}
|
||||
AppProcessBuilder::AppProcessBuilder() {}
|
||||
|
||||
static void
|
||||
ReplaceEnviroment(const LaunchOptions& options) {
|
||||
static void ReplaceEnviroment(const LaunchOptions& options) {
|
||||
for (auto& elt : options.env_map) {
|
||||
setenv(elt.first.c_str(), elt.second.c_str(), 1);
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
AppProcessBuilder::ForkProcess(const std::vector<std::string>& argv,
|
||||
const LaunchOptions& options, ProcessHandle* process_handle) {
|
||||
bool AppProcessBuilder::ForkProcess(const std::vector<std::string>& argv,
|
||||
const LaunchOptions& options,
|
||||
ProcessHandle* process_handle) {
|
||||
auto cleanFDs = mozilla::MakeScopeExit([&] {
|
||||
for (auto& elt : options.fds_to_remap) {
|
||||
auto fd = std::get<0>(elt);
|
||||
|
@ -98,16 +94,16 @@ AppProcessBuilder::ForkProcess(const std::vector<std::string>& argv,
|
|||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
|
||||
#ifdef OS_LINUX
|
||||
# ifdef OS_LINUX
|
||||
pid_t pid = options.fork_delegate ? options.fork_delegate->Fork() : fork();
|
||||
// WARNING: if pid == 0, only async signal safe operations are permitted from
|
||||
// here until exec or _exit.
|
||||
//
|
||||
// Specifically, heap allocation is not safe: the sandbox's fork substitute
|
||||
// won't run the pthread_atfork handlers that fix up the malloc locks.
|
||||
#else
|
||||
# else
|
||||
pid_t pid = fork();
|
||||
#endif
|
||||
# endif
|
||||
|
||||
if (pid < 0) {
|
||||
return false;
|
||||
|
@ -127,8 +123,7 @@ AppProcessBuilder::ForkProcess(const std::vector<std::string>& argv,
|
|||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
AppProcessBuilder::ReplaceArguments(int *argcp, char*** argvp) {
|
||||
void AppProcessBuilder::ReplaceArguments(int* argcp, char*** argvp) {
|
||||
// Change argc & argv of main() with the arguments passing
|
||||
// through IPC.
|
||||
char** argv = new char*[argv_.size() + 1];
|
||||
|
@ -141,8 +136,7 @@ AppProcessBuilder::ReplaceArguments(int *argcp, char*** argvp) {
|
|||
*argcp = argv_.size();
|
||||
}
|
||||
|
||||
void
|
||||
AppProcessBuilder::InitAppProcess(int *argcp, char*** argvp) {
|
||||
void AppProcessBuilder::InitAppProcess(int* argcp, char*** argvp) {
|
||||
MOZ_ASSERT(MessageLoop::current() == nullptr,
|
||||
"The message loop of the main thread should have been destroyed");
|
||||
|
||||
|
@ -157,8 +151,7 @@ AppProcessBuilder::InitAppProcess(int *argcp, char*** argvp) {
|
|||
}
|
||||
|
||||
CloseSuperfluousFds(&shuffle_, [](void* ctx, int fd) {
|
||||
return static_cast<decltype(&shuffle_)>(ctx)->MapsTo(fd) ||
|
||||
IsNoCloseFd(fd);
|
||||
return static_cast<decltype(&shuffle_)>(ctx)->MapsTo(fd) || IsNoCloseFd(fd);
|
||||
});
|
||||
// Without this, the destructor of |shuffle_| would try to close FDs
|
||||
// created by it, but they have been closed by
|
||||
|
@ -168,21 +161,16 @@ AppProcessBuilder::InitAppProcess(int *argcp, char*** argvp) {
|
|||
ReplaceArguments(argcp, argvp);
|
||||
}
|
||||
|
||||
static void
|
||||
handle_sigchld(int s) {
|
||||
waitpid(-1, nullptr, WNOHANG);
|
||||
}
|
||||
static void handle_sigchld(int s) { waitpid(-1, nullptr, WNOHANG); }
|
||||
|
||||
static void
|
||||
InstallChildSignalHandler() {
|
||||
static void InstallChildSignalHandler() {
|
||||
// Since content processes are not children of the chrome process
|
||||
// any more, the fork server process has to handle SIGCHLD, or
|
||||
// content process would remain zombie after dead.
|
||||
signal(SIGCHLD, handle_sigchld);
|
||||
}
|
||||
|
||||
static void
|
||||
ReserveFileDescriptors() {
|
||||
static void ReserveFileDescriptors() {
|
||||
// Reserve the lower positions of the file descriptors to make sure
|
||||
// debug files and other files don't take these positions. So we
|
||||
// can keep their file descriptors during CloseSuperfluousFds() with
|
||||
|
@ -193,14 +181,12 @@ ReserveFileDescriptors() {
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
InitForkServerProcess() {
|
||||
void InitForkServerProcess() {
|
||||
InstallChildSignalHandler();
|
||||
ReserveFileDescriptors();
|
||||
}
|
||||
|
||||
static bool
|
||||
LaunchAppWithForkServer(const std::vector<std::string>& argv,
|
||||
static bool LaunchAppWithForkServer(const std::vector<std::string>& argv,
|
||||
const LaunchOptions& options,
|
||||
ProcessHandle* process_handle) {
|
||||
MOZ_ASSERT(ForkServiceChild::Get());
|
||||
|
@ -217,12 +203,11 @@ LaunchAppWithForkServer(const std::vector<std::string>& argv,
|
|||
nsCString(vv.second.c_str())));
|
||||
}
|
||||
for (auto& fdmapping : options.fds_to_remap) {
|
||||
fdsremap.AppendElement(mozilla::FdMapping(mozilla::ipc::FileDescriptor(fdmapping.first),
|
||||
fdmapping.second));
|
||||
fdsremap.AppendElement(mozilla::FdMapping(
|
||||
mozilla::ipc::FileDescriptor(fdmapping.first), fdmapping.second));
|
||||
}
|
||||
|
||||
return ForkServiceChild::Get()->SendForkNewSubprocess(_argv, env,
|
||||
fdsremap,
|
||||
return ForkServiceChild::Get()->SendForkNewSubprocess(_argv, env, fdsremap,
|
||||
process_handle);
|
||||
}
|
||||
#endif // MOZ_ENABLE_FORKSERVER
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace mozilla {
|
|||
namespace ipc {
|
||||
class MiniTransceiver;
|
||||
}
|
||||
}
|
||||
} // namespace mozilla
|
||||
|
||||
class FileDescriptorSet;
|
||||
|
||||
|
|
|
@ -51,9 +51,7 @@ class FileDescriptorShuffle {
|
|||
|
||||
// Forget the information, so that it's destructor will not try to
|
||||
// delete FDs duped by itself.
|
||||
void Forget() {
|
||||
mTempFds.Clear();
|
||||
}
|
||||
void Forget() { mTempFds.Clear(); }
|
||||
|
||||
private:
|
||||
nsTArray<std::pair<int, int>> mMapping;
|
||||
|
|
|
@ -14,12 +14,11 @@
|
|||
#include <fcntl.h>
|
||||
|
||||
#if defined(XP_LINUX) && defined(MOZ_SANDBOX)
|
||||
#include "mozilla/SandboxLaunch.h"
|
||||
# include "mozilla/SandboxLaunch.h"
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
namespace mozilla {
|
||||
namespace ipc {
|
||||
|
||||
|
@ -27,14 +26,12 @@ static const int sClientFd = 3;
|
|||
|
||||
LazyLogModule gForkServiceLog("ForkService");
|
||||
|
||||
ForkServer::ForkServer() {
|
||||
}
|
||||
ForkServer::ForkServer() {}
|
||||
|
||||
/**
|
||||
* Prepare an environment for running a fork server.
|
||||
*/
|
||||
void
|
||||
ForkServer::InitProcess(int* aArgc, char*** aArgv) {
|
||||
void ForkServer::InitProcess(int* aArgc, char*** aArgv) {
|
||||
base::InitForkServerProcess();
|
||||
|
||||
int fd = sClientFd;
|
||||
|
@ -46,13 +43,12 @@ ForkServer::InitProcess(int* aArgc, char*** aArgv) {
|
|||
/**
|
||||
* Start providing the service at the IPC channel.
|
||||
*/
|
||||
bool
|
||||
ForkServer::HandleMessages() {
|
||||
bool ForkServer::HandleMessages() {
|
||||
// |sClientFd| is created by an instance of |IPC::Channel|.
|
||||
// It sends a HELLO automatically.
|
||||
IPC::Message hello;
|
||||
mTcver->RecvInfallible(hello,
|
||||
"Expect to receive a HELLO message from the parent process!");
|
||||
mTcver->RecvInfallible(
|
||||
hello, "Expect to receive a HELLO message from the parent process!");
|
||||
MOZ_ASSERT(hello.type() == kHELLO_MESSAGE_TYPE);
|
||||
|
||||
// Send it back
|
||||
|
@ -75,16 +71,14 @@ ForkServer::HandleMessages() {
|
|||
return true;
|
||||
}
|
||||
|
||||
inline void
|
||||
CleanCString(nsCString& str) {
|
||||
inline void CleanCString(nsCString& str) {
|
||||
char* data;
|
||||
int sz = str.GetMutableData(&data);
|
||||
|
||||
memset(data, ' ', sz);
|
||||
}
|
||||
|
||||
inline void
|
||||
CleanString(std::string& str) {
|
||||
inline void CleanString(std::string& str) {
|
||||
const char deadbeef[] =
|
||||
"\xde\xad\xbe\xef\xde\xad\xbe\xef\xde\xad\xbe\xef\xde\xad\xbe\xef"
|
||||
"\xde\xad\xbe\xef\xde\xad\xbe\xef\xde\xad\xbe\xef\xde\xad\xbe\xef";
|
||||
|
@ -98,8 +92,7 @@ CleanString(std::string& str) {
|
|||
}
|
||||
}
|
||||
|
||||
inline void
|
||||
PrepareArguments(std::vector<std::string>& aArgv,
|
||||
inline void PrepareArguments(std::vector<std::string>& aArgv,
|
||||
nsTArray<nsCString>& aArgvArray) {
|
||||
for (auto& elt : aArgvArray) {
|
||||
aArgv.push_back(elt.get());
|
||||
|
@ -108,11 +101,11 @@ PrepareArguments(std::vector<std::string>& aArgv,
|
|||
}
|
||||
|
||||
// Prepare aOptions->env_map
|
||||
inline void
|
||||
PrepareEnv(base::LaunchOptions* aOptions, nsTArray<EnvVar>& aEnvMap) {
|
||||
inline void PrepareEnv(base::LaunchOptions* aOptions,
|
||||
nsTArray<EnvVar>& aEnvMap) {
|
||||
for (auto& elt : aEnvMap) {
|
||||
nsCString &var = Get<0>(elt);
|
||||
nsCString &val = Get<1>(elt);
|
||||
nsCString& var = Get<0>(elt);
|
||||
nsCString& val = Get<1>(elt);
|
||||
aOptions->env_map[var.get()] = val.get();
|
||||
CleanCString(var);
|
||||
CleanCString(val);
|
||||
|
@ -120,8 +113,7 @@ PrepareEnv(base::LaunchOptions* aOptions, nsTArray<EnvVar>& aEnvMap) {
|
|||
}
|
||||
|
||||
// Prepare aOptions->fds_to_remap
|
||||
inline void
|
||||
PrepareFdsRemap(base::LaunchOptions* aOptions,
|
||||
inline void PrepareFdsRemap(base::LaunchOptions* aOptions,
|
||||
nsTArray<FdMapping>& aFdsRemap) {
|
||||
MOZ_LOG(gForkServiceLog, LogLevel::Verbose, ("fds mapping:"));
|
||||
for (auto& elt : aFdsRemap) {
|
||||
|
@ -137,8 +129,7 @@ PrepareFdsRemap(base::LaunchOptions* aOptions,
|
|||
/**
|
||||
* Parse a Message to get a list of arguments and fill a LaunchOptions.
|
||||
*/
|
||||
inline bool
|
||||
ParseForkNewSubprocess(IPC::Message& aMsg,
|
||||
inline bool ParseForkNewSubprocess(IPC::Message& aMsg,
|
||||
std::vector<std::string>& aArgv,
|
||||
base::LaunchOptions* aOptions) {
|
||||
if (aMsg.type() != Msg_ForkNewSubprocess__ID) {
|
||||
|
@ -167,15 +158,12 @@ ParseForkNewSubprocess(IPC::Message& aMsg,
|
|||
return true;
|
||||
}
|
||||
|
||||
inline void
|
||||
SanitizeBuffers(IPC::Message& aMsg,
|
||||
std::vector<std::string>& aArgv,
|
||||
inline void SanitizeBuffers(IPC::Message& aMsg, std::vector<std::string>& aArgv,
|
||||
base::LaunchOptions& aOptions) {
|
||||
// Clean all buffers in the message to make sure content processes
|
||||
// not peeking others.
|
||||
auto& blist = aMsg.Buffers();
|
||||
for (auto itr = blist.Iter();
|
||||
!itr.Done();
|
||||
for (auto itr = blist.Iter(); !itr.Done();
|
||||
itr.Advance(blist, itr.RemainingInSegment())) {
|
||||
memset(itr.Data(), 0, itr.RemainingInSegment());
|
||||
}
|
||||
|
@ -198,8 +186,7 @@ SanitizeBuffers(IPC::Message& aMsg,
|
|||
* It will return in both the fork server process and the new content
|
||||
* process. |mAppProcBuilder| is null for the fork server.
|
||||
*/
|
||||
void
|
||||
ForkServer::OnMessageReceived(IPC::Message&& message) {
|
||||
void ForkServer::OnMessageReceived(IPC::Message&& message) {
|
||||
IPC::Message msg(std::move(message));
|
||||
|
||||
std::vector<std::string> argv;
|
||||
|
@ -230,8 +217,7 @@ ForkServer::OnMessageReceived(IPC::Message&& message) {
|
|||
|
||||
IPC::Message reply(MSG_ROUTING_CONTROL, Reply_ForkNewSubprocess__ID);
|
||||
WriteIPDLParam(&reply, nullptr, child_pid);
|
||||
mTcver->SendInfallible(reply,
|
||||
"failed to send a reply message");
|
||||
mTcver->SendInfallible(reply, "failed to send a reply message");
|
||||
|
||||
// Without this, the content processes that is forked later are
|
||||
// able to read the content of buffers even the buffers have been
|
||||
|
@ -250,11 +236,11 @@ ForkServer::OnMessageReceived(IPC::Message&& message) {
|
|||
* For the later case, aArgc and aArgv are modified to pass the
|
||||
* arguments from the chrome process.
|
||||
*/
|
||||
bool
|
||||
ForkServer::RunForkServer(int* aArgc, char*** aArgv) {
|
||||
bool ForkServer::RunForkServer(int* aArgc, char*** aArgv) {
|
||||
#ifdef DEBUG
|
||||
if (getenv("MOZ_FORKSERVER_WAIT_GDB")) {
|
||||
printf("Waiting for 30 seconds."
|
||||
printf(
|
||||
"Waiting for 30 seconds."
|
||||
" Attach the fork server with gdb %s %d\n",
|
||||
(*aArgv)[0], base::GetCurrentProcId());
|
||||
sleep(30);
|
||||
|
@ -276,7 +262,8 @@ ForkServer::RunForkServer(int* aArgc, char*** aArgv) {
|
|||
if (forkserver.HandleMessages()) {
|
||||
// In the fork server process
|
||||
// The server has stopped.
|
||||
MOZ_LOG(gForkServiceLog, LogLevel::Verbose, ("Terminate the fork server"));
|
||||
MOZ_LOG(gForkServiceLog, LogLevel::Verbose,
|
||||
("Terminate the fork server"));
|
||||
NS_LogTerm();
|
||||
return true;
|
||||
}
|
||||
|
@ -287,7 +274,8 @@ ForkServer::RunForkServer(int* aArgc, char*** aArgv) {
|
|||
}
|
||||
#ifdef DEBUG
|
||||
if (sleep_newproc) {
|
||||
printf("Waiting for 30 seconds."
|
||||
printf(
|
||||
"Waiting for 30 seconds."
|
||||
" Attach the new process with gdb %s %d\n",
|
||||
(*aArgv)[0], base::GetCurrentProcId());
|
||||
sleep(30);
|
||||
|
@ -303,7 +291,8 @@ ForkServer::RunForkServer(int* aArgc, char*** aArgv) {
|
|||
forkserver.mAppProcBuilder->InitAppProcess(aArgc, aArgv);
|
||||
forkserver.mAppProcBuilder.reset();
|
||||
|
||||
MOZ_ASSERT(NS_LITERAL_CSTRING("tab") == (*aArgv)[*aArgc - 1], "Only |tab| is allowed!");
|
||||
MOZ_ASSERT(NS_LITERAL_CSTRING("tab") == (*aArgv)[*aArgc - 1],
|
||||
"Only |tab| is allowed!");
|
||||
|
||||
// Open log files again with right names and the new PID.
|
||||
nsTraceRefcnt::ResetLogFiles((*aArgv)[*aArgc - 1]);
|
||||
|
@ -311,5 +300,5 @@ ForkServer::RunForkServer(int* aArgc, char*** aArgv) {
|
|||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} // namespace ipc
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -14,11 +14,11 @@ namespace mozilla {
|
|||
namespace ipc {
|
||||
|
||||
class ForkServer {
|
||||
public:
|
||||
public:
|
||||
static const int kHELLO_MESSAGE_TYPE = 65535;
|
||||
|
||||
ForkServer();
|
||||
~ForkServer() {};
|
||||
~ForkServer(){};
|
||||
|
||||
void InitProcess(int* aArgc, char*** aArgv);
|
||||
bool HandleMessages();
|
||||
|
@ -28,7 +28,7 @@ public:
|
|||
|
||||
static bool RunForkServer(int* aArgc, char*** aArgv);
|
||||
|
||||
private:
|
||||
private:
|
||||
UniquePtr<MiniTransceiver> mTcver;
|
||||
UniquePtr<base::AppProcessBuilder> mAppProcBuilder;
|
||||
};
|
||||
|
@ -38,7 +38,7 @@ enum {
|
|||
Reply_ForkNewSubprocess__ID,
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
} // namespace ipc
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // __FORKSERVER_H_
|
||||
|
|
|
@ -19,11 +19,10 @@ extern LazyLogModule gForkServiceLog;
|
|||
|
||||
mozilla::UniquePtr<ForkServiceChild> ForkServiceChild::sForkServiceChild;
|
||||
|
||||
void
|
||||
ForkServiceChild::StartForkServer() {
|
||||
void ForkServiceChild::StartForkServer() {
|
||||
std::vector<std::string> extraArgs;
|
||||
|
||||
GeckoChildProcessHost *subprocess =
|
||||
GeckoChildProcessHost* subprocess =
|
||||
new GeckoChildProcessHost(GeckoProcessType_ForkServer, false);
|
||||
subprocess->LaunchAndWaitForProcessHandle(std::move(extraArgs));
|
||||
|
||||
|
@ -41,14 +40,10 @@ ForkServiceChild::StartForkServer() {
|
|||
subprocess->GetChannel()->Close();
|
||||
}
|
||||
|
||||
void
|
||||
ForkServiceChild::StopForkServer() {
|
||||
sForkServiceChild = nullptr;
|
||||
}
|
||||
void ForkServiceChild::StopForkServer() { sForkServiceChild = nullptr; }
|
||||
|
||||
ForkServiceChild::ForkServiceChild(int aFd, GeckoChildProcessHost* aProcess)
|
||||
: mWaitForHello(true)
|
||||
, mProcess(aProcess) {
|
||||
: mWaitForHello(true), mProcess(aProcess) {
|
||||
mTcver = MakeUnique<MiniTransceiver>(aFd);
|
||||
}
|
||||
|
||||
|
@ -57,11 +52,9 @@ ForkServiceChild::~ForkServiceChild() {
|
|||
close(mTcver->GetFD());
|
||||
}
|
||||
|
||||
bool
|
||||
ForkServiceChild::SendForkNewSubprocess(const nsTArray<nsCString>& aArgv,
|
||||
const nsTArray<EnvVar>& aEnvMap,
|
||||
const nsTArray<FdMapping>& aFdsRemap,
|
||||
pid_t* aPid) {
|
||||
bool ForkServiceChild::SendForkNewSubprocess(
|
||||
const nsTArray<nsCString>& aArgv, const nsTArray<EnvVar>& aEnvMap,
|
||||
const nsTArray<FdMapping>& aFdsRemap, pid_t* aPid) {
|
||||
if (mWaitForHello) {
|
||||
// IPC::Channel created by the GeckoChildProcessHost has
|
||||
// already send a HELLO. It is expected to receive a hello
|
||||
|
@ -97,8 +90,7 @@ ForkServiceChild::SendForkNewSubprocess(const nsTArray<nsCString>& aArgv,
|
|||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
ForkServiceChild::OnMessageReceived(IPC::Message&& message) {
|
||||
void ForkServiceChild::OnMessageReceived(IPC::Message&& message) {
|
||||
if (message.type() != Reply_ForkNewSubprocess__ID) {
|
||||
MOZ_LOG(gForkServiceLog, LogLevel::Verbose,
|
||||
("unknown reply type %d", message.type()));
|
||||
|
@ -117,14 +109,11 @@ NS_IMPL_ISUPPORTS(ForkServerLauncher, nsIObserver)
|
|||
bool ForkServerLauncher::mHaveStartedClient = false;
|
||||
StaticRefPtr<ForkServerLauncher> ForkServerLauncher::mSingleton;
|
||||
|
||||
ForkServerLauncher::ForkServerLauncher() {
|
||||
}
|
||||
ForkServerLauncher::ForkServerLauncher() {}
|
||||
|
||||
ForkServerLauncher::~ForkServerLauncher() {
|
||||
}
|
||||
ForkServerLauncher::~ForkServerLauncher() {}
|
||||
|
||||
already_AddRefed<ForkServerLauncher>
|
||||
ForkServerLauncher::Create() {
|
||||
already_AddRefed<ForkServerLauncher> ForkServerLauncher::Create() {
|
||||
if (mSingleton == nullptr) {
|
||||
mSingleton = new ForkServerLauncher();
|
||||
}
|
||||
|
@ -133,19 +122,20 @@ ForkServerLauncher::Create() {
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ForkServerLauncher::Observe(nsISupports* aSubject,
|
||||
const char* aTopic,
|
||||
ForkServerLauncher::Observe(nsISupports* aSubject, const char* aTopic,
|
||||
const char16_t* aData) {
|
||||
if (!mHaveStartedClient && strcmp(aTopic, NS_XPCOM_STARTUP_CATEGORY) == 0) {
|
||||
mHaveStartedClient = true;
|
||||
ForkServiceChild::StartForkServer();
|
||||
|
||||
nsCOMPtr<nsIObserverService> obsSvc = mozilla::services::GetObserverService();
|
||||
nsCOMPtr<nsIObserverService> obsSvc =
|
||||
mozilla::services::GetObserverService();
|
||||
MOZ_ASSERT(obsSvc != nullptr);
|
||||
obsSvc->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
|
||||
}
|
||||
|
||||
if (mHaveStartedClient && strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID) == 0) {
|
||||
if (mHaveStartedClient &&
|
||||
strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID) == 0) {
|
||||
mHaveStartedClient = false;
|
||||
ForkServiceChild::StopForkServer();
|
||||
|
||||
|
@ -155,5 +145,5 @@ ForkServerLauncher::Observe(nsISupports* aSubject,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} // namespace ipc
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -26,7 +26,7 @@ class GeckoChildProcessHost;
|
|||
* pipe and get the PID of the new process from the reply.
|
||||
*/
|
||||
class ForkServiceChild {
|
||||
public:
|
||||
public:
|
||||
ForkServiceChild(int aFd, GeckoChildProcessHost* aProcess);
|
||||
virtual ~ForkServiceChild();
|
||||
|
||||
|
@ -42,11 +42,9 @@ public:
|
|||
* \param aPid returns the PID of the content process created.
|
||||
* \return true if success.
|
||||
*/
|
||||
bool SendForkNewSubprocess(
|
||||
const nsTArray<nsCString>& aArgv,
|
||||
bool SendForkNewSubprocess(const nsTArray<nsCString>& aArgv,
|
||||
const nsTArray<EnvVar>& aEnvMap,
|
||||
const nsTArray<FdMapping>& aFdsRemap,
|
||||
pid_t* aPid);
|
||||
const nsTArray<FdMapping>& aFdsRemap, pid_t* aPid);
|
||||
|
||||
/**
|
||||
* Create a fork server process and the singleton of this class.
|
||||
|
@ -62,7 +60,7 @@ public:
|
|||
*/
|
||||
static ForkServiceChild* Get() { return sForkServiceChild.get(); }
|
||||
|
||||
private:
|
||||
private:
|
||||
// Called when a message is received.
|
||||
void OnMessageReceived(IPC::Message&& message);
|
||||
|
||||
|
@ -77,21 +75,21 @@ private:
|
|||
* Start a fork server at |xpcom-startup| from the chrome process.
|
||||
*/
|
||||
class ForkServerLauncher : public nsIObserver {
|
||||
public:
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
ForkServerLauncher();
|
||||
static already_AddRefed<ForkServerLauncher> Create();
|
||||
|
||||
private:
|
||||
private:
|
||||
virtual ~ForkServerLauncher();
|
||||
|
||||
static bool mHaveStartedClient;
|
||||
static StaticRefPtr<ForkServerLauncher> mSingleton;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
} // namespace ipc
|
||||
} // namespace mozilla
|
||||
|
||||
#endif /* __FORKSERVICE_CHILD_H_ */
|
||||
|
|
|
@ -831,7 +831,8 @@ void BaseProcessLauncher::GetChildLogName(const char* origLogName,
|
|||
//
|
||||
// Fork server needs a dedicated thread for accessing
|
||||
// |ForkServiceChild|.
|
||||
#if defined(XP_WIN) || defined(MOZ_WIDGET_ANDROID) || defined(MOZ_ENABLE_FORKSERVER)
|
||||
#if defined(XP_WIN) || defined(MOZ_WIDGET_ANDROID) || \
|
||||
defined(MOZ_ENABLE_FORKSERVER)
|
||||
|
||||
static mozilla::StaticMutex gIPCLaunchThreadMutex;
|
||||
static mozilla::StaticRefPtr<nsIThread> gIPCLaunchThread;
|
||||
|
@ -884,7 +885,8 @@ nsCOMPtr<nsIEventTarget> GetIPCLauncher() {
|
|||
return thread;
|
||||
}
|
||||
|
||||
#else // defined(XP_WIN) || defined(MOZ_WIDGET_ANDROID) || defined(MOZ_ENABLE_FORKSERVER)
|
||||
#else // defined(XP_WIN) || defined(MOZ_WIDGET_ANDROID) ||
|
||||
// defined(MOZ_ENABLE_FORKSERVER)
|
||||
|
||||
// Other platforms use an on-demand thread pool.
|
||||
|
||||
|
|
|
@ -69,10 +69,9 @@ static MOZ_NEVER_INLINE bool ReadIPDLParam(const IPC::Message* aMsg,
|
|||
}
|
||||
|
||||
template <typename P>
|
||||
static MOZ_NEVER_INLINE bool ReadIPDLParamInfallible(const IPC::Message* aMsg,
|
||||
PickleIterator* aIter,
|
||||
IProtocol* aActor, P* aResult,
|
||||
const char* aCrashMessage) {
|
||||
static MOZ_NEVER_INLINE bool ReadIPDLParamInfallible(
|
||||
const IPC::Message* aMsg, PickleIterator* aIter, IProtocol* aActor,
|
||||
P* aResult, const char* aCrashMessage) {
|
||||
bool ok = ReadIPDLParam(aMsg, aIter, aActor, aResult);
|
||||
if (!ok) {
|
||||
MOZ_CRASH_UNSAFE(aCrashMessage);
|
||||
|
|
|
@ -32,10 +32,10 @@ MiniTransceiver::MiniTransceiver(int aFd, DataBufferClear aDataBufClear)
|
|||
namespace {
|
||||
|
||||
/**
|
||||
* Initialize the IO vector for sending data and the control buffer for sending FDs.
|
||||
* Initialize the IO vector for sending data and the control buffer for sending
|
||||
* FDs.
|
||||
*/
|
||||
static void
|
||||
InitMsgHdr(msghdr* aHdr, int aIOVSize, int aMaxNumFds) {
|
||||
static void InitMsgHdr(msghdr* aHdr, int aIOVSize, int aMaxNumFds) {
|
||||
aHdr->msg_name = nullptr;
|
||||
aHdr->msg_namelen = 0;
|
||||
aHdr->msg_flags = 0;
|
||||
|
@ -54,20 +54,18 @@ InitMsgHdr(msghdr* aHdr, int aIOVSize, int aMaxNumFds) {
|
|||
/**
|
||||
* Delete resources allocated by InitMsgHdr().
|
||||
*/
|
||||
static void
|
||||
DeinitMsgHdr(msghdr* aHdr) {
|
||||
static void DeinitMsgHdr(msghdr* aHdr) {
|
||||
delete aHdr->msg_iov;
|
||||
delete static_cast<char*>(aHdr->msg_control);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void
|
||||
MiniTransceiver::PrepareFDs(msghdr* aHdr, IPC::Message& aMsg) {
|
||||
void MiniTransceiver::PrepareFDs(msghdr* aHdr, IPC::Message& aMsg) {
|
||||
// Set control buffer to send file descriptors of the Message.
|
||||
int num_fds = aMsg.file_descriptor_set()->size();
|
||||
|
||||
cmsghdr *cmsg = CMSG_FIRSTHDR(aHdr);
|
||||
cmsghdr* cmsg = CMSG_FIRSTHDR(aHdr);
|
||||
cmsg->cmsg_level = SOL_SOCKET;
|
||||
cmsg->cmsg_type = SCM_RIGHTS;
|
||||
cmsg->cmsg_len = CMSG_LEN(sizeof(int) * num_fds);
|
||||
|
@ -79,14 +77,12 @@ MiniTransceiver::PrepareFDs(msghdr* aHdr, IPC::Message& aMsg) {
|
|||
aMsg.header()->num_fds = num_fds;
|
||||
}
|
||||
|
||||
size_t
|
||||
MiniTransceiver::PrepareBuffers(msghdr* aHdr, IPC::Message& aMsg) {
|
||||
size_t MiniTransceiver::PrepareBuffers(msghdr* aHdr, IPC::Message& aMsg) {
|
||||
// Set iovec to send for all buffers of the Message.
|
||||
iovec *iov = aHdr->msg_iov;
|
||||
iovec* iov = aHdr->msg_iov;
|
||||
size_t iovlen = 0;
|
||||
size_t bytes_to_send = 0;
|
||||
for (Pickle::BufferList::IterImpl iter(aMsg.Buffers());
|
||||
!iter.Done();
|
||||
for (Pickle::BufferList::IterImpl iter(aMsg.Buffers()); !iter.Done();
|
||||
iter.Advance(aMsg.Buffers(), iter.RemainingInSegment())) {
|
||||
char* data = iter.Data();
|
||||
size_t size = iter.RemainingInSegment();
|
||||
|
@ -102,18 +98,18 @@ MiniTransceiver::PrepareBuffers(msghdr* aHdr, IPC::Message& aMsg) {
|
|||
return bytes_to_send;
|
||||
}
|
||||
|
||||
bool
|
||||
MiniTransceiver::Send(IPC::Message& aMsg) {
|
||||
bool MiniTransceiver::Send(IPC::Message& aMsg) {
|
||||
#ifdef DEBUG
|
||||
if (mState == STATE_SENDING) {
|
||||
MOZ_CRASH("STATE_SENDING: It violates of request-response and no concurrent rules");
|
||||
MOZ_CRASH(
|
||||
"STATE_SENDING: It violates of request-response and no concurrent "
|
||||
"rules");
|
||||
}
|
||||
mState = STATE_SENDING;
|
||||
#endif
|
||||
|
||||
auto clean_fdset = MakeScopeExit([&] {
|
||||
aMsg.file_descriptor_set()->CommitAll();
|
||||
});
|
||||
auto clean_fdset =
|
||||
MakeScopeExit([&] { aMsg.file_descriptor_set()->CommitAll(); });
|
||||
|
||||
int num_fds = aMsg.file_descriptor_set()->size();
|
||||
msghdr hdr;
|
||||
|
@ -132,23 +128,22 @@ MiniTransceiver::Send(IPC::Message& aMsg) {
|
|||
NS_WARNING(error);
|
||||
return false;
|
||||
}
|
||||
MOZ_ASSERT(bytes_written == (ssize_t)bytes_to_send, "The message is too big?!");
|
||||
MOZ_ASSERT(bytes_written == (ssize_t)bytes_to_send,
|
||||
"The message is too big?!");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
unsigned
|
||||
MiniTransceiver::RecvFDs(msghdr* aHdr, int* aAllFds, unsigned aMaxFds) {
|
||||
unsigned MiniTransceiver::RecvFDs(msghdr* aHdr, int* aAllFds,
|
||||
unsigned aMaxFds) {
|
||||
if (aHdr->msg_controllen == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned num_all_fds = 0;
|
||||
for (cmsghdr* cmsg = CMSG_FIRSTHDR(aHdr);
|
||||
cmsg;
|
||||
for (cmsghdr* cmsg = CMSG_FIRSTHDR(aHdr); cmsg;
|
||||
cmsg = CMSG_NXTHDR(aHdr, cmsg)) {
|
||||
MOZ_ASSERT(cmsg->cmsg_level == SOL_SOCKET &&
|
||||
cmsg->cmsg_type == SCM_RIGHTS,
|
||||
MOZ_ASSERT(cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_RIGHTS,
|
||||
"Accept only SCM_RIGHTS to receive file descriptors");
|
||||
|
||||
unsigned payload_sz = cmsg->cmsg_len - CMSG_LEN(0);
|
||||
|
@ -165,9 +160,9 @@ MiniTransceiver::RecvFDs(msghdr* aHdr, int* aAllFds, unsigned aMaxFds) {
|
|||
return num_all_fds;
|
||||
}
|
||||
|
||||
bool
|
||||
MiniTransceiver::RecvData(char* aDataBuf, size_t aBufSize, uint32_t* aMsgSize,
|
||||
int* aFdsBuf, unsigned aMaxFds, unsigned* aNumFds) {
|
||||
bool MiniTransceiver::RecvData(char* aDataBuf, size_t aBufSize,
|
||||
uint32_t* aMsgSize, int* aFdsBuf,
|
||||
unsigned aMaxFds, unsigned* aNumFds) {
|
||||
msghdr hdr;
|
||||
InitMsgHdr(&hdr, 1, aMaxFds);
|
||||
|
||||
|
@ -207,11 +202,12 @@ MiniTransceiver::RecvData(char* aDataBuf, size_t aBufSize, uint32_t* aMsgSize,
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
MiniTransceiver::Recv(IPC::Message& aMsg) {
|
||||
bool MiniTransceiver::Recv(IPC::Message& aMsg) {
|
||||
#ifdef DEBUG
|
||||
if (mState == STATE_RECEIVING) {
|
||||
MOZ_CRASH("STATE_RECEIVING: It violates of request-response and no concurrent rules");
|
||||
MOZ_CRASH(
|
||||
"STATE_RECEIVING: It violates of request-response and no concurrent "
|
||||
"rules");
|
||||
}
|
||||
mState = STATE_RECEIVING;
|
||||
#endif
|
||||
|
@ -221,8 +217,8 @@ MiniTransceiver::Recv(IPC::Message& aMsg) {
|
|||
int all_fds[kMaxNumFds];
|
||||
unsigned num_all_fds = 0;
|
||||
|
||||
if (!RecvData(databuf.get(), kMaxDataSize, &msgsz,
|
||||
all_fds, kMaxDataSize, &num_all_fds)) {
|
||||
if (!RecvData(databuf.get(), kMaxDataSize, &msgsz, all_fds, kMaxDataSize,
|
||||
&num_all_fds)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,10 +14,7 @@ struct msghdr;
|
|||
namespace mozilla {
|
||||
namespace ipc {
|
||||
|
||||
enum class DataBufferClear {
|
||||
None,
|
||||
AfterReceiving
|
||||
};
|
||||
enum class DataBufferClear { None, AfterReceiving };
|
||||
|
||||
/**
|
||||
* This simple implementation handles the transmissions of IPC
|
||||
|
@ -31,13 +28,14 @@ enum class DataBufferClear {
|
|||
* complexity of asynchronous I/O.
|
||||
*/
|
||||
class MiniTransceiver {
|
||||
public:
|
||||
public:
|
||||
/**
|
||||
* \param aFd should be a blocking, no O_NONBLOCK, fd.
|
||||
* \param aClearDataBuf is true to clear data buffers after
|
||||
* receiving a message.
|
||||
*/
|
||||
explicit MiniTransceiver(int aFd, DataBufferClear aDataBufClear = DataBufferClear::None);
|
||||
explicit MiniTransceiver(
|
||||
int aFd, DataBufferClear aDataBufClear = DataBufferClear::None);
|
||||
|
||||
bool Send(IPC::Message& aMsg);
|
||||
inline bool SendInfallible(IPC::Message& aMsg, const char* aCrashMessage) {
|
||||
|
@ -63,7 +61,7 @@ public:
|
|||
|
||||
int GetFD() { return mFd; }
|
||||
|
||||
private:
|
||||
private:
|
||||
/**
|
||||
* Set control buffer to make file descriptors ready to be sent
|
||||
* through a socket.
|
||||
|
@ -113,7 +111,7 @@ private:
|
|||
DataBufferClear mDataBufClear;
|
||||
};
|
||||
|
||||
} // ipc
|
||||
} // mozilla
|
||||
} // namespace ipc
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // __MINITRANSCEIVER_H_
|
||||
|
|
|
@ -1099,7 +1099,8 @@ static bool GetDisplayPortImpl(
|
|||
result = GetDisplayPortFromRectData(aContent, rectData, aMultiplier);
|
||||
} else if (isDisplayportSuppressed ||
|
||||
nsLayoutUtils::ShouldDisableApzForElement(aContent)) {
|
||||
DisplayPortMarginsPropertyData noMargins(ScreenMargin(), 1, /*painted=*/false);
|
||||
DisplayPortMarginsPropertyData noMargins(ScreenMargin(), 1,
|
||||
/*painted=*/false);
|
||||
result = GetDisplayPortFromMarginsData(aContent, &noMargins, aMultiplier);
|
||||
} else {
|
||||
result = GetDisplayPortFromMarginsData(aContent, marginsData, aMultiplier);
|
||||
|
@ -1143,8 +1144,7 @@ bool nsLayoutUtils::GetDisplayPort(
|
|||
bool usingDisplayPort =
|
||||
GetDisplayPortImpl(aContent, aResult, multiplier,
|
||||
MaxSizeExceededBehaviour::Assert, aOutPainted);
|
||||
if (aResult && usingDisplayPort &&
|
||||
aRelativeTo == RelativeTo::ScrollFrame) {
|
||||
if (aResult && usingDisplayPort && aRelativeTo == RelativeTo::ScrollFrame) {
|
||||
TranslateFromScrollPortToScrollFrame(aContent, aResult);
|
||||
}
|
||||
return usingDisplayPort;
|
||||
|
|
|
@ -485,8 +485,7 @@ bool nsImageFrame::UpdateIntrinsicSize() {
|
|||
return mIntrinsicSize != oldIntrinsicSize;
|
||||
}
|
||||
|
||||
static AspectRatio ComputeAspectRatio(imgIContainer* aImage,
|
||||
bool aHasRequest,
|
||||
static AspectRatio ComputeAspectRatio(imgIContainer* aImage, bool aHasRequest,
|
||||
const nsImageFrame& aFrame) {
|
||||
const ComputedStyle& style = *aFrame.Style();
|
||||
if (style.StyleDisplay()->IsContainSize()) {
|
||||
|
@ -718,8 +717,7 @@ void nsImageFrame::UpdateImage(imgIRequest* aRequest, imgIContainer* aImage) {
|
|||
}
|
||||
// NOTE(emilio): Intentionally using `|` instead of `||` to avoid
|
||||
// short-circuiting.
|
||||
bool intrinsicSizeChanged =
|
||||
UpdateIntrinsicSize() | UpdateIntrinsicRatio();
|
||||
bool intrinsicSizeChanged = UpdateIntrinsicSize() | UpdateIntrinsicRatio();
|
||||
if (!GotInitialReflow()) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -71,8 +71,7 @@ class nsMathMLContainerFrame : public nsContainerFrame, public nsMathMLFrame {
|
|||
if (aFlags & (eLineParticipant | eSupportsContainLayoutAndPaint)) {
|
||||
return false;
|
||||
}
|
||||
return nsContainerFrame::IsFrameOfType(
|
||||
aFlags & ~eMathML);
|
||||
return nsContainerFrame::IsFrameOfType(aFlags & ~eMathML);
|
||||
}
|
||||
|
||||
virtual void AppendFrames(ChildListID aListID,
|
||||
|
@ -419,8 +418,7 @@ class nsMathMLmathBlockFrame final : public nsBlockFrame {
|
|||
}
|
||||
|
||||
virtual bool IsFrameOfType(uint32_t aFlags) const override {
|
||||
return nsBlockFrame::IsFrameOfType(
|
||||
aFlags & ~nsIFrame::eMathML);
|
||||
return nsBlockFrame::IsFrameOfType(aFlags & ~nsIFrame::eMathML);
|
||||
}
|
||||
|
||||
// See nsIMathMLFrame.h
|
||||
|
@ -488,8 +486,7 @@ class nsMathMLmathInlineFrame final : public nsInlineFrame,
|
|||
}
|
||||
|
||||
virtual bool IsFrameOfType(uint32_t aFlags) const override {
|
||||
return nsInlineFrame::IsFrameOfType(
|
||||
aFlags & ~nsIFrame::eMathML);
|
||||
return nsInlineFrame::IsFrameOfType(aFlags & ~nsIFrame::eMathML);
|
||||
}
|
||||
|
||||
bool IsMrowLike() override {
|
||||
|
|
|
@ -272,8 +272,7 @@ class nsMathMLmtdInnerFrame final : public nsBlockFrame, public nsMathMLFrame {
|
|||
nsReflowStatus& aStatus) override;
|
||||
|
||||
virtual bool IsFrameOfType(uint32_t aFlags) const override {
|
||||
return nsBlockFrame::IsFrameOfType(
|
||||
aFlags & ~nsIFrame::eMathML);
|
||||
return nsBlockFrame::IsFrameOfType(aFlags & ~nsIFrame::eMathML);
|
||||
}
|
||||
|
||||
virtual const nsStyleText* StyleTextForLineLayout() override;
|
||||
|
|
|
@ -116,8 +116,8 @@ class nsBoxFrame : public nsContainerFrame {
|
|||
// that contains a block so ReflowInput doesn't tell us to be
|
||||
// NS_UNCONSTRAINEDSIZE wide.)
|
||||
return nsContainerFrame::IsFrameOfType(
|
||||
aFlags & ~(nsIFrame::eReplaced | nsIFrame::eReplacedContainsBlock |
|
||||
eXULBox));
|
||||
aFlags &
|
||||
~(nsIFrame::eReplaced | nsIFrame::eReplacedContainsBlock | eXULBox));
|
||||
}
|
||||
|
||||
#ifdef DEBUG_FRAME_DUMP
|
||||
|
|
|
@ -1407,7 +1407,7 @@ TEST_F(VideoConduitTest, TestVideoEncodeMaxFsNegotiatedThenSinkWants) {
|
|||
SendVideoFrame(1280, 720, frame++);
|
||||
ASSERT_EQ(sink->mVideoFrame.width(), 960);
|
||||
ASSERT_EQ(sink->mVideoFrame.height(), 540);
|
||||
ASSERT_EQ(sink->mVideoFrame.timestamp_us(), (frame-1)*1000);
|
||||
ASSERT_EQ(sink->mVideoFrame.timestamp_us(), (frame - 1) * 1000);
|
||||
ASSERT_EQ(sink->mOnFrameCount, frame);
|
||||
|
||||
wants.max_pixel_count = 3600 * 16 * 16;
|
||||
|
@ -1416,7 +1416,7 @@ TEST_F(VideoConduitTest, TestVideoEncodeMaxFsNegotiatedThenSinkWants) {
|
|||
SendVideoFrame(1280, 720, frame++);
|
||||
ASSERT_EQ(sink->mVideoFrame.width(), 960);
|
||||
ASSERT_EQ(sink->mVideoFrame.height(), 540);
|
||||
ASSERT_EQ(sink->mVideoFrame.timestamp_us(), (frame-1)*1000);
|
||||
ASSERT_EQ(sink->mVideoFrame.timestamp_us(), (frame - 1) * 1000);
|
||||
ASSERT_EQ(sink->mOnFrameCount, frame);
|
||||
|
||||
mVideoConduit->StopTransmitting();
|
||||
|
@ -1445,7 +1445,7 @@ TEST_F(VideoConduitTest, TestVideoEncodeMaxFsCodecChange) {
|
|||
SendVideoFrame(1280, 720, frame++);
|
||||
ASSERT_EQ(sink->mVideoFrame.width(), 960);
|
||||
ASSERT_EQ(sink->mVideoFrame.height(), 540);
|
||||
ASSERT_EQ(sink->mVideoFrame.timestamp_us(), (frame-1)*1000);
|
||||
ASSERT_EQ(sink->mVideoFrame.timestamp_us(), (frame - 1) * 1000);
|
||||
ASSERT_EQ(sink->mOnFrameCount, frame);
|
||||
|
||||
VideoCodecConfig codecConfigVP9(121, "VP9", constraints);
|
||||
|
@ -1457,7 +1457,7 @@ TEST_F(VideoConduitTest, TestVideoEncodeMaxFsCodecChange) {
|
|||
SendVideoFrame(1280, 720, frame++);
|
||||
ASSERT_EQ(sink->mVideoFrame.width(), 960);
|
||||
ASSERT_EQ(sink->mVideoFrame.height(), 540);
|
||||
ASSERT_EQ(sink->mVideoFrame.timestamp_us(), (frame-1)*1000);
|
||||
ASSERT_EQ(sink->mVideoFrame.timestamp_us(), (frame - 1) * 1000);
|
||||
ASSERT_EQ(sink->mOnFrameCount, frame);
|
||||
|
||||
mVideoConduit->StopTransmitting();
|
||||
|
@ -1486,7 +1486,7 @@ TEST_F(VideoConduitTest, TestVideoEncodeMaxFsSinkWantsThenCodecChange) {
|
|||
SendVideoFrame(1280, 720, frame++);
|
||||
ASSERT_EQ(sink->mVideoFrame.width(), 960);
|
||||
ASSERT_EQ(sink->mVideoFrame.height(), 540);
|
||||
ASSERT_EQ(sink->mVideoFrame.timestamp_us(), (frame-1)*1000);
|
||||
ASSERT_EQ(sink->mVideoFrame.timestamp_us(), (frame - 1) * 1000);
|
||||
ASSERT_EQ(sink->mOnFrameCount, frame);
|
||||
|
||||
VideoCodecConfig codecConfigVP9(121, "VP9", constraints);
|
||||
|
@ -1497,7 +1497,7 @@ TEST_F(VideoConduitTest, TestVideoEncodeMaxFsSinkWantsThenCodecChange) {
|
|||
SendVideoFrame(1280, 720, frame++);
|
||||
ASSERT_EQ(sink->mVideoFrame.width(), 960);
|
||||
ASSERT_EQ(sink->mVideoFrame.height(), 540);
|
||||
ASSERT_EQ(sink->mVideoFrame.timestamp_us(), (frame-1)*1000);
|
||||
ASSERT_EQ(sink->mVideoFrame.timestamp_us(), (frame - 1) * 1000);
|
||||
ASSERT_EQ(sink->mOnFrameCount, frame);
|
||||
|
||||
mVideoConduit->StopTransmitting();
|
||||
|
@ -1524,7 +1524,7 @@ TEST_F(VideoConduitTest, TestVideoEncodeMaxFsNegotiated) {
|
|||
SendVideoFrame(1280, 720, frame++);
|
||||
ASSERT_EQ(sink->mVideoFrame.width(), 1280);
|
||||
ASSERT_EQ(sink->mVideoFrame.height(), 720);
|
||||
ASSERT_EQ(sink->mVideoFrame.timestamp_us(), (frame-1)*1000);
|
||||
ASSERT_EQ(sink->mVideoFrame.timestamp_us(), (frame - 1) * 1000);
|
||||
ASSERT_EQ(sink->mOnFrameCount, frame);
|
||||
|
||||
// Ensure that negotiating a new max-fs works
|
||||
|
@ -1535,7 +1535,7 @@ TEST_F(VideoConduitTest, TestVideoEncodeMaxFsNegotiated) {
|
|||
SendVideoFrame(1280, 720, frame++);
|
||||
ASSERT_EQ(sink->mVideoFrame.width(), 960);
|
||||
ASSERT_EQ(sink->mVideoFrame.height(), 540);
|
||||
ASSERT_EQ(sink->mVideoFrame.timestamp_us(), (frame-1)*1000);
|
||||
ASSERT_EQ(sink->mVideoFrame.timestamp_us(), (frame - 1) * 1000);
|
||||
ASSERT_EQ(sink->mOnFrameCount, frame);
|
||||
|
||||
// Ensure that negotiating max-fs away works
|
||||
|
@ -1546,7 +1546,7 @@ TEST_F(VideoConduitTest, TestVideoEncodeMaxFsNegotiated) {
|
|||
SendVideoFrame(1280, 720, frame++);
|
||||
ASSERT_EQ(sink->mVideoFrame.width(), 1280);
|
||||
ASSERT_EQ(sink->mVideoFrame.height(), 720);
|
||||
ASSERT_EQ(sink->mVideoFrame.timestamp_us(), (frame-1)*1000);
|
||||
ASSERT_EQ(sink->mVideoFrame.timestamp_us(), (frame - 1) * 1000);
|
||||
ASSERT_EQ(sink->mOnFrameCount, frame);
|
||||
|
||||
mVideoConduit->StopTransmitting();
|
||||
|
|
|
@ -208,7 +208,8 @@ class WebrtcVideoConduit
|
|||
*/
|
||||
void AddOrUpdateSink(rtc::VideoSinkInterface<webrtc::VideoFrame>* sink,
|
||||
const rtc::VideoSinkWants& wants) override;
|
||||
void AddOrUpdateSinkNotLocked(rtc::VideoSinkInterface<webrtc::VideoFrame>* sink,
|
||||
void AddOrUpdateSinkNotLocked(
|
||||
rtc::VideoSinkInterface<webrtc::VideoFrame>* sink,
|
||||
const rtc::VideoSinkWants& wants);
|
||||
|
||||
void RemoveSink(rtc::VideoSinkInterface<webrtc::VideoFrame>* sink) override;
|
||||
|
|
|
@ -12,12 +12,13 @@
|
|||
namespace mozilla {
|
||||
|
||||
class RTCStatsIdGenerator {
|
||||
public:
|
||||
public:
|
||||
RTCStatsIdGenerator();
|
||||
nsString Id(const nsString& aKey);
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(RTCStatsIdGenerator);
|
||||
private:
|
||||
virtual ~RTCStatsIdGenerator() {};
|
||||
|
||||
private:
|
||||
virtual ~RTCStatsIdGenerator(){};
|
||||
nsString Generate();
|
||||
|
||||
const uint64_t mSalt;
|
||||
|
@ -25,5 +26,5 @@ private:
|
|||
std::map<nsString, nsString> mAllocated;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace mozilla
|
||||
#endif
|
||||
|
|
|
@ -241,9 +241,7 @@ struct MemorySectionNameBuf : public _MEMORY_SECTION_NAME {
|
|||
mSectionFileName.Buffer = mBuf;
|
||||
}
|
||||
|
||||
MemorySectionNameBuf(const MemorySectionNameBuf& aOther) {
|
||||
*this = aOther;
|
||||
}
|
||||
MemorySectionNameBuf(const MemorySectionNameBuf& aOther) { *this = aOther; }
|
||||
|
||||
MemorySectionNameBuf(MemorySectionNameBuf&& aOther) {
|
||||
*this = std::move(aOther);
|
||||
|
|
|
@ -204,8 +204,8 @@ void nsAndroidNetworkLinkService::OnLinkStatusKnown() { mStatusIsKnown = true; }
|
|||
|
||||
void nsAndroidNetworkLinkService::OnDnsSuffixListUpdated() {
|
||||
RefPtr<nsAndroidNetworkLinkService> self = this;
|
||||
NS_DispatchToMainThread(
|
||||
NS_NewRunnableFunction("nsAndroidNetworkLinkService::OnDnsSuffixListUpdated", [self]() {
|
||||
NS_DispatchToMainThread(NS_NewRunnableFunction(
|
||||
"nsAndroidNetworkLinkService::OnDnsSuffixListUpdated", [self]() {
|
||||
self->NotifyObservers(NS_DNS_SUFFIX_LIST_UPDATED_TOPIC, nullptr);
|
||||
}));
|
||||
}
|
||||
|
|
|
@ -169,8 +169,8 @@ void nsNetworkLinkService::OnLinkStatusKnown() { mStatusIsKnown = true; }
|
|||
|
||||
void nsNetworkLinkService::OnDnsSuffixListUpdated() {
|
||||
RefPtr<nsNetworkLinkService> self = this;
|
||||
NS_DispatchToMainThread(
|
||||
NS_NewRunnableFunction("nsNetworkLinkService::OnDnsSuffixListUpdated", [self]() {
|
||||
NS_DispatchToMainThread(NS_NewRunnableFunction(
|
||||
"nsNetworkLinkService::OnDnsSuffixListUpdated", [self]() {
|
||||
self->NotifyObservers(NS_DNS_SUFFIX_LIST_UPDATED_TOPIC, nullptr);
|
||||
}));
|
||||
}
|
||||
|
|
|
@ -221,9 +221,8 @@ static int FuzzingRunNetworkHttp(const uint8_t* data, size_t size) {
|
|||
bool mainPingBack = false;
|
||||
|
||||
NS_DispatchBackgroundTask(NS_NewRunnableFunction("Dummy", [&]() {
|
||||
NS_DispatchToMainThread(NS_NewRunnableFunction("Dummy", [&]() {
|
||||
mainPingBack = true;
|
||||
}));
|
||||
NS_DispatchToMainThread(
|
||||
NS_NewRunnableFunction("Dummy", [&]() { mainPingBack = true; }));
|
||||
}));
|
||||
|
||||
SpinEventLoopUntil([&]() -> bool { return mainPingBack; });
|
||||
|
|
|
@ -209,8 +209,7 @@ static void AttachSandboxReporter(base::file_handle_mapping_vector* aFdMap) {
|
|||
|
||||
class SandboxFork : public base::LaunchOptions::ForkDelegate {
|
||||
public:
|
||||
explicit SandboxFork(int aFlags, bool aChroot,
|
||||
int aServerFd = -1,
|
||||
explicit SandboxFork(int aFlags, bool aChroot, int aServerFd = -1,
|
||||
int aClientFd = -1);
|
||||
virtual ~SandboxFork();
|
||||
|
||||
|
@ -349,11 +348,9 @@ void SandboxLaunchPrepare(GeckoProcessType aType,
|
|||
*/
|
||||
void SandboxLaunchForkServerPrepare(const std::vector<std::string>& aArgv,
|
||||
base::LaunchOptions& aOptions) {
|
||||
auto chroot = std::find_if(aOptions.env_map.begin(),
|
||||
aOptions.env_map.end(),
|
||||
[](auto& elt) {
|
||||
return elt.first == kSandboxChrootEnvFlag;
|
||||
});
|
||||
auto chroot = std::find_if(
|
||||
aOptions.env_map.begin(), aOptions.env_map.end(),
|
||||
[](auto& elt) { return elt.first == kSandboxChrootEnvFlag; });
|
||||
if (chroot == aOptions.env_map.end()) {
|
||||
return;
|
||||
}
|
||||
|
@ -363,11 +360,9 @@ void SandboxLaunchForkServerPrepare(const std::vector<std::string>& aArgv,
|
|||
|
||||
// Find chroot server fd. It is supposed to be map to
|
||||
// kSandboxChrootServerFd so that we find it out from the mapping.
|
||||
auto fdmap = std::find_if(aOptions.fds_to_remap.begin(),
|
||||
aOptions.fds_to_remap.end(),
|
||||
[](auto& elt) {
|
||||
return elt.second == kSandboxChrootServerFd;
|
||||
});
|
||||
auto fdmap = std::find_if(
|
||||
aOptions.fds_to_remap.begin(), aOptions.fds_to_remap.end(),
|
||||
[](auto& elt) { return elt.second == kSandboxChrootServerFd; });
|
||||
MOZ_ASSERT(fdmap != aOptions.fds_to_remap.end(),
|
||||
"ChrootServerFd is not found with sandbox chroot");
|
||||
int chrootserverfd = fdmap->first;
|
||||
|
|
|
@ -267,8 +267,7 @@ void XRE_SetAndroidChildFds(JNIEnv* env, const XRE_AndroidChildFds& fds) {
|
|||
|
||||
void XRE_SetProcessType(const char* aProcessTypeString) {
|
||||
static bool called = false;
|
||||
if (called &&
|
||||
sChildProcessType != GeckoProcessType_ForkServer) {
|
||||
if (called && sChildProcessType != GeckoProcessType_ForkServer) {
|
||||
MOZ_CRASH();
|
||||
}
|
||||
called = true;
|
||||
|
|
|
@ -29,15 +29,15 @@ namespace mozilla {
|
|||
namespace widget {
|
||||
|
||||
typedef ABI::Windows::Foundation::ITypedEventHandler<
|
||||
ABI::Windows::UI::Notifications::ToastNotification *, IInspectable *>
|
||||
ABI::Windows::UI::Notifications::ToastNotification*, IInspectable*>
|
||||
ToastActivationHandler;
|
||||
typedef ABI::Windows::Foundation::ITypedEventHandler<
|
||||
ABI::Windows::UI::Notifications::ToastNotification *,
|
||||
ABI::Windows::UI::Notifications::ToastDismissedEventArgs *>
|
||||
ABI::Windows::UI::Notifications::ToastNotification*,
|
||||
ABI::Windows::UI::Notifications::ToastDismissedEventArgs*>
|
||||
ToastDismissedHandler;
|
||||
typedef ABI::Windows::Foundation::ITypedEventHandler<
|
||||
ABI::Windows::UI::Notifications::ToastNotification *,
|
||||
ABI::Windows::UI::Notifications::ToastFailedEventArgs *>
|
||||
ABI::Windows::UI::Notifications::ToastNotification*,
|
||||
ABI::Windows::UI::Notifications::ToastFailedEventArgs*>
|
||||
ToastFailedHandler;
|
||||
|
||||
using namespace ABI::Windows::Data::Xml::Dom;
|
||||
|
@ -49,11 +49,11 @@ using namespace mozilla;
|
|||
|
||||
NS_IMPL_ISUPPORTS(ToastNotificationHandler, nsIAlertNotificationImageListener)
|
||||
|
||||
static bool SetNodeValueString(const nsString &aString, IXmlNode *node,
|
||||
IXmlDocument *xml) {
|
||||
static bool SetNodeValueString(const nsString& aString, IXmlNode* node,
|
||||
IXmlDocument* xml) {
|
||||
ComPtr<IXmlText> inputText;
|
||||
if (NS_WARN_IF(FAILED(xml->CreateTextNode(
|
||||
HStringReference(static_cast<const wchar_t *>(aString.get())).Get(),
|
||||
HStringReference(static_cast<const wchar_t*>(aString.get())).Get(),
|
||||
&inputText)))) {
|
||||
return false;
|
||||
}
|
||||
|
@ -69,9 +69,9 @@ static bool SetNodeValueString(const nsString &aString, IXmlNode *node,
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool SetAttribute(IXmlElement *element, const HSTRING name,
|
||||
const nsAString &value) {
|
||||
HSTRING valueStr = HStringReference(static_cast<const wchar_t *>(
|
||||
static bool SetAttribute(IXmlElement* element, const HSTRING name,
|
||||
const nsAString& value) {
|
||||
HSTRING valueStr = HStringReference(static_cast<const wchar_t*>(
|
||||
PromiseFlatString(value).get()))
|
||||
.Get();
|
||||
if (NS_WARN_IF(FAILED(element->SetAttribute(name, valueStr)))) {
|
||||
|
@ -80,9 +80,9 @@ static bool SetAttribute(IXmlElement *element, const HSTRING name,
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool AddActionNode(IXmlDocument *toastXml, IXmlNode *actionsNode,
|
||||
const nsAString &actionTitle,
|
||||
const nsAString &actionArgs) {
|
||||
static bool AddActionNode(IXmlDocument* toastXml, IXmlNode* actionsNode,
|
||||
const nsAString& actionTitle,
|
||||
const nsAString& actionArgs) {
|
||||
ComPtr<IXmlElement> action;
|
||||
HRESULT hr =
|
||||
toastXml->CreateElement(HStringReference(L"action").Get(), &action);
|
||||
|
@ -174,8 +174,8 @@ ComPtr<IXmlDocument> ToastNotificationHandler::InitializeXmlForTemplate(
|
|||
return toastXml;
|
||||
}
|
||||
|
||||
nsresult
|
||||
ToastNotificationHandler::InitAlertAsync(nsIAlertNotification *aAlert) {
|
||||
nsresult ToastNotificationHandler::InitAlertAsync(
|
||||
nsIAlertNotification* aAlert) {
|
||||
return aAlert->LoadImage(/* aTimeout = */ 0, this, /* aUserData = */ nullptr,
|
||||
getter_AddRefs(mImageRequest));
|
||||
}
|
||||
|
@ -341,7 +341,7 @@ bool ToastNotificationHandler::ShowAlert() {
|
|||
}
|
||||
|
||||
bool ToastNotificationHandler::CreateWindowsNotificationFromXml(
|
||||
IXmlDocument *aXml) {
|
||||
IXmlDocument* aXml) {
|
||||
ComPtr<IToastNotificationFactory> factory;
|
||||
HRESULT hr = GetActivationFactory(
|
||||
HStringReference(RuntimeClass_Windows_UI_Notifications_ToastNotification)
|
||||
|
@ -359,8 +359,8 @@ bool ToastNotificationHandler::CreateWindowsNotificationFromXml(
|
|||
RefPtr<ToastNotificationHandler> self = this;
|
||||
|
||||
hr = mNotification->add_Activated(
|
||||
Callback<ToastActivationHandler>([self](IToastNotification *aNotification,
|
||||
IInspectable *aInspectable) {
|
||||
Callback<ToastActivationHandler>([self](IToastNotification* aNotification,
|
||||
IInspectable* aInspectable) {
|
||||
return self->OnActivate(aNotification, aInspectable);
|
||||
}).Get(),
|
||||
&mActivatedToken);
|
||||
|
@ -369,8 +369,8 @@ bool ToastNotificationHandler::CreateWindowsNotificationFromXml(
|
|||
}
|
||||
|
||||
hr = mNotification->add_Dismissed(
|
||||
Callback<ToastDismissedHandler>([self](IToastNotification *aNotification,
|
||||
IToastDismissedEventArgs *aArgs) {
|
||||
Callback<ToastDismissedHandler>([self](IToastNotification* aNotification,
|
||||
IToastDismissedEventArgs* aArgs) {
|
||||
return self->OnDismiss(aNotification, aArgs);
|
||||
}).Get(),
|
||||
&mDismissedToken);
|
||||
|
@ -379,8 +379,8 @@ bool ToastNotificationHandler::CreateWindowsNotificationFromXml(
|
|||
}
|
||||
|
||||
hr = mNotification->add_Failed(
|
||||
Callback<ToastFailedHandler>([self](IToastNotification *aNotification,
|
||||
IToastFailedEventArgs *aArgs) {
|
||||
Callback<ToastFailedHandler>([self](IToastNotification* aNotification,
|
||||
IToastFailedEventArgs* aArgs) {
|
||||
return self->OnFail(aNotification, aArgs);
|
||||
}).Get(),
|
||||
&mFailedToken);
|
||||
|
@ -400,7 +400,7 @@ bool ToastNotificationHandler::CreateWindowsNotificationFromXml(
|
|||
}
|
||||
|
||||
HSTRING uidStr =
|
||||
HStringReference(static_cast<const wchar_t *>(uid.get())).Get();
|
||||
HStringReference(static_cast<const wchar_t*>(uid.get())).Get();
|
||||
hr = toastNotificationManagerStatics->CreateToastNotifierWithId(uidStr,
|
||||
&mNotifier);
|
||||
if (NS_WARN_IF(FAILED(hr))) {
|
||||
|
@ -419,8 +419,7 @@ bool ToastNotificationHandler::CreateWindowsNotificationFromXml(
|
|||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
ToastNotificationHandler::SendFinished() {
|
||||
void ToastNotificationHandler::SendFinished() {
|
||||
if (!mSentFinished && mAlertListener) {
|
||||
mAlertListener->Observe(nullptr, "alertfinished", mCookie.get());
|
||||
}
|
||||
|
@ -429,20 +428,20 @@ ToastNotificationHandler::SendFinished() {
|
|||
}
|
||||
|
||||
HRESULT
|
||||
ToastNotificationHandler::OnActivate(IToastNotification *notification,
|
||||
IInspectable *inspectable) {
|
||||
ToastNotificationHandler::OnActivate(IToastNotification* notification,
|
||||
IInspectable* inspectable) {
|
||||
if (mAlertListener) {
|
||||
nsAutoString argString;
|
||||
if (inspectable) {
|
||||
ComPtr<IToastActivatedEventArgs> eventArgs;
|
||||
HRESULT hr = inspectable->QueryInterface(
|
||||
__uuidof(IToastActivatedEventArgs), (void **)&eventArgs);
|
||||
__uuidof(IToastActivatedEventArgs), (void**)&eventArgs);
|
||||
if (SUCCEEDED(hr)) {
|
||||
HSTRING arguments;
|
||||
hr = eventArgs->get_Arguments(&arguments);
|
||||
if (SUCCEEDED(hr)) {
|
||||
uint32_t len = 0;
|
||||
const wchar_t *buffer = WindowsGetStringRawBuffer(arguments, &len);
|
||||
const wchar_t* buffer = WindowsGetStringRawBuffer(arguments, &len);
|
||||
if (buffer) {
|
||||
argString.Assign(buffer, len);
|
||||
}
|
||||
|
@ -480,16 +479,16 @@ ToastNotificationHandler::OnActivate(IToastNotification *notification,
|
|||
}
|
||||
|
||||
HRESULT
|
||||
ToastNotificationHandler::OnDismiss(IToastNotification *notification,
|
||||
IToastDismissedEventArgs *aArgs) {
|
||||
ToastNotificationHandler::OnDismiss(IToastNotification* notification,
|
||||
IToastDismissedEventArgs* aArgs) {
|
||||
SendFinished();
|
||||
mBackend->RemoveHandler(mName, this);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT
|
||||
ToastNotificationHandler::OnFail(IToastNotification *notification,
|
||||
IToastFailedEventArgs *aArgs) {
|
||||
ToastNotificationHandler::OnFail(IToastNotification* notification,
|
||||
IToastFailedEventArgs* aArgs) {
|
||||
SendFinished();
|
||||
mBackend->RemoveHandler(mName, this);
|
||||
return S_OK;
|
||||
|
@ -504,12 +503,12 @@ nsresult ToastNotificationHandler::TryShowAlert() {
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ToastNotificationHandler::OnImageMissing(nsISupports *) {
|
||||
ToastNotificationHandler::OnImageMissing(nsISupports*) {
|
||||
return TryShowAlert();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ToastNotificationHandler::OnImageReady(nsISupports *, imgIRequest *aRequest) {
|
||||
ToastNotificationHandler::OnImageReady(nsISupports*, imgIRequest* aRequest) {
|
||||
nsresult rv = AsyncSaveImage(aRequest);
|
||||
if (NS_FAILED(rv)) {
|
||||
return TryShowAlert();
|
||||
|
@ -517,7 +516,7 @@ ToastNotificationHandler::OnImageReady(nsISupports *, imgIRequest *aRequest) {
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsresult ToastNotificationHandler::AsyncSaveImage(imgIRequest *aRequest) {
|
||||
nsresult ToastNotificationHandler::AsyncSaveImage(imgIRequest* aRequest) {
|
||||
nsresult rv =
|
||||
NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(mImageFile));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
|
@ -580,7 +579,7 @@ nsresult ToastNotificationHandler::AsyncSaveImage(imgIRequest *aRequest) {
|
|||
nsCOMPtr<nsIRunnable> cbRunnable = NS_NewRunnableFunction(
|
||||
"ToastNotificationHandler::AsyncWriteBitmapCb",
|
||||
[self, rv]() -> void {
|
||||
auto handler = const_cast<ToastNotificationHandler *>(self.get());
|
||||
auto handler = const_cast<ToastNotificationHandler*>(self.get());
|
||||
handler->OnWriteBitmapFinished(rv);
|
||||
});
|
||||
|
||||
|
|
|
@ -569,10 +569,11 @@ static void DoInitTraceLog(const char* aProcType) {
|
|||
return;
|
||||
}
|
||||
|
||||
bool defined =
|
||||
InitLog(ENVVAR("XPCOM_MEM_BLOAT_LOG"), "bloat/leaks", &gBloatLog, aProcType);
|
||||
bool defined = InitLog(ENVVAR("XPCOM_MEM_BLOAT_LOG"), "bloat/leaks",
|
||||
&gBloatLog, aProcType);
|
||||
if (!defined) {
|
||||
gLogLeaksOnly = InitLog(ENVVAR("XPCOM_MEM_LEAK_LOG"), "leaks", &gBloatLog, aProcType);
|
||||
gLogLeaksOnly =
|
||||
InitLog(ENVVAR("XPCOM_MEM_LEAK_LOG"), "leaks", &gBloatLog, aProcType);
|
||||
}
|
||||
if (defined || gLogLeaksOnly) {
|
||||
// Use the same bloat view, if there is, to keep it consistent
|
||||
|
@ -1182,9 +1183,7 @@ static void ClearLogs(bool aKeepCounters) {
|
|||
maybeUnregisterAndCloseFile(gCOMPtrLog);
|
||||
}
|
||||
|
||||
void nsTraceRefcnt::Shutdown() {
|
||||
ClearLogs(false);
|
||||
}
|
||||
void nsTraceRefcnt::Shutdown() { ClearLogs(false); }
|
||||
|
||||
void nsTraceRefcnt::SetActivityIsLegal(bool aLegal) {
|
||||
if (gActivityTLS == BAD_TLS_INDEX) {
|
||||
|
|
|
@ -58,7 +58,8 @@ class nsThreadManager : public nsIThreadManager {
|
|||
nsresult DispatchToBackgroundThread(nsIRunnable* aEvent,
|
||||
uint32_t aDispatchFlags);
|
||||
|
||||
already_AddRefed<nsISerialEventTarget> CreateBackgroundTaskQueue(const char* aName);
|
||||
already_AddRefed<nsISerialEventTarget> CreateBackgroundTaskQueue(
|
||||
const char* aName);
|
||||
|
||||
// Returns the maximal number of threads that have been in existence
|
||||
// simultaneously during the execution of the thread manager.
|
||||
|
|
Загрузка…
Ссылка в новой задаче