tools/profiler/core/SyncProfile.h
author Julian Seward <jseward@acm.org>
Thu, 23 Feb 2017 23:05:23 +0100
changeset 373705 6ef5dd99b45cf4b556e7204ba29c6446f550702a
parent 361172 82e687d1494c8eca73dd7464d634cac24429f1aa
child 374171 63fa61a6e3d12a7d562e5108706b8d0a75dc7e4b
permissions -rw-r--r--
Bug 1341255 - Profiler tidyups: remove StackEntry, rename ProfileEntry to ProfileBufferEntry (part 2: rename ProfileEntry). r=n.nethercote.

/* -*- Mode: C++; tab-width: 2; 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/. */

#ifndef __SYNCPROFILE_H
#define __SYNCPROFILE_H

#include "ThreadInfo.h"

class SyncProfile : public ThreadInfo
{
public:
  SyncProfile(int aThreadId, PseudoStack* aStack);
  ~SyncProfile();

  // SyncProfiles' stacks are deduplicated in the context of the containing
  // profile in which the backtrace is as a marker payload.
  void StreamJSON(SpliceableJSONWriter& aWriter, UniqueStacks& aUniqueStacks);

  virtual void EndUnwind();

private:
  friend class ProfilerBacktrace;

  enum OwnerState
  {
    REFERENCED,       // ProfilerBacktrace has a pointer to this but doesn't own
    OWNED,            // ProfilerBacktrace is responsible for destroying this
    OWNER_DESTROYING, // ProfilerBacktrace owns this and is destroying
    ORPHANED          // No owner, we must destroy ourselves
  };

  bool ShouldDestroy();

  OwnerState mOwnerState;
};

#endif // __SYNCPROFILE_H