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 nsUpdateDriver_h__
8 #define nsUpdateDriver_h__
12 #include "nsIUpdateService.h"
13 #include "nsIThread.h"
16 #include "mozilla/Attributes.h"
23 typedef HANDLE ProcessType
;
24 #elif defined(XP_MACOSX)
25 typedef pid_t ProcessType
;
28 typedef PRProcess
* ProcessType
;
32 * This function processes any available updates. As part of that process, it
33 * may exit the current process and relaunch it at a later time.
35 * Two directories are passed to this function: greDir (where the actual
36 * binary resides) and appDir (which contains application.ini for XULRunner
37 * apps). If this is not a XULRunner app then appDir is identical to greDir.
39 * The argc and argv passed to this function should be what is needed to
40 * relaunch the current process.
42 * The appVersion param passed to this function is the current application's
43 * version and is used to determine if an update's version is older than the
44 * current application version.
46 * If you want the update to be processed without restarting, set the restart
49 * This function does not modify appDir.
51 nsresult
ProcessUpdates(nsIFile
*greDir
, nsIFile
*appDir
,
53 int argc
, char **argv
,
54 const char *appVersion
,
56 bool isOSUpdate
= false,
57 nsIFile
*osApplyToDir
= nullptr,
58 ProcessType
*pid
= nullptr);
61 // The implementation of the update processor handles the task of loading the
62 // updater application for staging an update.
63 // XXX ehsan this is living in this file in order to make use of the existing
64 // stuff here, we might want to move it elsewhere in the future.
65 class nsUpdateProcessor MOZ_FINAL
: public nsIUpdateProcessor
70 NS_DECL_THREADSAFE_ISUPPORTS
71 NS_DECL_NSIUPDATEPROCESSOR
76 struct StagedUpdateInfo
{
83 for (int i
= 0; i
< mArgc
; ++i
) {
89 nsCOMPtr
<nsIFile
> mGREDir
;
90 nsCOMPtr
<nsIFile
> mAppDir
;
91 nsCOMPtr
<nsIFile
> mUpdateRoot
;
92 nsCOMPtr
<nsIFile
> mOSApplyToDir
;
95 nsAutoCString mAppVersion
;
100 void StartStagedUpdate();
101 void WaitForProcess();
103 void ShutdownWatcherThread();
106 ProcessType mUpdaterPID
;
107 nsCOMPtr
<nsIThread
> mProcessWatcher
;
108 nsCOMPtr
<nsIUpdate
> mUpdate
;
109 StagedUpdateInfo mInfo
;
113 #endif // nsUpdateDriver_h__