mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 12:51:06 +00:00
Bug 1557794. Stop using [array] in nsIGfxInfo. r=jrmuizel
Differential Revision: https://phabricator.services.mozilla.com/D34210 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
581338764d
commit
877c6cfe77
@ -554,10 +554,9 @@ var dataProviders = {
|
||||
if (infoInfo)
|
||||
data.info = infoInfo;
|
||||
|
||||
let failureCount = {};
|
||||
let failureIndices = {};
|
||||
|
||||
let failures = gfxInfo.getFailures(failureCount, failureIndices);
|
||||
let failures = gfxInfo.getFailures(failureIndices);
|
||||
if (failures.length) {
|
||||
data.failures = failures;
|
||||
if (failureIndices.value.length == failures.length) {
|
||||
|
@ -1074,48 +1074,26 @@ GfxInfoBase::LogFailure(const nsACString& failure) {
|
||||
<< "(LF) " << failure.BeginReading();
|
||||
}
|
||||
|
||||
/* XPConnect method of returning arrays is very ugly. Would not recommend. */
|
||||
NS_IMETHODIMP GfxInfoBase::GetFailures(uint32_t* failureCount,
|
||||
int32_t** indices, char*** failures) {
|
||||
NS_IMETHODIMP GfxInfoBase::GetFailures(nsTArray<int32_t>& indices,
|
||||
nsTArray<nsCString>& failures) {
|
||||
MutexAutoLock lock(mMutex);
|
||||
|
||||
NS_ENSURE_ARG_POINTER(failureCount);
|
||||
NS_ENSURE_ARG_POINTER(failures);
|
||||
|
||||
*failures = nullptr;
|
||||
*failureCount = 0;
|
||||
|
||||
// indices is "allowed" to be null, the caller may not care about them,
|
||||
// although calling from JS doesn't seem to get us there.
|
||||
if (indices) *indices = nullptr;
|
||||
|
||||
LogForwarder* logForwarder = Factory::GetLogForwarder();
|
||||
if (!logForwarder) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
// There are two stirng copies in this method, starting with this one. We are
|
||||
// There are two string copies in this method, starting with this one. We are
|
||||
// assuming this is not a big deal, as the size of the array should be small
|
||||
// and the strings in it should be small as well (the error messages in the
|
||||
// code.) The second copy happens with the Clone() calls. Technically,
|
||||
// we don't need the mutex lock after the StringVectorCopy() call.
|
||||
// code.) The second copy happens with the AppendElement() calls.
|
||||
// Technically, we don't need the mutex lock after the StringVectorCopy() call.
|
||||
LoggingRecord loggedStrings = logForwarder->LoggingRecordCopy();
|
||||
*failureCount = loggedStrings.size();
|
||||
|
||||
if (*failureCount != 0) {
|
||||
*failures = (char**)moz_xmalloc(*failureCount * sizeof(char*));
|
||||
if (indices) {
|
||||
*indices = (int32_t*)moz_xmalloc(*failureCount * sizeof(int32_t));
|
||||
}
|
||||
|
||||
/* copy over the failure messages into the array we just allocated */
|
||||
LoggingRecord::const_iterator it;
|
||||
uint32_t i = 0;
|
||||
for (it = loggedStrings.begin(); it != loggedStrings.end(); ++it, i++) {
|
||||
(*failures)[i] =
|
||||
(char*)moz_xmemdup(Get<1>(*it).c_str(), Get<1>(*it).size() + 1);
|
||||
if (indices) (*indices)[i] = Get<0>(*it);
|
||||
}
|
||||
LoggingRecord::const_iterator it;
|
||||
for (it = loggedStrings.begin(); it != loggedStrings.end(); ++it) {
|
||||
failures.AppendElement(
|
||||
nsDependentCSubstring(Get<1>(*it).c_str(), Get<1>(*it).size()));
|
||||
indices.AppendElement(Get<0>(*it));
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -55,8 +55,8 @@ class GfxInfoBase : public nsIGfxInfo,
|
||||
|
||||
NS_IMETHOD GetMonitors(JSContext* cx,
|
||||
JS::MutableHandleValue _retval) override;
|
||||
NS_IMETHOD GetFailures(uint32_t* failureCount, int32_t** indices,
|
||||
char*** failures) override;
|
||||
NS_IMETHOD GetFailures(nsTArray<int32_t>& indices,
|
||||
nsTArray<nsCString>& failures) override;
|
||||
NS_IMETHOD_(void) LogFailure(const nsACString& failure) override;
|
||||
NS_IMETHOD GetInfo(JSContext*, JS::MutableHandle<JS::Value>) override;
|
||||
NS_IMETHOD GetFeatures(JSContext*, JS::MutableHandle<JS::Value>) override;
|
||||
|
@ -85,10 +85,7 @@ interface nsIGfxInfo : nsISupports
|
||||
[implicit_jscontext]
|
||||
jsval getMonitors();
|
||||
|
||||
void getFailures(
|
||||
out unsigned long failureCount,
|
||||
[optional, array, size_is(failureCount)] out long indices,
|
||||
[retval, array, size_is(failureCount)] out string failures);
|
||||
Array<ACString> getFailures(out Array<long> indices);
|
||||
|
||||
[noscript, notxpcom] void logFailure(in ACString failure);
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user