1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/widget/windows/nsIdleServiceWin.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,46 @@ 1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 1.5 +/* vim:expandtab:shiftwidth=4:tabstop=4: 1.6 + */ 1.7 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.8 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.9 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.10 + 1.11 +#ifndef nsIdleServiceWin_h__ 1.12 +#define nsIdleServiceWin_h__ 1.13 + 1.14 +#include "nsIdleService.h" 1.15 + 1.16 + 1.17 +/* NOTE: Compare of GetTickCount() could overflow. This corrects for 1.18 +* overflow situations. 1.19 +***/ 1.20 +#ifndef SAFE_COMPARE_EVEN_WITH_WRAPPING 1.21 +#define SAFE_COMPARE_EVEN_WITH_WRAPPING(A, B) (((int)((long)A - (long)B) & 0xFFFFFFFF)) 1.22 +#endif 1.23 + 1.24 + 1.25 +class nsIdleServiceWin : public nsIdleService 1.26 +{ 1.27 +public: 1.28 + NS_DECL_ISUPPORTS_INHERITED 1.29 + 1.30 + bool PollIdleTime(uint32_t* aIdleTime); 1.31 + 1.32 + static already_AddRefed<nsIdleServiceWin> GetInstance() 1.33 + { 1.34 + nsRefPtr<nsIdleServiceWin> idleService = 1.35 + nsIdleService::GetInstance().downcast<nsIdleServiceWin>(); 1.36 + if (!idleService) { 1.37 + idleService = new nsIdleServiceWin(); 1.38 + } 1.39 + 1.40 + return idleService.forget(); 1.41 + } 1.42 + 1.43 +protected: 1.44 + nsIdleServiceWin() { } 1.45 + virtual ~nsIdleServiceWin() { } 1.46 + bool UsePollMode(); 1.47 +}; 1.48 + 1.49 +#endif // nsIdleServiceWin_h__