mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-03 18:47:53 +00:00
835e1550cb
A lot of existing code has variations on: if (ManagedPFooChild().Length()) { ...(ManagedPFooChild()[0])... } // Do something with nullptr, or some other action. It's pretty reasonable to repeat this code when the managed protocols are stored in an array; the code gets much less nice when managed protocols are stored in a hashtable. Let's write a small utility function to handle those details for us. Then when we change the underlying storage, we only need to update this function, rather than a bunch of callsites. ProtocolUtils.h is included by all the generated IPDL headers, so LoneManagedOrNull should be available everywhere the above pattern would be encountered.
43 lines
1.2 KiB
C++
43 lines
1.2 KiB
C++
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* vim: set ts=8 sts=2 et sw=2 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 "mozilla/plugins/PluginModuleChild.h"
|
|
#include "ContentChild.h"
|
|
#include "CrashReporterChild.h"
|
|
#include "nsXULAppAPI.h"
|
|
|
|
using mozilla::plugins::PluginModuleChild;
|
|
|
|
namespace mozilla {
|
|
namespace dom {
|
|
|
|
/*static*/
|
|
PCrashReporterChild*
|
|
CrashReporterChild::GetCrashReporter()
|
|
{
|
|
const ManagedContainer<PCrashReporterChild>* reporters = nullptr;
|
|
switch (XRE_GetProcessType()) {
|
|
case GeckoProcessType_Content: {
|
|
ContentChild* child = ContentChild::GetSingleton();
|
|
reporters = &child->ManagedPCrashReporterChild();
|
|
break;
|
|
}
|
|
case GeckoProcessType_Plugin: {
|
|
PluginModuleChild* child = PluginModuleChild::GetChrome();
|
|
reporters = &child->ManagedPCrashReporterChild();
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
if (!reporters) {
|
|
return nullptr;
|
|
}
|
|
return LoneManagedOrNull(*reporters);
|
|
}
|
|
|
|
} // namespace dom
|
|
} // namespace mozilla
|