author cku <>
Wed, 13 Dec 2017 12:42:59 +0800
changeset 396527 8320a9f9de3e4ef593cf8c5a96c832ed5c28c9fc
parent 370901 e0dace2b0ab34355eb4ba4dbc5d379768465d7e9
child 448947 6f3709b3878117466168c40affa7bca0b60cf75b
permissions -rw-r--r--
Bug 1424922 - Prevent calling PDFiumParent::Close twice. r=dvander We call PDFiumParent::Close twice under certain conditions. Once in PDFiumProcessParent::Delete, and once in PDFiumProcessParent's dtor. So we may hit MOZ_ABORT which tell us that we are trying to close a closed channel. This patch prevents hitting this abort by: 1. Only close the channel in PDFiumProcessParent::Delete, remove another call in PDFiumProcessParent's dtor. (Please see the change in PDFiumProcessParent.cpp). 2. Remove PDFiumParent::AbortConversion and relative code. We can just use PDFiumParent::EndConversion instead. When calling PDFiumParent::Close, we actually close the IPC channel *synchronously*, which means there is no need to register a callback by PDFiumParent::AbortConversion to receive actor-destroy callback. MozReview-Commit-ID: 9i5j6t54J3h

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* 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 */


#include "GeckoTaskTracer.h"
#include "nsCOMPtr.h"
#include "nsThreadUtils.h"

namespace mozilla {
namespace tasktracer {

class TracedTaskCommon
  TracedTaskCommon(const TracedTaskCommon& aSrc)
    : mSourceEventType(aSrc.mSourceEventType)
    , mSourceEventId(aSrc.mSourceEventId)
    , mParentTaskId(aSrc.mParentTaskId)
    , mTaskId(aSrc.mTaskId)
    , mIsTraceInfoInit(aSrc.mIsTraceInfoInit) {}
  virtual ~TracedTaskCommon();

  void DispatchTask(int aDelayTimeMs = 0);

  void SetTLSTraceInfo() {
    if (mIsTraceInfoInit) {
  void GetTLSTraceInfo() {
    if (IsStartLogging()) {
  void ClearTLSTraceInfo();

  void DoSetTLSTraceInfo();
  void DoGetTLSTraceInfo();

  void Init();

  // TraceInfo of TLS will be set by the following parameters, including source
  // event type, source event ID, parent task ID, and task ID of this traced
  // task/runnable.
  SourceEventType mSourceEventType;
  uint64_t mSourceEventId;
  uint64_t mParentTaskId;
  uint64_t mTaskId;
  bool mIsTraceInfoInit;

class TracedRunnable : public TracedTaskCommon
                     , public nsIRunnable

  explicit TracedRunnable(already_AddRefed<nsIRunnable>&& aOriginalObj);

  virtual ~TracedRunnable();

  nsCOMPtr<nsIRunnable> mOriginalObj;

 * This class is used to create a logical task, without a real
 * runnable.
class VirtualTask : public TracedTaskCommon {
  VirtualTask() : TracedTaskCommon() {}

  VirtualTask(const VirtualTask& aSrc) : TracedTaskCommon(aSrc) {}

   * Initialize the task to create an unique ID, and store other
   * information.
   * This method may be called for one or more times.
  void Init(uintptr_t* aVPtr = nullptr) {
    if (aVPtr) {
      extern void LogVirtualTablePtr(uint64_t aTaskId, uint64_t aSourceEventId, uintptr_t* aVptr);
      LogVirtualTablePtr(mTaskId, mSourceEventId, aVPtr);

   * Define the life-span of a VirtualTask.
   * VirtualTask is not a real task, goes without a runnable, it's
   * instances are never dispatched and ran by event loops.  This
   * class used to define running time as the life-span of it's
   * instance.
  class AutoRunTask : public AutoSaveCurTraceInfo {
    VirtualTask* mTask;
    void StartScope(VirtualTask *aTask);
    void StopScope();
    explicit AutoRunTask(VirtualTask *aTask)
      : AutoSaveCurTraceInfo()
      , mTask(aTask) {
      if (HasSavedTraceInfo()) {
    ~AutoRunTask() {
      if (HasSavedTraceInfo()) {

} // namespace tasktracer
} // namespace mozilla