Backed out changeset af2c13b9fdb7 (bug 1801244) per developer request.
[gecko.git] / toolkit / xre / nsUpdateSyncManager.h
blob4c24cde8d447f2f032bb0f11fef0ba8e968cf535
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
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/. */
7 #ifndef nsUpdateSyncManager_h__
8 #define nsUpdateSyncManager_h__
10 #include "mozilla/AlreadyAddRefed.h"
11 #include "nsIObserver.h"
12 #include "nsIUpdateService.h"
13 #include "MultiInstanceLock.h"
15 // The update sync manager is responsible for making sure that only one
16 // instance of the application is running at the time we want to start updating
17 // it. It does this by taking a multi-instance lock very early during the
18 // application's startup process. Then, when app update tasks are ready to run,
19 // the update service asks us whether anything else has also taken that lock,
20 // which, if true, would mean another instance of the application is currently
21 // running and performing update tasks should be avoided (the update service
22 // also runs a timeout and eventually goes ahead with the update in order to
23 // prevent an external program from effectively disabling updates).
24 class nsUpdateSyncManager final : public nsIUpdateSyncManager,
25 public nsIObserver {
26 public:
27 explicit nsUpdateSyncManager(nsIFile* anAppFile = nullptr);
29 NS_DECL_THREADSAFE_ISUPPORTS
30 NS_DECL_NSIUPDATESYNCMANAGER
31 NS_DECL_NSIOBSERVER
33 static already_AddRefed<nsUpdateSyncManager> GetSingleton();
35 private:
36 ~nsUpdateSyncManager();
38 nsUpdateSyncManager(nsUpdateSyncManager&) = delete;
39 nsUpdateSyncManager(nsUpdateSyncManager&&) = delete;
40 nsUpdateSyncManager& operator=(nsUpdateSyncManager&) = delete;
41 nsUpdateSyncManager& operator=(nsUpdateSyncManager&&) = delete;
43 nsresult OpenLock(nsIFile* anAppFile = nullptr);
44 void ReleaseLock();
46 mozilla::MultiInstLockHandle mLock = MULTI_INSTANCE_LOCK_HANDLE_ERROR;
49 #endif // nsUpdateSyncManager_h__