author Sriram Ramasubramanian <>
Wed, 05 Sep 2012 14:53:54 -0700
changeset 104344 d89a71a8f5aead66d115b573aab0c8a47129ff12
parent 104106 3d9424eb6eb473cfd14309fd635ff7d6e29322c2
child 108707 f7505a5f3770d78f482843b5d3ad76012f40bb0f
permissions -rw-r--r--
Bug 785246: Make custom button inherit ShapedButton. [r=mfinkle]

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* 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 */

#ifndef nsUpdateDriver_h__
#define nsUpdateDriver_h__

#include "nscore.h"
#include "nsIUpdateService.h"
#include "nsIThread.h"
#include "nsCOMPtr.h"
#include "nsString.h"
#include "mozilla/Attributes.h"

class nsIFile;

#if defined(XP_WIN)
#include <windows.h>
  typedef HANDLE     ProcessType;
#elif defined(XP_MACOSX)
  typedef pid_t      ProcessType;
#include "prproces.h"
  typedef PRProcess* ProcessType;

 * This function processes any available updates.  As part of that process, it
 * may exit the current process and relaunch it at a later time.
 * Two directories are passed to this function: greDir (where the actual
 * binary resides) and appDir (which contains application.ini for XULRunner
 * apps). If this is not a XULRunner app then appDir is identical to greDir.
 * The argc and argv passed to this function should be what is needed to
 * relaunch the current process.
 * The appVersion param passed to this function is the current application's
 * version and is used to determine if an update's version is older than the
 * current application version.
 * If you want the update to be processed without restarting, set the restart
 * parameter to false.
 * This function does not modify appDir.
NS_HIDDEN_(nsresult) ProcessUpdates(nsIFile *greDir, nsIFile *appDir,
                                    nsIFile *updRootDir,
                                    int argc, char **argv,
                                    const char *appVersion,
                                    bool restart = true,
                                    ProcessType *pid = nullptr);

// The implementation of the update processor handles the task of loading the
// updater application in the background for applying an update.
// XXX ehsan this is living in this file in order to make use of the existing
// stuff here, we might want to move it elsewhere in the future.
class nsUpdateProcessor MOZ_FINAL : public nsIUpdateProcessor


  struct BackgroundUpdateInfo {
      : mArgc(0),
    ~BackgroundUpdateInfo() {
      for (int i = 0; i < mArgc; ++i) {
        delete[] mArgv[i];
      delete[] mArgv;

    nsCOMPtr<nsIFile> mGREDir;
    nsCOMPtr<nsIFile> mAppDir;
    nsCOMPtr<nsIFile> mUpdateRoot;
    int mArgc;
    char **mArgv;
    nsAutoCString mAppVersion;

  void StartBackgroundUpdate();
  void WaitForProcess();
  void UpdateDone();
  void ShutdownWatcherThread();

  ProcessType mUpdaterPID;
  nsCOMPtr<nsIThread> mProcessWatcher;
  nsCOMPtr<nsIUpdate> mUpdate;
  BackgroundUpdateInfo mInfo;

#endif  // nsUpdateDriver_h__