DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Implementation

Mercurial (fbe9d9ed5227)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
/* -*- 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 https://mozilla.org/MPL/2.0/. */

#ifndef mozilla_WinDllServices_h
#define mozilla_WinDllServices_h

#include "mozilla/CombinedStacks.h"
#include "mozilla/glue/WindowsDllServices.h"
#include "mozilla/Maybe.h"
#include "mozilla/ModuleEvaluator_windows.h"
#include "mozilla/mozalloc.h"
#include "mozilla/UniquePtr.h"
#include "mozilla/Vector.h"

namespace mozilla {

// Holds the data that telemetry requests, and will be later converted to the
// telemetry payload.
class UntrustedModuleLoadTelemetryData {
 public:
  UntrustedModuleLoadTelemetryData() = default;
  // Moves allowed, no copies.
  UntrustedModuleLoadTelemetryData(UntrustedModuleLoadTelemetryData&&) =
      default;
  UntrustedModuleLoadTelemetryData(
      const UntrustedModuleLoadTelemetryData& aOther) = delete;

  Vector<ModuleLoadEvent, 0, InfallibleAllocPolicy> mEvents;
  Telemetry::CombinedStacks mStacks;
  int mErrorModules = 0;
  Maybe<double> mXULLoadDurationMS;
};

class UntrustedModulesManager;

class DllServices : public mozilla::glue::DllServices {
 public:
  static DllServices* Get();

  static const char* kTopicDllLoadedMainThread;
  static const char* kTopicDllLoadedNonMainThread;

  /**
   * Processes pending untrusted module evaluation / examination, and returns
   * a copy of the total data we've gathered for use by the untrusted modules
   * telemetry ping.
   *
   * This function should be called on a background thread, and can take a
   * while.
   *
   * @param  aOut [out] Receives a copy of internally-stored data.
   * @return true upon success.
   */
  bool GetUntrustedModuleTelemetryData(UntrustedModuleLoadTelemetryData& aOut);

 private:
  DllServices();
  ~DllServices() = default;

  void NotifyDllLoad(const bool aIsMainThread,
                     const nsString& aDllName) override;

  void NotifyUntrustedModuleLoads(
      const Vector<glue::ModuleLoadEvent, 0, InfallibleAllocPolicy>& aEvents)
      override;

  UniquePtr<UntrustedModulesManager> mUntrustedModulesManager;
};

}  // namespace mozilla

#endif  // mozilla_WinDllServices_h