Bug 1651165 - Rename idle service r=Gijs,geckoview-reviewers,snorp

Differential Revision: https://phabricator.services.mozilla.com/D83413
This commit is contained in:
Doug Thayer
2020-07-20 16:06:59 +00:00
parent 62b798f95a
commit 4db191dfe7
53 changed files with 319 additions and 295 deletions

View File

@@ -840,9 +840,9 @@ const OBSERVE_LASTWINDOW_CLOSE_TOPICS = AppConstants.platform != "macosx";
function BrowserGlue() {
XPCOMUtils.defineLazyServiceGetter(
this,
"_idleService",
"@mozilla.org/widget/idleservice;1",
"nsIIdleService"
"_userIdleService",
"@mozilla.org/widget/useridleservice;1",
"nsIUserIdleService"
);
XPCOMUtils.defineLazyGetter(this, "_distributionCustomizer", function() {
@@ -1191,11 +1191,14 @@ BrowserGlue.prototype = {
os.removeObserver(this, "weave:engine:clients:display-uris");
os.removeObserver(this, "session-save");
if (this._bookmarksBackupIdleTime) {
this._idleService.removeIdleObserver(this, this._bookmarksBackupIdleTime);
this._userIdleService.removeIdleObserver(
this,
this._bookmarksBackupIdleTime
);
delete this._bookmarksBackupIdleTime;
}
if (this._lateTasksIdleObserver) {
this._idleService.removeIdleObserver(
this._userIdleService.removeIdleObserver(
this._lateTasksIdleObserver,
LATE_TASKS_IDLE_TIME_SEC
);
@@ -1989,7 +1992,10 @@ BrowserGlue.prototype = {
}
if (this._bookmarksBackupIdleTime) {
this._idleService.removeIdleObserver(this, this._bookmarksBackupIdleTime);
this._userIdleService.removeIdleObserver(
this,
this._bookmarksBackupIdleTime
);
delete this._bookmarksBackupIdleTime;
}
@@ -2246,7 +2252,7 @@ BrowserGlue.prototype = {
this._scheduleArbitrarilyLateIdleTasks();
}
};
this._idleService.addIdleObserver(
this._userIdleService.addIdleObserver(
this._lateTasksIdleObserver,
LATE_TASKS_IDLE_TIME_SEC
);
@@ -2988,7 +2994,10 @@ BrowserGlue.prototype = {
}
}
}
this._idleService.addIdleObserver(this, this._bookmarksBackupIdleTime);
this._userIdleService.addIdleObserver(
this,
this._bookmarksBackupIdleTime
);
}
if (this._isNewProfile) {

View File

@@ -120,7 +120,7 @@ var SessionSaverInternal = {
/**
* `true` if the user has been idle for at least
* `SessionSaverInternal._intervalWhileIdle` ms. Idleness is computed
* with `nsIIdleService`.
* with `nsIUserIdleService`.
*/
_isIdle: false,
@@ -394,8 +394,8 @@ XPCOMUtils.defineLazyPreferenceGetter(
// to re-fetch the service instead of the original one in use; This is for a
// case that the Mock service in the unit test needs to be fetched to
// replace the original one.
var idleService = Cc["@mozilla.org/widget/idleservice;1"].getService(
Ci.nsIIdleService
var idleService = Cc["@mozilla.org/widget/useridleservice;1"].getService(
Ci.nsIUserIdleService
);
if (previous != undefined) {
idleService.removeIdleObserver(SessionSaverInternal, previous);
@@ -406,8 +406,8 @@ XPCOMUtils.defineLazyPreferenceGetter(
}
);
var idleService = Cc["@mozilla.org/widget/idleservice;1"].getService(
Ci.nsIIdleService
var idleService = Cc["@mozilla.org/widget/useridleservice;1"].getService(
Ci.nsIUserIdleService
);
idleService.addIdleObserver(
SessionSaverInternal,

View File

@@ -25,7 +25,7 @@ var idleService = {
}
},
QueryInterface: ChromeUtils.generateQI(["nsIIdleService"]),
QueryInterface: ChromeUtils.generateQI(["nsIUserIdleService"]),
idleTime: 19999,
addIdleObserver(observer, time) {
@@ -53,7 +53,7 @@ add_task(async function testIntervalChanges() {
// Mock an idle service.
let fakeIdleService = MockRegistrar.register(
"@mozilla.org/widget/idleservice;1",
"@mozilla.org/widget/useridleservice;1",
idleService
);
idleService._reset();

View File

@@ -49,8 +49,8 @@ XPCOMUtils.defineLazyGetter(this, "_stringBundle", function() {
XPCOMUtils.defineLazyServiceGetter(
this,
"_idle",
"@mozilla.org/widget/idleservice;1",
"nsIIdleService"
"@mozilla.org/widget/useridleservice;1",
"nsIUserIdleService"
);
XPCOMUtils.defineLazyServiceGetter(
this,

View File

@@ -175,7 +175,7 @@
#include "nsContainerFrame.h"
#include "nsIClassifiedChannel.h"
#include "nsIHttpChannelInternal.h"
#include "nsIIdleService.h"
#include "nsIUserIdleService.h"
#include "nsIImageLoadingContent.h"
#include "nsIInterfaceRequestor.h"
#include "nsIInterfaceRequestorUtils.h"
@@ -1419,8 +1419,8 @@ void nsContentUtils::SplitMimeType(const nsAString& aValue, nsString& aType,
nsresult nsContentUtils::IsUserIdle(uint32_t aRequestedIdleTimeInMS,
bool* aUserIsIdle) {
nsresult rv;
nsCOMPtr<nsIIdleService> idleService =
do_GetService("@mozilla.org/widget/idleservice;1", &rv);
nsCOMPtr<nsIUserIdleService> idleService =
do_GetService("@mozilla.org/widget/useridleservice;1", &rv);
NS_ENSURE_SUCCESS(rv, rv);
uint32_t idleTimeInMS;

View File

@@ -81,7 +81,7 @@ class nsHistory;
class nsGlobalWindowObserver;
class nsGlobalWindowOuter;
class nsDOMWindowUtils;
class nsIIdleService;
class nsIUserIdleService;
struct nsRect;
class nsWindowSizes;

View File

@@ -194,7 +194,7 @@
#include "nsIDragService.h"
#include "nsIExternalProtocolService.h"
#include "nsIGfxInfo.h"
#include "nsIIdleService.h"
#include "nsIUserIdleService.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsILocalStorageManager.h"
#include "nsIMemoryInfoDumper.h"
@@ -1870,8 +1870,8 @@ void ContentParent::ActorDestroy(ActorDestroyReason why) {
}
// Remove any and all idle listeners.
nsCOMPtr<nsIIdleService> idleService =
do_GetService("@mozilla.org/widget/idleservice;1");
nsCOMPtr<nsIUserIdleService> idleService =
do_GetService("@mozilla.org/widget/useridleservice;1");
MOZ_ASSERT(idleService);
RefPtr<ParentIdleListener> listener;
for (int32_t i = mIdleListeners.Length() - 1; i >= 0; --i) {
@@ -4576,8 +4576,8 @@ mozilla::ipc::IPCResult ContentParent::RecvRecordingDeviceEvents(
mozilla::ipc::IPCResult ContentParent::RecvAddIdleObserver(
const uint64_t& aObserver, const uint32_t& aIdleTimeInS) {
nsresult rv;
nsCOMPtr<nsIIdleService> idleService =
do_GetService("@mozilla.org/widget/idleservice;1", &rv);
nsCOMPtr<nsIUserIdleService> idleService =
do_GetService("@mozilla.org/widget/useridleservice;1", &rv);
NS_ENSURE_SUCCESS(rv, IPC_FAIL_NO_REASON(this));
RefPtr<ParentIdleListener> listener =
@@ -4595,8 +4595,8 @@ mozilla::ipc::IPCResult ContentParent::RecvRemoveIdleObserver(
listener = static_cast<ParentIdleListener*>(mIdleListeners[i].get());
if (listener->mObserver == aObserver && listener->mTime == aIdleTimeInS) {
nsresult rv;
nsCOMPtr<nsIIdleService> idleService =
do_GetService("@mozilla.org/widget/idleservice;1", &rv);
nsCOMPtr<nsIUserIdleService> idleService =
do_GetService("@mozilla.org/widget/useridleservice;1", &rv);
NS_ENSURE_SUCCESS(rv, IPC_FAIL_NO_REASON(this));
idleService->RemoveIdleObserver(listener, aIdleTimeInS);
mIdleListeners.RemoveElementAt(i);

View File

@@ -17,7 +17,7 @@
#include "mozilla/ipc/BackgroundParent.h"
#include "mozilla/ipc/BackgroundUtils.h"
#include "mozilla/ipc/PBackgroundChild.h"
#include "nsIIdleService.h"
#include "nsIUserIdleService.h"
#include "nsIObserverService.h"
#include "nsXULAppAPI.h"
#include "QuotaManager.h"
@@ -33,7 +33,7 @@ using namespace mozilla::ipc;
namespace {
const char kIdleServiceContractId[] = "@mozilla.org/widget/idleservice;1";
const char kIdleServiceContractId[] = "@mozilla.org/widget/useridleservice;1";
// The number of seconds we will wait after receiving the idle-daily
// notification before beginning maintenance.
@@ -349,7 +349,7 @@ void QuotaManagerService::PerformIdleMaintenance() {
// We don't want user activity to impact this code if we're running tests.
Unused << Observe(nullptr, OBSERVER_TOPIC_IDLE, nullptr);
} else if (!mIdleObserverRegistered) {
nsCOMPtr<nsIIdleService> idleService =
nsCOMPtr<nsIUserIdleService> idleService =
do_GetService(kIdleServiceContractId);
MOZ_ASSERT(idleService);
@@ -365,7 +365,7 @@ void QuotaManagerService::RemoveIdleObserver() {
MOZ_ASSERT(NS_IsMainThread());
if (mIdleObserverRegistered) {
nsCOMPtr<nsIIdleService> idleService =
nsCOMPtr<nsIUserIdleService> idleService =
do_GetService(kIdleServiceContractId);
MOZ_ASSERT(idleService);

View File

@@ -28,7 +28,7 @@
#include "nsCRT.h"
#include "nsEffectiveTLDService.h"
#include "nsIConsoleService.h"
#include "nsIIdleService.h"
#include "nsIUserIdleService.h"
#include "nsIInputStream.h"
#include "nsINavHistoryService.h"
#include "nsIObserverService.h"

View File

@@ -64,8 +64,8 @@ ChromeUtils.defineModuleGetter(
XPCOMUtils.defineLazyServiceGetter(
this,
"IdleService",
"@mozilla.org/widget/idleservice;1",
"nsIIdleService"
"@mozilla.org/widget/useridleservice;1",
"nsIUserIdleService"
);
XPCOMUtils.defineLazyServiceGetter(
this,

View File

@@ -4,8 +4,8 @@
function run_test() {
print("Init the fake idle service and check its identity.");
let fakeIdleService = Cc["@mozilla.org/widget/idleservice;1"].getService(
Ci.nsIIdleService
let fakeIdleService = Cc["@mozilla.org/widget/useridleservice;1"].getService(
Ci.nsIUserIdleService
);
try {
fakeIdleService.QueryInterface(Ci.nsIFactory);

View File

@@ -277,7 +277,7 @@ var _fakeIdleService = {
Ci.nsIComponentRegistrar
));
},
contractID: "@mozilla.org/widget/idleservice;1",
contractID: "@mozilla.org/widget/useridleservice;1",
CID: Components.ID("{9163a4ae-70c2-446c-9ac1-bbe4ab93004e}"),
activate: function FIS_activate() {
@@ -322,7 +322,7 @@ var _fakeIdleService = {
QueryInterface: ChromeUtils.generateQI(["nsIFactory"]),
},
// nsIIdleService
// nsIUserIdleService
get idleTime() {
return 0;
},
@@ -335,7 +335,7 @@ var _fakeIdleService = {
if (aIID.equals(Ci.nsIFactory)) {
return this.factory;
}
if (aIID.equals(Ci.nsIIdleService) || aIID.equals(Ci.nsISupports)) {
if (aIID.equals(Ci.nsIUserIdleService) || aIID.equals(Ci.nsISupports)) {
return this;
}
throw Components.Exception("", Cr.NS_ERROR_NO_INTERFACE);
@@ -348,7 +348,7 @@ var _fakeIdleService = {
*/
function do_get_idle() {
_fakeIdleService.deactivate();
return Cc[_fakeIdleService.contractID].getService(Ci.nsIIdleService);
return Cc[_fakeIdleService.contractID].getService(Ci.nsIUserIdleService);
}
// Map resource://test/ to current working directory and

View File

@@ -7,8 +7,8 @@
XPCOMUtils.defineLazyServiceGetter(
this,
"idleService",
"@mozilla.org/widget/idleservice;1",
"nsIIdleService"
"@mozilla.org/widget/useridleservice;1",
"nsIUserIdleService"
);
// WeakMap[Extension -> Object]

View File

@@ -44,7 +44,7 @@ add_task(async function testWithRealIdleService() {
let chromeScript = loadChromeScript(() => {
const {sendAsyncMessage} = this;
const idleService = Cc["@mozilla.org/widget/idleservice;1"].getService(Ci.nsIIdleService);
const idleService = Cc["@mozilla.org/widget/useridleservice;1"].getService(Ci.nsIUserIdleService);
let idleTime = idleService.idleTime;
sendAsyncMessage("detectionInterval", Math.max(Math.ceil(idleTime / 1000) + 10, 15));
});

View File

@@ -25,7 +25,7 @@ let idleService = {
this._activity.observerFires.push(state);
}
},
QueryInterface: ChromeUtils.generateQI(["nsIIdleService"]),
QueryInterface: ChromeUtils.generateQI(["nsIUserIdleService"]),
idleTime: 19999,
addIdleObserver: function(observer, time) {
this._observers.add(observer);
@@ -74,7 +74,7 @@ function checkActivity(expectedActivity) {
add_task(async function setup() {
let fakeIdleService = MockRegistrar.register(
"@mozilla.org/widget/idleservice;1",
"@mozilla.org/widget/useridleservice;1",
idleService
);
registerCleanupFunction(() => {

View File

@@ -470,8 +470,8 @@ function nsPlacesExpiration() {
XPCOMUtils.defineLazyServiceGetter(
this,
"_idle",
"@mozilla.org/widget/idleservice;1",
"nsIIdleService"
"@mozilla.org/widget/useridleservice;1",
"nsIUserIdleService"
);
this._prefBranch = Services.prefs.getBranch(PREF_BRANCH);

View File

@@ -5,7 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsWidgetsCID.h"
#include "nsIIdleService.h"
#include "nsIUserIdleService.h"
#ifndef TEST_NAME
# error "Must #define TEST_NAME before including places_test_harness_tail.h"
@@ -63,8 +63,8 @@ void do_test_finished() {
void disable_idle_service() {
(void)fprintf(stderr, TEST_INFO_STR "Disabling Idle Service.\n");
nsCOMPtr<nsIIdleService> idle =
do_GetService("@mozilla.org/widget/idleservice;1");
nsCOMPtr<nsIUserIdleService> idle =
do_GetService("@mozilla.org/widget/useridleservice;1");
idle->SetDisabled(true);
}

View File

@@ -3763,8 +3763,8 @@ var engineUpdateService = {
XPCOMUtils.defineLazyServiceGetter(
SearchService.prototype,
"idleService",
"@mozilla.org/widget/idleservice;1",
"nsIIdleService"
"@mozilla.org/widget/useridleservice;1",
"nsIUserIdleService"
);
/**

View File

@@ -266,7 +266,7 @@ var SearchTestUtils = Object.freeze({
}
},
QueryInterface: ChromeUtils.generateQI(["nsIIdleService"]),
QueryInterface: ChromeUtils.generateQI(["nsIUserIdleService"]),
idleTime: 19999,
addIdleObserver(observer, time) {
@@ -285,7 +285,7 @@ var SearchTestUtils = Object.freeze({
*/
useMockIdleService(registerCleanupFunction) {
let fakeIdleService = MockRegistrar.register(
"@mozilla.org/widget/idleservice;1",
"@mozilla.org/widget/useridleservice;1",
SearchTestUtils.idleService
);
registerCleanupFunction(() => {

View File

@@ -30,7 +30,7 @@ const { TelemetryPrioPing } = ChromeUtils.import(
);
XPCOMUtils.defineLazyServiceGetters(this, {
idleService: ["@mozilla.org/widget/idleservice;1", "nsIIdleService"],
idleService: ["@mozilla.org/widget/useridleservice;1", "nsIUserIdleService"],
});
const MIN_SUBSESSION_LENGTH_MS =

View File

@@ -30,11 +30,11 @@ Classes = [
},
{
'cid': '{6987230e-0098-4e78-bc5f-1493ee7519fa}',
'contract_ids': ['@mozilla.org/widget/idleservice;1'],
'contract_ids': ['@mozilla.org/widget/useridleservice;1'],
'singleton': True,
'type': 'nsIdleServiceAndroid',
'headers': ['/widget/android/nsIdleServiceAndroid.h'],
'constructor': 'nsIdleServiceAndroid::GetInstance',
'type': 'nsUserIdleServiceAndroid',
'headers': ['/widget/android/nsUserIdleServiceAndroid.h'],
'constructor': 'nsUserIdleServiceAndroid::GetInstance',
},
{
'cid': '{8b5314bc-db01-11d2-96ce-0060b0fb9956}',

View File

@@ -133,9 +133,9 @@ UNIFIED_SOURCES += [
'nsAppShell.cpp',
'nsClipboard.cpp',
'nsDeviceContextAndroid.cpp',
'nsIdleServiceAndroid.cpp',
'nsLookAndFeel.cpp',
'nsPrintSettingsServiceAndroid.cpp',
'nsUserIdleServiceAndroid.cpp',
'nsWidgetFactory.cpp',
'nsWindow.cpp',
'ProcInfo.cpp',

View File

@@ -1,34 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=4:tabstop=4:
*/
/* 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 nsIdleServiceAndroid_h__
#define nsIdleServiceAndroid_h__
#include "nsIdleService.h"
class nsIdleServiceAndroid : public nsIdleService {
public:
NS_INLINE_DECL_REFCOUNTING_INHERITED(nsIdleServiceAndroid, nsIdleService)
bool PollIdleTime(uint32_t* aIdleTime) override;
static already_AddRefed<nsIdleServiceAndroid> GetInstance() {
RefPtr<nsIdleService> idleService = nsIdleService::GetInstance();
if (!idleService) {
idleService = new nsIdleServiceAndroid();
}
return idleService.forget().downcast<nsIdleServiceAndroid>();
}
protected:
nsIdleServiceAndroid() {}
virtual ~nsIdleServiceAndroid() {}
bool UsePollMode() override;
};
#endif // nsIdleServiceAndroid_h__

View File

@@ -5,8 +5,10 @@
* 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/. */
#include "nsIdleServiceAndroid.h"
#include "nsUserIdleServiceAndroid.h"
bool nsIdleServiceAndroid::PollIdleTime(uint32_t* aIdleTime) { return false; }
bool nsUserIdleServiceAndroid::PollIdleTime(uint32_t* aIdleTime) {
return false;
}
bool nsIdleServiceAndroid::UsePollMode() { return false; }
bool nsUserIdleServiceAndroid::UsePollMode() { return false; }

View File

@@ -0,0 +1,35 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=4:tabstop=4:
*/
/* 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 nsUserIdleServiceAndroid_h__
#define nsUserIdleServiceAndroid_h__
#include "nsUserIdleService.h"
class nsUserIdleServiceAndroid : public nsUserIdleService {
public:
NS_INLINE_DECL_REFCOUNTING_INHERITED(nsUserIdleServiceAndroid,
nsUserIdleService)
bool PollIdleTime(uint32_t* aIdleTime) override;
static already_AddRefed<nsUserIdleServiceAndroid> GetInstance() {
RefPtr<nsUserIdleService> idleService = nsUserIdleService::GetInstance();
if (!idleService) {
idleService = new nsUserIdleServiceAndroid();
}
return idleService.forget().downcast<nsUserIdleServiceAndroid>();
}
protected:
nsUserIdleServiceAndroid() {}
virtual ~nsUserIdleServiceAndroid() {}
bool UsePollMode() override;
};
#endif // nsUserIdleServiceAndroid_h__

View File

@@ -49,7 +49,7 @@ using mozilla::dom::ContentParent;
#include "nsAppShell.h"
#include "nsFocusManager.h"
#include "nsIdleService.h"
#include "nsUserIdleService.h"
#include "nsLayoutUtils.h"
#include "nsViewManager.h"
@@ -2165,7 +2165,7 @@ void nsWindow::GeckoViewSupport::OnReady(jni::Object::Param aQueue) {
void nsWindow::UserActivity() {
if (!mIdleService) {
mIdleService = do_GetService("@mozilla.org/widget/idleservice;1");
mIdleService = do_GetService("@mozilla.org/widget/useridleservice;1");
}
if (mIdleService) {

View File

@@ -9,7 +9,7 @@
#include "nsBaseWidget.h"
#include "gfxPoint.h"
#include "nsIIdleServiceInternal.h"
#include "nsIUserIdleServiceInternal.h"
#include "nsTArray.h"
#include "EventDispatcher.h"
#include "mozilla/EventForwards.h"
@@ -352,7 +352,7 @@ class nsWindow final : public nsBaseWidget {
nsTArray<nsWindow*> mChildren;
nsWindow* mParent;
nsCOMPtr<nsIIdleServiceInternal> mIdleService;
nsCOMPtr<nsIUserIdleServiceInternal> mIdleService;
mozilla::ScreenIntCoord mDynamicToolbarMaxHeight;
mozilla::ScreenIntMargin mSafeAreaInsets;

View File

@@ -42,7 +42,6 @@ UNIFIED_SOURCES += [
'nsDeviceContextSpecX.mm',
'nsFilePicker.mm',
'nsIconLoaderService.mm',
'nsIdleServiceX.mm',
'nsLookAndFeel.mm',
'nsMacCursor.mm',
'nsMacDockSupport.mm',
@@ -66,6 +65,7 @@ UNIFIED_SOURCES += [
'nsTouchBarInput.mm',
'nsTouchBarInputIcon.mm',
'nsTouchBarUpdater.mm',
'nsUserIdleServiceX.mm',
'nsWidgetFactory.mm',
'nsWindowMap.mm',
'OSXNotificationCenter.mm',

View File

@@ -1,31 +0,0 @@
/* 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 nsIdleServiceX_h_
#define nsIdleServiceX_h_
#include "nsIdleService.h"
class nsIdleServiceX : public nsIdleService {
public:
NS_INLINE_DECL_REFCOUNTING_INHERITED(nsIdleServiceX, nsIdleService)
bool PollIdleTime(uint32_t* aIdleTime) override;
static already_AddRefed<nsIdleServiceX> GetInstance() {
RefPtr<nsIdleService> idleService = nsIdleService::GetInstance();
if (!idleService) {
idleService = new nsIdleServiceX();
}
return idleService.forget().downcast<nsIdleServiceX>();
}
protected:
nsIdleServiceX() {}
virtual ~nsIdleServiceX() {}
bool UsePollMode() override;
};
#endif // nsIdleServiceX_h_

View File

@@ -38,6 +38,7 @@
#include "mozilla/MouseEvents.h"
using namespace mozilla;
using namespace mozilla::dom;
static bool gConstructingMenu = false;
static bool gMenuMethodsSwizzled = false;

View File

@@ -0,0 +1,31 @@
/* 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 nsUserIdleServiceX_h_
#define nsUserIdleServiceX_h_
#include "nsUserIdleService.h"
class nsUserIdleServiceX : public nsUserIdleService {
public:
NS_INLINE_DECL_REFCOUNTING_INHERITED(nsUserIdleServiceX, nsUserIdleService)
bool PollIdleTime(uint32_t* aIdleTime) override;
static already_AddRefed<nsUserIdleServiceX> GetInstance() {
RefPtr<nsUserIdleService> idleService = nsUserIdleService::GetInstance();
if (!idleService) {
idleService = new nsUserIdleServiceX();
}
return idleService.forget().downcast<nsUserIdleServiceX>();
}
protected:
nsUserIdleServiceX() {}
virtual ~nsUserIdleServiceX() {}
bool UsePollMode() override;
};
#endif // nsUserIdleServiceX_h_

View File

@@ -2,11 +2,11 @@
* 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/. */
#include "nsIdleServiceX.h"
#include "nsUserIdleServiceX.h"
#include "nsObjCExceptions.h"
#import <Foundation/Foundation.h>
bool nsIdleServiceX::PollIdleTime(uint32_t* aIdleTime) {
bool nsUserIdleServiceX::PollIdleTime(uint32_t* aIdleTime) {
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
kern_return_t rval;
@@ -57,4 +57,4 @@ bool nsIdleServiceX::PollIdleTime(uint32_t* aIdleTime) {
NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(false);
}
bool nsIdleServiceX::UsePollMode() { return true; }
bool nsUserIdleServiceX::UsePollMode() { return true; }

View File

@@ -28,7 +28,7 @@
#include "nsLookAndFeel.h"
#include "nsSound.h"
#include "nsIdleServiceX.h"
#include "nsUserIdleServiceX.h"
#include "NativeKeyBindings.h"
#include "OSXNotificationCenter.h"
@@ -66,7 +66,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsPrinterListX)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSettingsServiceX, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintDialogServiceX, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSession, Init)
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIdleServiceX, nsIdleServiceX::GetInstance)
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsUserIdleServiceX, nsUserIdleServiceX::GetInstance)
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(ScreenManager, ScreenManager::GetAddRefedSingleton)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(OSXNotificationCenter, Init)
@@ -147,7 +147,7 @@ static const mozilla::Module::CIDEntry kWidgetCIDs[] = {
{&kNS_PRINTSESSION_CID, false, NULL, nsPrintSessionConstructor},
{&kNS_PRINTSETTINGSSERVICE_CID, false, NULL, nsPrintSettingsServiceXConstructor},
{&kNS_PRINTDIALOGSERVICE_CID, false, NULL, nsPrintDialogServiceXConstructor},
{&kNS_IDLE_SERVICE_CID, false, NULL, nsIdleServiceXConstructor},
{&kNS_IDLE_SERVICE_CID, false, NULL, nsUserIdleServiceXConstructor},
{&kNS_SYSTEMALERTSSERVICE_CID, false, NULL, OSXNotificationCenterConstructor},
{&kNS_NATIVEMENUSERVICE_CID, false, NULL, nsNativeMenuServiceXConstructor},
{&kNS_MACDOCKSUPPORT_CID, false, NULL, nsMacDockSupportConstructor},
@@ -177,7 +177,7 @@ static const mozilla::Module::ContractIDEntry kWidgetContracts[] = {
{"@mozilla.org/gfx/printsession;1", &kNS_PRINTSESSION_CID},
{"@mozilla.org/gfx/printsettings-service;1", &kNS_PRINTSETTINGSSERVICE_CID},
{NS_PRINTDIALOGSERVICE_CONTRACTID, &kNS_PRINTDIALOGSERVICE_CID},
{"@mozilla.org/widget/idleservice;1", &kNS_IDLE_SERVICE_CID},
{"@mozilla.org/widget/useridleservice;1", &kNS_IDLE_SERVICE_CID},
{"@mozilla.org/system-alerts-service;1", &kNS_SYSTEMALERTSSERVICE_CID},
{"@mozilla.org/widget/nativemenuservice;1", &kNS_NATIVEMENUSERVICE_CID},
{"@mozilla.org/widget/macdocksupport;1", &kNS_MACDOCKSUPPORT_CID},

View File

@@ -119,11 +119,11 @@ if defined('MOZ_X11'):
},
{
'cid': '{6987230e-0098-4e78-bc5f-1493ee7519fa}',
'contract_ids': ['@mozilla.org/widget/idleservice;1'],
'contract_ids': ['@mozilla.org/widget/useridleservice;1'],
'singleton': True,
'type': 'nsIdleService',
'headers': ['/widget/gtk/nsIdleServiceGTK.h'],
'constructor': 'nsIdleServiceGTK::GetInstance',
'type': 'nsUserIdleService',
'headers': ['/widget/gtk/nsUserIdleServiceGTK.h'],
'constructor': 'nsUserIdleServiceGTK::GetInstance',
},
]

View File

@@ -65,7 +65,7 @@ if CONFIG['MOZ_X11']:
'CompositorWidgetParent.cpp',
'GtkCompositorWidget.cpp',
'InProcessGtkCompositorWidget.cpp',
'nsIdleServiceGTK.cpp',
'nsUserIdleServiceGTK.cpp',
]
EXPORTS.mozilla.widget += [
'CompositorWidgetChild.h',

View File

@@ -7,14 +7,14 @@
#include <gtk/gtk.h>
#include "nsIdleServiceGTK.h"
#include "nsUserIdleServiceGTK.h"
#include "nsDebug.h"
#include "prlink.h"
#include "mozilla/Logging.h"
using mozilla::LogLevel;
static mozilla::LazyLogModule sIdleLog("nsIIdleService");
static mozilla::LazyLogModule sIdleLog("nsIUserIdleService");
typedef bool (*_XScreenSaverQueryExtension_fn)(Display* dpy, int* event_base,
int* error_base);
@@ -35,7 +35,7 @@ static void Initialize() {
return;
}
// This will leak - See comments in ~nsIdleServiceGTK().
// This will leak - See comments in ~nsUserIdleServiceGTK().
PRLibrary* xsslib = PR_LoadLibrary("libXss.so.1");
if (!xsslib) // ouch.
{
@@ -61,9 +61,11 @@ static void Initialize() {
sInitialized = true;
}
nsIdleServiceGTK::nsIdleServiceGTK() : mXssInfo(nullptr) { Initialize(); }
nsUserIdleServiceGTK::nsUserIdleServiceGTK() : mXssInfo(nullptr) {
Initialize();
}
nsIdleServiceGTK::~nsIdleServiceGTK() {
nsUserIdleServiceGTK::~nsUserIdleServiceGTK() {
if (mXssInfo) XFree(mXssInfo);
// It is not safe to unload libXScrnSaver until each display is closed because
@@ -77,7 +79,7 @@ nsIdleServiceGTK::~nsIdleServiceGTK() {
#endif
}
bool nsIdleServiceGTK::PollIdleTime(uint32_t* aIdleTime) {
bool nsUserIdleServiceGTK::PollIdleTime(uint32_t* aIdleTime) {
if (!sInitialized) {
// For some reason, we could not find xscreensaver.
return false;
@@ -110,4 +112,4 @@ bool nsIdleServiceGTK::PollIdleTime(uint32_t* aIdleTime) {
return false;
}
bool nsIdleServiceGTK::UsePollMode() { return sInitialized; }
bool nsUserIdleServiceGTK::UsePollMode() { return sInitialized; }

View File

@@ -5,10 +5,10 @@
* 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 nsIdleServiceGTK_h__
#define nsIdleServiceGTK_h__
#ifndef nsUserIdleServiceGTK_h__
#define nsUserIdleServiceGTK_h__
#include "nsIdleService.h"
#include "nsUserIdleService.h"
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <gdk/gdkx.h>
@@ -22,29 +22,29 @@ typedef struct {
unsigned long event_mask; // event stuff
} XScreenSaverInfo;
class nsIdleServiceGTK : public nsIdleService {
class nsUserIdleServiceGTK : public nsUserIdleService {
public:
NS_INLINE_DECL_REFCOUNTING_INHERITED(nsIdleServiceGTK, nsIdleService)
NS_INLINE_DECL_REFCOUNTING_INHERITED(nsUserIdleServiceGTK, nsUserIdleService)
virtual bool PollIdleTime(uint32_t* aIdleTime) override;
static already_AddRefed<nsIdleServiceGTK> GetInstance() {
RefPtr<nsIdleServiceGTK> idleService =
nsIdleService::GetInstance().downcast<nsIdleServiceGTK>();
static already_AddRefed<nsUserIdleServiceGTK> GetInstance() {
RefPtr<nsUserIdleServiceGTK> idleService =
nsUserIdleService::GetInstance().downcast<nsUserIdleServiceGTK>();
if (!idleService) {
idleService = new nsIdleServiceGTK();
idleService = new nsUserIdleServiceGTK();
}
return idleService.forget();
}
private:
~nsIdleServiceGTK();
~nsUserIdleServiceGTK();
XScreenSaverInfo* mXssInfo;
protected:
nsIdleServiceGTK();
nsUserIdleServiceGTK();
virtual bool UsePollMode() override;
};
#endif // nsIdleServiceGTK_h__
#endif // nsUserIdleServiceGTK_h__

View File

@@ -74,7 +74,7 @@
#include "nsGfxCIID.h"
#include "nsGtkUtils.h"
#include "mozilla/layers/LayersTypes.h"
#include "nsIIdleServiceInternal.h"
#include "nsIUserIdleServiceInternal.h"
#include "GLContext.h"
#include "gfx2DGlue.h"
@@ -367,8 +367,8 @@ static inline bool TimestampIsNewerThan(guint32 a, guint32 b) {
}
static void UpdateLastInputEventTime(void* aGdkEvent) {
nsCOMPtr<nsIIdleServiceInternal> idleService =
do_GetService("@mozilla.org/widget/idleservice;1");
nsCOMPtr<nsIUserIdleServiceInternal> idleService =
do_GetService("@mozilla.org/widget/useridleservice;1");
if (idleService) {
idleService->ResetIdleTimeOut(0);
}

View File

@@ -109,8 +109,6 @@ XPIDL_SOURCES += [
'nsIFormatConverter.idl',
'nsIGfxInfo.idl',
'nsIGfxInfoDebug.idl',
'nsIIdleService.idl',
'nsIIdleServiceInternal.idl',
'nsIPaper.idl',
'nsIPrinter.idl',
'nsIPrinterList.idl',
@@ -122,6 +120,8 @@ XPIDL_SOURCES += [
'nsISharePicker.idl',
'nsISound.idl',
'nsITransferable.idl',
'nsIUserIdleService.idl',
'nsIUserIdleServiceInternal.idl',
]
XPIDL_MODULE = 'widget'
@@ -137,7 +137,6 @@ EXPORTS += [
'nsBaseScreen.h',
'nsBaseWidget.h',
'nsIDeviceContextSpec.h',
'nsIdleService.h',
'nsIKeyEventInPluginCallback.h',
'nsIPluginWidget.h',
'nsIPrintDialogService.h',
@@ -146,6 +145,7 @@ EXPORTS += [
'nsIWidgetListener.h',
'nsPaper.h',
'nsPrinter.h',
'nsUserIdleService.h',
'nsWidgetInitData.h',
'nsWidgetsCID.h',
'PuppetWidget.h',
@@ -205,7 +205,6 @@ UNIFIED_SOURCES += [
'nsDragServiceProxy.cpp',
'nsFilePickerProxy.cpp',
'nsHTMLFormatConverter.cpp',
'nsIdleService.cpp',
'nsIWidgetListener.cpp',
'nsNativeBasicTheme.cpp',
'nsPaper.cpp',
@@ -214,6 +213,7 @@ UNIFIED_SOURCES += [
'nsPrintSettingsImpl.cpp',
'nsSoundProxy.cpp',
'nsTransferable.cpp',
'nsUserIdleService.cpp',
'nsXPLookAndFeel.cpp',
'PuppetBidiKeyboard.cpp',
'PuppetWidget.cpp',

View File

@@ -17,7 +17,7 @@ interface nsIObserver;
*/
[scriptable, uuid(cc52f19a-63ae-4a1c-9cc3-e79eace0b471)]
interface nsIIdleService : nsISupports
interface nsIUserIdleService : nsISupports
{
/**
* The amount of time in milliseconds that has passed
@@ -39,7 +39,7 @@ interface nsIIdleService : nsISupports
*
* @note
* The subject of the notification the observer will get is always the
* nsIIdleService itself.
* nsIUserIdleService itself.
* When the user goes idle, the observer topic is "idle" and when he gets
* back, the observer topic is "active".
* The data param for the notification contains the current user idle time.

View File

@@ -2,10 +2,10 @@
* 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/. */
#include "nsIIdleService.idl"
#include "nsIUserIdleService.idl"
[scriptable, uuid(7b89a2e7-ed12-42e0-b86d-4984239abd7b)]
interface nsIIdleServiceInternal : nsIIdleService
interface nsIUserIdleServiceInternal : nsIUserIdleService
{
/**
* "Resets the idle time to the value specified."

View File

@@ -5,7 +5,7 @@
* 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/. */
#include "nsIdleService.h"
#include "nsUserIdleService.h"
#include "nsString.h"
#include "nsIObserverService.h"
#include "nsDebug.h"
@@ -59,15 +59,16 @@ class IdleListenerComparator {
};
////////////////////////////////////////////////////////////////////////////////
//// nsIdleServiceDaily
//// nsUserIdleServiceDaily
NS_IMPL_ISUPPORTS(nsIdleServiceDaily, nsIObserver, nsISupportsWeakReference)
NS_IMPL_ISUPPORTS(nsUserIdleServiceDaily, nsIObserver, nsISupportsWeakReference)
NS_IMETHODIMP
nsIdleServiceDaily::Observe(nsISupports*, const char* aTopic, const char16_t*) {
MOZ_LOG(
sLog, LogLevel::Debug,
("nsIdleServiceDaily: Observe '%s' (%d)", aTopic, mShutdownInProgress));
nsUserIdleServiceDaily::Observe(nsISupports*, const char* aTopic,
const char16_t*) {
MOZ_LOG(sLog, LogLevel::Debug,
("nsUserIdleServiceDaily: Observe '%s' (%d)", aTopic,
mShutdownInProgress));
if (strcmp(aTopic, "profile-after-change") == 0) {
// We are back. Start sending notifications again.
@@ -86,7 +87,7 @@ nsIdleServiceDaily::Observe(nsISupports*, const char* aTopic, const char16_t*) {
MOZ_ASSERT(strcmp(aTopic, OBSERVER_TOPIC_IDLE) == 0);
MOZ_LOG(sLog, LogLevel::Debug,
("nsIdleServiceDaily: Notifying idle-daily observers"));
("nsUserIdleServiceDaily: Notifying idle-daily observers"));
#ifdef MOZ_WIDGET_ANDROID
__android_log_print(LOG_LEVEL, LOG_TAG, "Notifying idle-daily observers");
#endif
@@ -119,8 +120,9 @@ nsIdleServiceDaily::Observe(nsISupports*, const char* aTopic, const char16_t*) {
prefs->SavePrefFile(nullptr);
}
MOZ_LOG(sLog, LogLevel::Debug,
("nsIdleServiceDaily: Storing last idle time as %d sec.", nowSec));
MOZ_LOG(
sLog, LogLevel::Debug,
("nsUserIdleServiceDaily: Storing last idle time as %d sec.", nowSec));
#ifdef MOZ_WIDGET_ANDROID
__android_log_print(LOG_LEVEL, LOG_TAG, "Storing last idle time as %d",
nowSec);
@@ -131,17 +133,17 @@ nsIdleServiceDaily::Observe(nsISupports*, const char* aTopic, const char16_t*) {
PR_Now() + ((PRTime)SECONDS_PER_DAY * (PRTime)PR_USEC_PER_SEC);
MOZ_LOG(sLog, LogLevel::Debug,
("nsIdleServiceDaily: Restarting daily timer"));
("nsUserIdleServiceDaily: Restarting daily timer"));
// Start timer for the next check in one day.
(void)mTimer->InitWithNamedFuncCallback(
DailyCallback, this, SECONDS_PER_DAY * PR_MSEC_PER_SEC,
nsITimer::TYPE_ONE_SHOT, "nsIdleServiceDaily::Observe");
nsITimer::TYPE_ONE_SHOT, "nsUserIdleServiceDaily::Observe");
return NS_OK;
}
nsIdleServiceDaily::nsIdleServiceDaily(nsIIdleService* aIdleService)
nsUserIdleServiceDaily::nsUserIdleServiceDaily(nsIUserIdleService* aIdleService)
: mIdleService(aIdleService),
mTimer(NS_NewTimer()),
mCategoryObservers(OBSERVER_TOPIC_IDLE_DAILY),
@@ -149,7 +151,7 @@ nsIdleServiceDaily::nsIdleServiceDaily(nsIIdleService* aIdleService)
mExpectedTriggerTime(0),
mIdleDailyTriggerWait(DAILY_SIGNIFICANT_IDLE_SERVICE_SEC) {}
void nsIdleServiceDaily::Init() {
void nsUserIdleServiceDaily::Init() {
// First check the time of the last idle-daily event notification. If it
// has been 24 hours or higher, or if we have never sent an idle-daily,
// get ready to send an idle-daily event. Otherwise set a timer targeted
@@ -161,7 +163,7 @@ void nsIdleServiceDaily::Init() {
// this value.
if (lastDaily == -1) {
MOZ_LOG(sLog, LogLevel::Debug,
("nsIdleServiceDaily: Init: disabled idle-daily"));
("nsUserIdleServiceDaily: Init: disabled idle-daily"));
return;
}
@@ -173,7 +175,7 @@ void nsIdleServiceDaily::Init() {
int32_t secondsSinceLastDaily = nowSec - lastDaily;
MOZ_LOG(sLog, LogLevel::Debug,
("nsIdleServiceDaily: Init: seconds since last daily: %d",
("nsUserIdleServiceDaily: Init: seconds since last daily: %d",
secondsSinceLastDaily));
// If it has been twenty four hours or more or if we have never sent an
@@ -183,15 +185,16 @@ void nsIdleServiceDaily::Init() {
bool hasBeenLongWait =
(lastDaily && (secondsSinceLastDaily > (SECONDS_PER_DAY * 2)));
MOZ_LOG(sLog, LogLevel::Debug,
("nsIdleServiceDaily: has been long wait? %d", hasBeenLongWait));
MOZ_LOG(
sLog, LogLevel::Debug,
("nsUserIdleServiceDaily: has been long wait? %d", hasBeenLongWait));
// StageIdleDaily sets up a wait for the user to become idle and then
// sends the idle-daily event.
StageIdleDaily(hasBeenLongWait);
} else {
MOZ_LOG(sLog, LogLevel::Debug,
("nsIdleServiceDaily: Setting timer a day from now"));
("nsUserIdleServiceDaily: Setting timer a day from now"));
#ifdef MOZ_WIDGET_ANDROID
__android_log_print(LOG_LEVEL, LOG_TAG, "Setting timer a day from now");
#endif
@@ -202,7 +205,7 @@ void nsIdleServiceDaily::Init() {
(SECONDS_PER_DAY - secondsSinceLastDaily) * PR_MSEC_PER_SEC;
MOZ_LOG(sLog, LogLevel::Debug,
("nsIdleServiceDaily: Seconds till next timeout: %d",
("nsUserIdleServiceDaily: Seconds till next timeout: %d",
(SECONDS_PER_DAY - secondsSinceLastDaily)));
// Mark the time at which we expect this to fire. On systems with faulty
@@ -213,31 +216,32 @@ void nsIdleServiceDaily::Init() {
(void)mTimer->InitWithNamedFuncCallback(
DailyCallback, this, milliSecLeftUntilDaily, nsITimer::TYPE_ONE_SHOT,
"nsIdleServiceDaily::Init");
"nsUserIdleServiceDaily::Init");
}
// Register for when we should terminate/pause
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
if (obs) {
MOZ_LOG(sLog, LogLevel::Debug,
("nsIdleServiceDaily: Registering for system event observers."));
MOZ_LOG(
sLog, LogLevel::Debug,
("nsUserIdleServiceDaily: Registering for system event observers."));
obs->AddObserver(this, "xpcom-will-shutdown", true);
obs->AddObserver(this, "profile-change-teardown", true);
obs->AddObserver(this, "profile-after-change", true);
}
}
nsIdleServiceDaily::~nsIdleServiceDaily() {
nsUserIdleServiceDaily::~nsUserIdleServiceDaily() {
if (mTimer) {
mTimer->Cancel();
mTimer = nullptr;
}
}
void nsIdleServiceDaily::StageIdleDaily(bool aHasBeenLongWait) {
void nsUserIdleServiceDaily::StageIdleDaily(bool aHasBeenLongWait) {
NS_ASSERTION(mIdleService, "No idle service available?");
MOZ_LOG(sLog, LogLevel::Debug,
("nsIdleServiceDaily: Registering Idle observer callback "
("nsUserIdleServiceDaily: Registering Idle observer callback "
"(short wait requested? %d)",
aHasBeenLongWait));
#ifdef MOZ_WIDGET_ANDROID
@@ -250,13 +254,14 @@ void nsIdleServiceDaily::StageIdleDaily(bool aHasBeenLongWait) {
}
// static
void nsIdleServiceDaily::DailyCallback(nsITimer* aTimer, void* aClosure) {
MOZ_LOG(sLog, LogLevel::Debug, ("nsIdleServiceDaily: DailyCallback running"));
void nsUserIdleServiceDaily::DailyCallback(nsITimer* aTimer, void* aClosure) {
MOZ_LOG(sLog, LogLevel::Debug,
("nsUserIdleServiceDaily: DailyCallback running"));
#ifdef MOZ_WIDGET_ANDROID
__android_log_print(LOG_LEVEL, LOG_TAG, "DailyCallback running");
#endif
nsIdleServiceDaily* self = static_cast<nsIdleServiceDaily*>(aClosure);
nsUserIdleServiceDaily* self = static_cast<nsUserIdleServiceDaily*>(aClosure);
// Check to be sure the timer didn't fire early. This currently only
// happens on android.
@@ -269,7 +274,7 @@ void nsIdleServiceDaily::DailyCallback(nsITimer* aTimer, void* aClosure) {
delayTime += 10 * PR_USEC_PER_MSEC;
MOZ_LOG(sLog, LogLevel::Debug,
("nsIdleServiceDaily: DailyCallback resetting timer to %" PRId64
("nsUserIdleServiceDaily: DailyCallback resetting timer to %" PRId64
" msec",
delayTime / PR_USEC_PER_MSEC));
#ifdef MOZ_WIDGET_ANDROID
@@ -280,7 +285,7 @@ void nsIdleServiceDaily::DailyCallback(nsITimer* aTimer, void* aClosure) {
(void)self->mTimer->InitWithNamedFuncCallback(
DailyCallback, self, delayTime / PR_USEC_PER_MSEC,
nsITimer::TYPE_ONE_SHOT, "nsIdleServiceDaily::DailyCallback");
nsITimer::TYPE_ONE_SHOT, "nsUserIdleServiceDaily::DailyCallback");
return;
}
@@ -359,18 +364,18 @@ void nsIdleServiceDaily::DailyCallback(nsITimer* aTimer, void* aClosure) {
*/
////////////////////////////////////////////////////////////////////////////////
//// nsIdleService
//// nsUserIdleService
namespace {
nsIdleService* gIdleService;
nsUserIdleService* gIdleService;
} // namespace
already_AddRefed<nsIdleService> nsIdleService::GetInstance() {
RefPtr<nsIdleService> instance(gIdleService);
already_AddRefed<nsUserIdleService> nsUserIdleService::GetInstance() {
RefPtr<nsUserIdleService> instance(gIdleService);
return instance.forget();
}
nsIdleService::nsIdleService()
nsUserIdleService::nsUserIdleService()
: mCurrentlySetToTimeoutAt(TimeStamp()),
mIdleObserverCount(0),
mDeltaToNextIdleSwitchInS(UINT32_MAX),
@@ -378,12 +383,12 @@ nsIdleService::nsIdleService()
MOZ_ASSERT(!gIdleService);
gIdleService = this;
if (XRE_IsParentProcess()) {
mDailyIdle = new nsIdleServiceDaily(this);
mDailyIdle = new nsUserIdleServiceDaily(this);
mDailyIdle->Init();
}
}
nsIdleService::~nsIdleService() {
nsUserIdleService::~nsUserIdleService() {
if (mTimer) {
mTimer->Cancel();
}
@@ -392,10 +397,12 @@ nsIdleService::~nsIdleService() {
gIdleService = nullptr;
}
NS_IMPL_ISUPPORTS(nsIdleService, nsIIdleService, nsIIdleServiceInternal)
NS_IMPL_ISUPPORTS(nsUserIdleService, nsIUserIdleService,
nsIUserIdleServiceInternal)
NS_IMETHODIMP
nsIdleService::AddIdleObserver(nsIObserver* aObserver, uint32_t aIdleTimeInS) {
nsUserIdleService::AddIdleObserver(nsIObserver* aObserver,
uint32_t aIdleTimeInS) {
NS_ENSURE_ARG_POINTER(aObserver);
// We don't accept idle time at 0, and we can't handle idle time that are too
// high either - no more than ~136 years.
@@ -454,7 +461,8 @@ nsIdleService::AddIdleObserver(nsIObserver* aObserver, uint32_t aIdleTimeInS) {
}
NS_IMETHODIMP
nsIdleService::RemoveIdleObserver(nsIObserver* aObserver, uint32_t aTimeInS) {
nsUserIdleService::RemoveIdleObserver(nsIObserver* aObserver,
uint32_t aTimeInS) {
NS_ENSURE_ARG_POINTER(aObserver);
NS_ENSURE_ARG(aTimeInS);
@@ -499,7 +507,7 @@ nsIdleService::RemoveIdleObserver(nsIObserver* aObserver, uint32_t aTimeInS) {
}
NS_IMETHODIMP
nsIdleService::ResetIdleTimeOut(uint32_t idleDeltaInMS) {
nsUserIdleService::ResetIdleTimeOut(uint32_t idleDeltaInMS) {
MOZ_LOG(sLog, LogLevel::Debug,
("idleService: Reset idle timeout (last interaction %u msec)",
idleDeltaInMS));
@@ -572,7 +580,7 @@ nsIdleService::ResetIdleTimeOut(uint32_t idleDeltaInMS) {
}
NS_IMETHODIMP
nsIdleService::GetIdleTime(uint32_t* idleTime) {
nsUserIdleService::GetIdleTime(uint32_t* idleTime) {
// Check sanity of in parameter.
if (!idleTime) {
return NS_ERROR_NULL_POINTER;
@@ -613,31 +621,32 @@ nsIdleService::GetIdleTime(uint32_t* idleTime) {
return NS_OK;
}
bool nsIdleService::PollIdleTime(uint32_t* /*aIdleTime*/) {
bool nsUserIdleService::PollIdleTime(uint32_t* /*aIdleTime*/) {
// Default behavior is not to have the ability to poll an idle time.
return false;
}
bool nsIdleService::UsePollMode() {
bool nsUserIdleService::UsePollMode() {
uint32_t dummy;
return PollIdleTime(&dummy);
}
nsresult nsIdleService::GetDisabled(bool* aResult) {
nsresult nsUserIdleService::GetDisabled(bool* aResult) {
*aResult = mDisabled;
return NS_OK;
}
nsresult nsIdleService::SetDisabled(bool aDisabled) {
nsresult nsUserIdleService::SetDisabled(bool aDisabled) {
mDisabled = aDisabled;
return NS_OK;
}
void nsIdleService::StaticIdleTimerCallback(nsITimer* aTimer, void* aClosure) {
static_cast<nsIdleService*>(aClosure)->IdleTimerCallback();
void nsUserIdleService::StaticIdleTimerCallback(nsITimer* aTimer,
void* aClosure) {
static_cast<nsUserIdleService*>(aClosure)->IdleTimerCallback();
}
void nsIdleService::IdleTimerCallback(void) {
void nsUserIdleService::IdleTimerCallback(void) {
// Remember that we no longer have a timer running.
mCurrentlySetToTimeoutAt = TimeStamp();
@@ -760,7 +769,7 @@ void nsIdleService::IdleTimerCallback(void) {
}
}
void nsIdleService::SetTimerExpiryIfBefore(TimeStamp aNextTimeout) {
void nsUserIdleService::SetTimerExpiryIfBefore(TimeStamp aNextTimeout) {
TimeDuration nextTimeoutDuration = aNextTimeout - TimeStamp::Now();
MOZ_LOG(
@@ -811,11 +820,11 @@ void nsIdleService::SetTimerExpiryIfBefore(TimeStamp aNextTimeout) {
// Start the timer
mTimer->InitWithNamedFuncCallback(
StaticIdleTimerCallback, this, deltaTime.ToMilliseconds(),
nsITimer::TYPE_ONE_SHOT, "nsIdleService::SetTimerExpiryIfBefore");
nsITimer::TYPE_ONE_SHOT, "nsUserIdleService::SetTimerExpiryIfBefore");
}
}
void nsIdleService::ReconfigureTimer(void) {
void nsUserIdleService::ReconfigureTimer(void) {
// Check if either someone is idle, or someone will become idle.
if ((mIdleObserverCount == 0) && UINT32_MAX == mDeltaToNextIdleSwitchInS) {
// If not, just let any existing timers run to completion

View File

@@ -5,15 +5,15 @@
* 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 nsIdleService_h__
#define nsIdleService_h__
#ifndef nsUserIdleService_h__
#define nsUserIdleService_h__
#include "nsIIdleServiceInternal.h"
#include "nsIUserIdleServiceInternal.h"
#include "nsCOMPtr.h"
#include "nsITimer.h"
#include "nsTArray.h"
#include "nsIObserver.h"
#include "nsIIdleService.h"
#include "nsIUserIdleService.h"
#include "nsCategoryCache.h"
#include "nsWeakReference.h"
#include "mozilla/TimeStamp.h"
@@ -34,17 +34,18 @@ class IdleListener {
};
// This one will be declared later.
class nsIdleService;
class nsUserIdleService;
/**
* Class to handle the daily idle timer.
*/
class nsIdleServiceDaily : public nsIObserver, public nsSupportsWeakReference {
class nsUserIdleServiceDaily : public nsIObserver,
public nsSupportsWeakReference {
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER
explicit nsIdleServiceDaily(nsIIdleService* aIdleService);
explicit nsUserIdleServiceDaily(nsIUserIdleService* aIdleService);
/**
* Initializes the daily idle observer.
@@ -54,7 +55,7 @@ class nsIdleServiceDaily : public nsIObserver, public nsSupportsWeakReference {
void Init();
private:
virtual ~nsIdleServiceDaily();
virtual ~nsUserIdleServiceDaily();
/**
* StageIdleDaily is the interim call made when an idle-daily event is due.
@@ -62,9 +63,9 @@ class nsIdleServiceDaily : public nsIObserver, public nsSupportsWeakReference {
* session, so this sets up a short wait for an idle event which triggers
* the actual idle-daily event.
*
* @param aHasBeenLongWait Pass true indicating nsIdleServiceDaily is having
* trouble getting the idle-daily event fired. If true StageIdleDaily will
* use a shorter idle wait time before firing idle-daily.
* @param aHasBeenLongWait Pass true indicating nsUserIdleServiceDaily is
* having trouble getting the idle-daily event fired. If true StageIdleDaily
* will use a shorter idle wait time before firing idle-daily.
*/
void StageIdleDaily(bool aHasBeenLongWait);
@@ -73,7 +74,7 @@ class nsIdleServiceDaily : public nsIObserver, public nsSupportsWeakReference {
* idle service, part to avoid potential pointer corruption due to this class
* being instantiated in the constructor of the service itself.
*/
nsIIdleService* mIdleService;
nsIUserIdleService* mIdleService;
/**
* Place to hold the timer used by this class to determine when a day has
@@ -110,17 +111,16 @@ class nsIdleServiceDaily : public nsIObserver, public nsSupportsWeakReference {
int32_t mIdleDailyTriggerWait;
};
class nsIdleService : public nsIIdleServiceInternal {
class nsUserIdleService : public nsIUserIdleServiceInternal {
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIIDLESERVICE
NS_DECL_NSIIDLESERVICEINTERNAL
NS_DECL_NSIUSERIDLESERVICE NS_DECL_NSIUSERIDLESERVICEINTERNAL
protected:
static already_AddRefed<nsIdleService> GetInstance();
protected : static already_AddRefed<nsUserIdleService>
GetInstance();
nsIdleService();
virtual ~nsIdleService();
nsUserIdleService();
virtual ~nsUserIdleService();
/**
* If there is a platform specific function to poll the system idel time
@@ -177,7 +177,7 @@ class nsIdleService : public nsIIdleServiceInternal {
/**
* Object keeping track of the daily idle thingy.
*/
RefPtr<nsIdleServiceDaily> mDailyIdle;
RefPtr<nsUserIdleServiceDaily> mDailyIdle;
/**
* Number of observers currently in idle mode.
@@ -224,4 +224,4 @@ class nsIdleService : public nsIIdleServiceInternal {
void IdleTimerCallback(void);
};
#endif // nsIdleService_h__
#endif // nsUserIdleService_h__

View File

@@ -50,16 +50,16 @@ var idleObserver =
// if (diff >= 5000)
// alert(data + " " + newIdleSeconds);
// Attempt to get to the nsIIdleService
// Attempt to get to the nsIUserIdleService
var subjectOK = false;
try {
var idleService = subject.QueryInterface(nsIIdleService);
var idleService = subject.QueryInterface(nsIUserIdleService);
subjectOK = true;
}
catch (ex)
{}
ok(subjectOK, "The subject of the notification should be the " +
"nsIIdleService.");
"nsIUserIdleService.");
// Attempt to remove ourselves.
var removedObserver = false;
@@ -80,17 +80,17 @@ var idleObserver =
};
const nsIIdleService = Ci.nsIIdleService;
const nsIISCID = "@mozilla.org/widget/idleservice;1";
const nsIUserIdleService = Ci.nsIUserIdleService;
const nsIISCID = "@mozilla.org/widget/useridleservice;1";
var idleService = null;
try
{
idleService = Cc[nsIISCID].getService(nsIIdleService);
idleService = Cc[nsIISCID].getService(nsIUserIdleService);
}
catch (ex)
{}
ok(idleService, "nsIIdleService should exist and be implemented on all tier 1 platforms.");
ok(idleService, "nsIUserIdleService should exist and be implemented on all tier 1 platforms.");
var idleTime = null;
var gotIdleTime = false;
@@ -120,7 +120,7 @@ try
catch (ex)
{}
ok(addedObserver, "The nsIIdleService should allow us to add an observer.");
ok(addedObserver, "The nsIUserIdleService should allow us to add an observer.");
addedObserver = false;
try
@@ -131,7 +131,7 @@ try
catch (ex)
{}
ok(addedObserver, "The nsIIdleService should allow us to add the same observer again.");
ok(addedObserver, "The nsIUserIdleService should allow us to add the same observer again.");
var removedObserver = false;
try
@@ -142,7 +142,7 @@ try
catch (ex)
{}
ok(removedObserver, "The nsIIdleService should allow us to remove the observer just once.");
ok(removedObserver, "The nsIUserIdleService should allow us to remove the observer just once.");
function testIdleTime()
{

View File

@@ -16,7 +16,7 @@
#include "nsAlgorithm.h"
#include "nsExceptionHandler.h"
#include "nsGkAtoms.h"
#include "nsIIdleServiceInternal.h"
#include "nsIUserIdleServiceInternal.h"
#include "nsIWindowsRegKey.h"
#include "nsMemory.h"
#include "nsPrintfCString.h"
@@ -3866,7 +3866,7 @@ void NativeKey::WillDispatchKeyboardEvent(WidgetKeyboardEvent& aKeyboardEvent,
*****************************************************************************/
KeyboardLayout* KeyboardLayout::sInstance = nullptr;
nsIIdleServiceInternal* KeyboardLayout::sIdleService = nullptr;
nsIUserIdleServiceInternal* KeyboardLayout::sIdleService = nullptr;
// This log is very noisy if you don't want to retrieve the mapping table
// of specific keyboard layout. LogLevel::Debug and LogLevel::Verbose are
@@ -3878,8 +3878,8 @@ LazyLogModule sKeyboardLayoutLogger("KeyboardLayoutWidgets");
KeyboardLayout* KeyboardLayout::GetInstance() {
if (!sInstance) {
sInstance = new KeyboardLayout();
nsCOMPtr<nsIIdleServiceInternal> idleService =
do_GetService("@mozilla.org/widget/idleservice;1");
nsCOMPtr<nsIUserIdleServiceInternal> idleService =
do_GetService("@mozilla.org/widget/useridleservice;1");
// The refcount will be decreased at shut down.
sIdleService = idleService.forget().take();
}

View File

@@ -39,7 +39,7 @@
#define VK_OEM_102 0xE2
#define VK_OEM_CLEAR 0xFE
class nsIIdleServiceInternal;
class nsIUserIdleServiceInternal;
namespace mozilla {
namespace widget {
@@ -955,7 +955,7 @@ class KeyboardLayout {
~KeyboardLayout();
static KeyboardLayout* sInstance;
static nsIIdleServiceInternal* sIdleService;
static nsIUserIdleServiceInternal* sIdleService;
struct DeadKeyTableListEntry {
DeadKeyTableListEntry* next;

View File

@@ -30,11 +30,11 @@ Classes = [
},
{
'cid': '{6987230e-0098-4e78-bc5f-1493ee7519fa}',
'contract_ids': ['@mozilla.org/widget/idleservice;1'],
'contract_ids': ['@mozilla.org/widget/useridleservice;1'],
'singleton': True,
'type': 'nsIdleServiceWin',
'constructor': 'nsIdleServiceWin::GetInstance',
'headers': ['/widget/windows/nsIdleServiceWin.h', 'nsIdleService.h'],
'type': 'nsUserIdleServiceWin',
'constructor': 'nsUserIdleServiceWin::GetInstance',
'headers': ['/widget/windows/nsUserIdleServiceWin.h', 'nsUserIdleService.h'],
},
{
'cid': '{b148eed2-236d-11d3-b35c-00a0cc3c1cde}',

View File

@@ -60,13 +60,13 @@ UNIFIED_SOURCES += [
'nsDataObj.cpp',
'nsDataObjCollection.cpp',
'nsDragService.cpp',
'nsIdleServiceWin.cpp',
'nsLookAndFeel.cpp',
'nsNativeDragSource.cpp',
'nsNativeDragTarget.cpp',
'nsNativeThemeWin.cpp',
'nsSound.cpp',
'nsToolkit.cpp',
'nsUserIdleServiceWin.cpp',
'nsUXThemeData.cpp',
'nsWindow.cpp',
'nsWindowBase.cpp',

View File

@@ -5,10 +5,10 @@
* 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/. */
#include "nsIdleServiceWin.h"
#include "nsUserIdleServiceWin.h"
#include <windows.h>
bool nsIdleServiceWin::PollIdleTime(uint32_t* aIdleTime) {
bool nsUserIdleServiceWin::PollIdleTime(uint32_t* aIdleTime) {
LASTINPUTINFO inputInfo;
inputInfo.cbSize = sizeof(inputInfo);
if (!::GetLastInputInfo(&inputInfo)) return false;
@@ -19,4 +19,4 @@ bool nsIdleServiceWin::PollIdleTime(uint32_t* aIdleTime) {
return true;
}
bool nsIdleServiceWin::UsePollMode() { return true; }
bool nsUserIdleServiceWin::UsePollMode() { return true; }

View File

@@ -5,10 +5,10 @@
* 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 nsIdleServiceWin_h__
#define nsIdleServiceWin_h__
#ifndef nsUserIdleServiceWin_h__
#define nsUserIdleServiceWin_h__
#include "nsIdleService.h"
#include "nsUserIdleService.h"
/* NOTE: Compare of GetTickCount() could overflow. This corrects for
* overflow situations.
@@ -18,26 +18,26 @@
(((int)((long)A - (long)B) & 0xFFFFFFFF))
#endif
class nsIdleServiceWin : public nsIdleService {
class nsUserIdleServiceWin : public nsUserIdleService {
public:
NS_INLINE_DECL_REFCOUNTING_INHERITED(nsIdleServiceWin, nsIdleService)
NS_INLINE_DECL_REFCOUNTING_INHERITED(nsUserIdleServiceWin, nsUserIdleService)
bool PollIdleTime(uint32_t* aIdleTime) override;
static already_AddRefed<nsIdleServiceWin> GetInstance() {
RefPtr<nsIdleServiceWin> idleService =
nsIdleService::GetInstance().downcast<nsIdleServiceWin>();
static already_AddRefed<nsUserIdleServiceWin> GetInstance() {
RefPtr<nsUserIdleServiceWin> idleService =
nsUserIdleService::GetInstance().downcast<nsUserIdleServiceWin>();
if (!idleService) {
idleService = new nsIdleServiceWin();
idleService = new nsUserIdleServiceWin();
}
return idleService.forget();
}
protected:
nsIdleServiceWin() {}
virtual ~nsIdleServiceWin() {}
nsUserIdleServiceWin() {}
virtual ~nsUserIdleServiceWin() {}
bool UsePollMode() override;
};
#endif // nsIdleServiceWin_h__
#endif // nsUserIdleServiceWin_h__

View File

@@ -6922,7 +6922,7 @@ void nsWindow::OnWindowPosChanging(LPWINDOWPOS& info) {
void nsWindow::UserActivity() {
// Check if we have the idle service, if not we try to get it.
if (!mIdleService) {
mIdleService = do_GetService("@mozilla.org/widget/idleservice;1");
mIdleService = do_GetService("@mozilla.org/widget/useridleservice;1");
}
// Check that we now have the idle service.

View File

@@ -15,7 +15,7 @@
#include "CompositorWidget.h"
#include "nsWindowBase.h"
#include "nsdefs.h"
#include "nsIdleService.h"
#include "nsUserIdleService.h"
#include "nsToolkit.h"
#include "nsString.h"
#include "nsTArray.h"
@@ -46,7 +46,7 @@
#endif
#include "nsUXThemeData.h"
#include "nsIIdleServiceInternal.h"
#include "nsIUserIdleServiceInternal.h"
#include "IMMHandler.h"
@@ -657,7 +657,7 @@ class nsWindow final : public nsWindowBase {
float mAspectRatio;
nsCOMPtr<nsIIdleServiceInternal> mIdleService;
nsCOMPtr<nsIUserIdleServiceInternal> mIdleService;
// Draggable titlebar region maintained by UpdateWindowDraggingRegion
LayoutDeviceIntRegion mDraggableRegion;

View File

@@ -16,7 +16,7 @@
# include "nsIObserverService.h"
# include "mozilla/ResultExtensions.h"
# include "mozilla/Services.h"
# include "nsIIdleService.h"
# include "nsIUserIdleService.h"
# include "nsISimpleEnumerator.h"
# include "nsIFile.h"
# include "nsITimer.h"
@@ -183,8 +183,8 @@ class nsAnonTempFileRemover final : public nsIObserver {
mTimer = nullptr;
}
// Remove idle service observer.
nsCOMPtr<nsIIdleService> idleSvc =
do_GetService("@mozilla.org/widget/idleservice;1");
nsCOMPtr<nsIUserIdleService> idleSvc =
do_GetService("@mozilla.org/widget/useridleservice;1");
if (idleSvc) {
idleSvc->RemoveIdleObserver(this, TEMP_FILE_IDLE_TIME_S);
}
@@ -216,8 +216,8 @@ class nsAnonTempFileRemover final : public nsIObserver {
// Add this as an idle observer. When we've been idle for
// TEMP_FILE_IDLE_TIME_S seconds, we'll get a notification, and we'll then
// try to delete any stray temp files.
nsCOMPtr<nsIIdleService> idleSvc =
do_GetService("@mozilla.org/widget/idleservice;1");
nsCOMPtr<nsIUserIdleService> idleSvc =
do_GetService("@mozilla.org/widget/useridleservice;1");
if (!idleSvc) {
return NS_ERROR_FAILURE;
}