Bug 1347661 - Unbreak --enable-warnings-as-errors on platforms without Gecko Profiler. r?gfritzsche
MozReview-Commit-ID: Jp2HsYItboc
--- a/toolkit/components/telemetry/Telemetry.cpp
+++ b/toolkit/components/telemetry/Telemetry.cpp
@@ -116,18 +116,20 @@ public:
typedef std::vector<Telemetry::ProcessedStack::Frame> Stack;
const Telemetry::ProcessedStack::Module& GetModule(unsigned aIndex) const;
size_t GetModuleCount() const;
const Stack& GetStack(unsigned aIndex) const;
size_t AddStack(const Telemetry::ProcessedStack& aStack);
size_t GetStackCount() const;
size_t SizeOfExcludingThis() const;
+#if defined(ENABLE_STACK_CAPTURE)
/** Clears the contents of vectors and resets the index. */
void Clear();
+#endif
private:
std::vector<Telemetry::ProcessedStack::Module> mModules;
// A circular buffer to hold the stacks.
std::vector<Stack> mStacks;
// The index of the next buffer element to write to in mStacks.
size_t mNextIndex;
};
@@ -224,22 +226,24 @@ ComputeAnnotationsKey(const HangAnnotati
while (annotationsEnum->Next(key, value)) {
aKeyOut.Append(key);
aKeyOut.Append(value);
}
return NS_OK;
}
+#if defined(ENABLE_STACK_CAPTURE)
void
CombinedStacks::Clear() {
mNextIndex = 0;
mStacks.clear();
mModules.clear();
}
+#endif
class HangReports {
public:
/**
* This struct encapsulates information for an individual ChromeHang annotation.
* mHangIndex is the index of the corresponding ChromeHang.
*/
struct AnnotationInfo {
@@ -266,20 +270,22 @@ public:
HangAnnotationsPtr mAnnotations;
private:
// Force move constructor
AnnotationInfo(const AnnotationInfo& aOther) = delete;
void operator=(const AnnotationInfo& aOther) = delete;
};
size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
+#if defined(MOZ_GECKO_PROFILER)
void AddHang(const Telemetry::ProcessedStack& aStack, uint32_t aDuration,
int32_t aSystemUptime, int32_t aFirefoxUptime,
HangAnnotationsPtr aAnnotations);
void PruneStackReferences(const size_t aRemovedStackIndex);
+#endif
uint32_t GetDuration(unsigned aIndex) const;
int32_t GetSystemUptime(unsigned aIndex) const;
int32_t GetFirefoxUptime(unsigned aIndex) const;
const nsClassHashtable<nsStringHashKey, AnnotationInfo>& GetAnnotationInfo() const;
const CombinedStacks& GetStacks() const;
private:
/**
* This struct encapsulates the data for an individual ChromeHang, excluding
@@ -293,16 +299,17 @@ private:
// Firefox uptime (in minutes) at the time of the hang
int32_t mFirefoxUptime;
};
std::vector<HangInfo> mHangInfo;
nsClassHashtable<nsStringHashKey, AnnotationInfo> mAnnotationInfo;
CombinedStacks mStacks;
};
+#if defined(MOZ_GECKO_PROFILER)
void
HangReports::AddHang(const Telemetry::ProcessedStack& aStack,
uint32_t aDuration,
int32_t aSystemUptime,
int32_t aFirefoxUptime,
HangAnnotationsPtr aAnnotations) {
// Append the new stack to the stack's circular queue.
size_t hangIndex = mStacks.AddStack(aStack);
@@ -366,16 +373,17 @@ HangReports::PruneStackReferences(const
}
// If this annotation no longer references any stack, drop it.
if (!stackIndices.Length()) {
iter.Remove();
}
}
}
+#endif
size_t
HangReports::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const {
size_t n = 0;
n += mStacks.SizeOfExcludingThis();
// This is a crude approximation. See comment on
// CombinedStacks::SizeOfExcludingThis.
n += mHangInfo.capacity() * sizeof(HangInfo);