author Rob Wu <rob@robwu.nl>
Sat, 24 Sep 2016 11:16:32 +0200
changeset 320058 a41f871e2d1b37754bbd1001c36c075511b49342
parent 240854 bf1d0c9242d9ac334c7f7521789840a7c711b418
permissions -rw-r--r--
Bug 1299411 - Decouple Port implementation from API r=aswan Decoupled the API from the implementation. From now on it is possible to create Port instances without generating an API. This allows us to internally use Ports to pass around messages with minimal overhead (in the form of unnecessary clones of messages). This will be used by native messaging. This commit has no behavioral change, it is mostly moving around some code and storing the internal message listener in a set. MozReview-Commit-ID: 4h0LNJvTH9R

/* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; -*- */
/* 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 nsAppShellSingleton_h__
#define nsAppShellSingleton_h__

 * This file is designed to be included into the file that provides the
 * nsIModule implementation for a particular widget toolkit.
 * The following functions are defined:
 *   nsAppShellInit
 *   nsAppShellShutdown
 *   nsAppShellConstructor
 * The nsAppShellInit function is designed to be used as a module constructor.
 * If you already have a module constructor, then call nsAppShellInit from your
 * module constructor.
 * The nsAppShellShutdown function is designed to be used as a module
 * destructor.  If you already have a module destructor, then call
 * nsAppShellShutdown from your module destructor.
 * The nsAppShellConstructor function is designed to be used as a factory
 * method for the nsAppShell class.

#include "nsXULAppAPI.h"

static nsIAppShell *sAppShell;

static nsresult
  NS_ASSERTION(!sAppShell, "already initialized");

  sAppShell = new nsAppShell();
  if (!sAppShell)

  nsresult rv;
  rv = static_cast<nsAppShell*>(sAppShell)->Init();
  if (NS_FAILED(rv)) {
    return rv;

  return NS_OK;

static void

static nsresult
nsAppShellConstructor(nsISupports *outer, const nsIID &iid, void **result)

  return sAppShell->QueryInterface(iid, result);

#endif  // nsAppShellSingleton_h__