1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef nsICancelableRunnable_h__ 8 #define nsICancelableRunnable_h__ 9 10 #include "nsISupports.h" 11 12 #define NS_ICANCELABLERUNNABLE_IID \ 13 { \ 14 0xde93dc4c, 0x5eea, 0x4eb7, { \ 15 0xb6, 0xd1, 0xdb, 0xf1, 0xe0, 0xce, 0xf6, 0x5c \ 16 } \ 17 } 18 19 class nsICancelableRunnable : public nsISupports { 20 public: 21 NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICANCELABLERUNNABLE_IID) 22 23 /* 24 * Cancels a pending task, so that calling run() on the task is a no-op. 25 * Calling cancel after the task execution has begun will be a no-op. 26 * Calling this method twice is considered an error. 27 * 28 * @throws NS_ERROR_UNEXPECTED 29 * Indicates that the runnable has already been canceled. 30 */ 31 virtual nsresult Cancel() = 0; 32 33 protected: 34 nsICancelableRunnable() = default; 35 virtual ~nsICancelableRunnable() = default; 36 }; 37 38 NS_DEFINE_STATIC_IID_ACCESSOR(nsICancelableRunnable, NS_ICANCELABLERUNNABLE_IID) 39 40 #endif // nsICancelableRunnable_h__ 41