dom/media/systemservices/CamerasUtils.h
author Kyle Huey <khuey@kylehuey.com>
Mon, 25 Apr 2016 17:23:21 -0700
changeset 294847 fcc0936b576daa150697671849a191009ca33811
parent 268184 e8c7dfe727cd970e2c3294934e2927b14143c205
child 295208 30dcf34cfb753d94c79f40bd1af15d3b75e981a5
permissions -rw-r--r--
Bug 1265927: Move nsRunnable to mozilla::Runnable, CancelableRunnable to mozilla::CancelableRunnable. r=froydnj

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set sw=2 ts=8 et ft=cpp : */
/* 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 mozilla_CameraUtils_h
#define mozilla_CameraUtils_h

#include "nsThreadUtils.h"
#include "nsCOMPtr.h"
#include "mozilla/UniquePtr.h"

#include "base/thread.h"

namespace mozilla {
namespace camera {

nsresult SynchronouslyCreatePBackground();

class ThreadDestructor : public Runnable
{
  DISALLOW_COPY_AND_ASSIGN(ThreadDestructor);

public:
  explicit ThreadDestructor(nsIThread* aThread)
    : mThread(aThread) {}

  NS_IMETHOD Run() override
  {
    if (mThread) {
      mThread->Shutdown();
    }
    return NS_OK;
  }

private:
  ~ThreadDestructor() {}
  nsCOMPtr<nsIThread> mThread;
};

class RunnableTask : public Task
{
public:
  explicit RunnableTask(Runnable* aRunnable)
    : mRunnable(aRunnable) {}

  void Run() override {
    mRunnable->Run();
  }

private:
  ~RunnableTask() {}
  RefPtr<Runnable> mRunnable;
};

}
}

#endif // mozilla_CameraUtils_h