Commit ca7bbcc7 authored by Florian Quèze's avatar Florian Quèze
Browse files

Bug 1720374 - Remove MOZ_GECKO_PROFILER ifdefs that are not useful, r=gerald.

parent 292c1a1f
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@
#include "nsTextEquivUtils.h"
#include "DocAccessibleChild.h"
#include "EventTree.h"
#include "GeckoProfiler.h"
#include "Pivot.h"
#include "Relation.h"
#include "Role.h"
@@ -74,6 +73,7 @@
#include "mozilla/PresShell.h"
#include "mozilla/Unused.h"
#include "mozilla/Preferences.h"
#include "mozilla/ProfilerMarkers.h"
#include "mozilla/StaticPrefs_ui.h"
#include "mozilla/dom/CanvasRenderingContext2D.h"
#include "mozilla/dom/Element.h"
@@ -810,7 +810,6 @@ void LocalAccessible::XULElmName(DocAccessible* aDocument, nsIContent* aElm,
nsresult LocalAccessible::HandleAccEvent(AccEvent* aEvent) {
  NS_ENSURE_ARG_POINTER(aEvent);

#ifdef MOZ_GECKO_PROFILER
  if (profiler_thread_is_being_profiled()) {
    nsAutoCString strEventType;
    GetAccService()->GetStringEventType(aEvent->GetEventType(), strEventType);
@@ -819,7 +818,6 @@ nsresult LocalAccessible::HandleAccEvent(AccEvent* aEvent) {
    strMarker.Append(strEventType);
    PROFILER_MARKER_UNTYPED(strMarker, OTHER);
  }
#endif

  if (IPCAccessibilityActive() && Document()) {
    DocAccessibleChild* ipcDoc = mDoc->IPCDoc();
+7 −7
Original line number Diff line number Diff line
@@ -7837,13 +7837,13 @@ nsresult nsDocShell::CreateContentViewer(const nsACString& aContentType,
      NS_ENSURE_SUCCESS(rv, rv);

      if (!parentSite.Equals(thisSite)) {
#ifdef MOZ_GECKO_PROFILER
        if (profiler_can_accept_markers()) {
          nsCOMPtr<nsIURI> prinURI;
          BasePrincipal::Cast(thisPrincipal)->GetURI(getter_AddRefs(prinURI));
          nsPrintfCString marker("Iframe loaded in background: %s",
                                 prinURI->GetSpecOrDefault().get());
          PROFILER_MARKER_TEXT("Background Iframe", DOM, {}, marker);
#endif
        }
        SetBackgroundLoadIframe();
      }
    }
+13 −11
Original line number Diff line number Diff line
@@ -192,7 +192,10 @@ void ChromeUtils::AddProfilerMarker(
    GlobalObject& aGlobal, const nsACString& aName,
    const ProfilerMarkerOptionsOrDouble& aOptions,
    const Optional<nsACString>& aText) {
#ifdef MOZ_GECKO_PROFILER
  if (!profiler_can_accept_markers()) {
    return;
  }

  MarkerOptions options;

  MarkerCategory category = ::geckoprofiler::category::JS;
@@ -267,7 +270,6 @@ void ChromeUtils::AddProfilerMarker(
      profiler_add_marker(aName, category, std::move(options));
    }
  }
#endif  // MOZ_GECKO_PROFILER
}

/* static */
+0 −2
Original line number Diff line number Diff line
@@ -583,13 +583,11 @@ void AudioStream::GetTimeStretched(AudioBufferWriter& aWriter) {
}

bool AudioStream::CheckThreadIdChanged() {
#ifdef MOZ_GECKO_PROFILER
  auto id = profiler_current_thread_id();
  if (id != mAudioThreadId) {
    mAudioThreadId = id;
    return true;
  }
#endif
  return false;
}

+11 −14
Original line number Diff line number Diff line
@@ -23,25 +23,22 @@ namespace mozilla {
// path.
class AudioThreadRegistry final {
 public:
  AudioThreadRegistry()
#ifdef MOZ_GECKO_PROFILER
      : mThreadIds("AudioThreadId")
#endif  // MOZ_GECKO_PROFILER
  {
  }
  AudioThreadRegistry() : mThreadIds("AudioThreadId") {}

#ifdef MOZ_GECKO_PROFILER
  ~AudioThreadRegistry() {
    // It would be nice to be able to assert that all threads have be
    // unregistered, but we can't: it's legal to suspend an audio stream, so
    // that the callback isn't called, and then immediately destroy it.
  }
#endif  // MOZ_GECKO_PROFILER

  // This is intended to be called when an object starts an audio callback
  // thread.
  void Register(int aThreadId) {
#ifdef MOZ_GECKO_PROFILER
    if (aThreadId == 0) {
      // profiler_current_thread_id returns 0 on unsupported platforms.
      return;
    }

    auto threadIds = mThreadIds.Lock();
    for (uint32_t i = 0; i < threadIds->Length(); i++) {
      if ((*threadIds)[i].mId == aThreadId) {
@@ -54,12 +51,15 @@ class AudioThreadRegistry final {
    tuc.mUserCount = 1;
    threadIds->AppendElement(tuc);
    PROFILER_REGISTER_THREAD("NativeAudioCallback");
#endif  // MOZ_GECKO_PROFILER
  }

  // This is intended to be called when an object stops an audio callback thread
  void Unregister(int aThreadId) {
#ifdef MOZ_GECKO_PROFILER
    if (aThreadId == 0) {
      // profiler_current_thread_id returns 0 on unsupported platforms.
      return;
    }

    auto threadIds = mThreadIds.Lock();
    for (uint32_t i = 0; i < threadIds->Length(); i++) {
      if ((*threadIds)[i].mId == aThreadId) {
@@ -74,7 +74,6 @@ class AudioThreadRegistry final {
      }
    }
    MOZ_ASSERT(false);
#endif  // MOZ_GECKO_PROFILER
  }

 private:
@@ -83,13 +82,11 @@ class AudioThreadRegistry final {
  AudioThreadRegistry(AudioThreadRegistry&&) = delete;
  AudioThreadRegistry& operator=(AudioThreadRegistry&&) = delete;

#ifdef MOZ_GECKO_PROFILER
  struct ThreadUserCount {
    int mId;  // from profiler_current_thread_id
    int mUserCount;
  };
  DataMutex<nsTArray<ThreadUserCount>> mThreadIds;
#endif  // MOZ_GECKO_PROFILER
};

}  // namespace mozilla
Loading