toolkit/xre/nsUpdateDriver.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     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__
    10 #include "nscore.h"
    11 #ifdef MOZ_UPDATER
    12 #include "nsIUpdateService.h"
    13 #include "nsIThread.h"
    14 #include "nsCOMPtr.h"
    15 #include "nsString.h"
    16 #include "mozilla/Attributes.h"
    17 #endif
    19 class nsIFile;
    21 #if defined(XP_WIN)
    22 #include <windows.h>
    23   typedef HANDLE     ProcessType;
    24 #elif defined(XP_MACOSX)
    25   typedef pid_t      ProcessType;
    26 #else
    27 #include "prproces.h"
    28   typedef PRProcess* ProcessType;
    29 #endif
    31 /**
    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.
    34  *
    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.
    38  * 
    39  * The argc and argv passed to this function should be what is needed to
    40  * relaunch the current process.
    41  *
    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.
    45  *
    46  * If you want the update to be processed without restarting, set the restart
    47  * parameter to false.
    48  *
    49  * This function does not modify appDir.
    50  */
    51 NS_HIDDEN_(nsresult) ProcessUpdates(nsIFile *greDir, nsIFile *appDir,
    52                                     nsIFile *updRootDir,
    53                                     int argc, char **argv,
    54                                     const char *appVersion,
    55                                     bool restart = true,
    56                                     bool isOSUpdate = false,
    57                                     nsIFile *osApplyToDir = nullptr,
    58                                     ProcessType *pid = nullptr);
    60 #ifdef MOZ_UPDATER
    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
    66 {
    67 public:
    68   nsUpdateProcessor();
    70   NS_DECL_THREADSAFE_ISUPPORTS
    71   NS_DECL_NSIUPDATEPROCESSOR
    73 private:
    74   struct StagedUpdateInfo {
    75     StagedUpdateInfo()
    76       : mArgc(0),
    77         mArgv(nullptr),
    78         mIsOSUpdate(false)
    79     {}
    80     ~StagedUpdateInfo() {
    81       for (int i = 0; i < mArgc; ++i) {
    82         delete[] mArgv[i];
    83       }
    84       delete[] mArgv;
    85     }
    87     nsCOMPtr<nsIFile> mGREDir;
    88     nsCOMPtr<nsIFile> mAppDir;
    89     nsCOMPtr<nsIFile> mUpdateRoot;
    90     nsCOMPtr<nsIFile> mOSApplyToDir;
    91     int mArgc;
    92     char **mArgv;
    93     nsAutoCString mAppVersion;
    94     bool mIsOSUpdate;
    95   };
    97 private:
    98   void StartStagedUpdate();
    99   void WaitForProcess();
   100   void UpdateDone();
   101   void ShutdownWatcherThread();
   103 private:
   104   ProcessType mUpdaterPID;
   105   nsCOMPtr<nsIThread> mProcessWatcher;
   106   nsCOMPtr<nsIUpdate> mUpdate;
   107   StagedUpdateInfo mInfo;
   108 };
   109 #endif
   111 #endif  // nsUpdateDriver_h__

mercurial