toolkit/components/remote/nsRemoteService.h
author Dave Townsend <dtownsend@oxymoronical.com>
Thu, 31 Jan 2019 12:13:34 -0800
changeset 520640 03c9381974486d342d41f010a60eb436b546ec7a
parent 520639 b9d78d81a381350aa548ce7d6b640b93d57ebb7c
child 520641 30cd61daa60513ca4c31cd466ad6868fb7859317
permissions -rw-r--r--
Bug 1518639: Move command line handing to nsRemoteService. r=jimm Makes nsRemoteService handle the command line parsing, though this will end up being removed in a later patch. Differential Revision: https://phabricator.services.mozilla.com/D19071

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
 */
/* 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 __nsRemoteService_h__
#define __nsRemoteService_h__

#include "nsRemoteServer.h"
#include "nsIObserverService.h"
#include "nsIObserver.h"
#include "nsPIDOMWindow.h"
#include "mozilla/UniquePtr.h"
#include "nsIFile.h"
#include "nsProfileLock.h"

enum RemoteResult {
  REMOTE_NOT_FOUND = 0,
  REMOTE_FOUND = 1,
  REMOTE_ARG_BAD = 2
};

class nsRemoteService final : public nsIObserver {
 public:
  // We will be a static singleton, so don't use the ordinary methods.
  NS_DECL_ISUPPORTS
  NS_DECL_NSIOBSERVER

  explicit nsRemoteService(const char* aProgram);

  void LockStartup();
  void UnlockStartup();

  RemoteResult StartClient(const char* aDesktopStartupID);
  void StartupServer(const char* aProfile);
  void ShutdownServer();

 private:
  ~nsRemoteService();

  mozilla::UniquePtr<nsRemoteServer> mRemoteServer;
  nsProfileLock mRemoteLock;
  nsCOMPtr<nsIFile> mRemoteLockDir;
  nsCString mProgram;
};

#endif  // __nsRemoteService_h__