Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/widget/nsAppShellSingleton.h
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; -*- */
2
/* This Source Code Form is subject to the terms of the Mozilla Public
3
 * License, v. 2.0. If a copy of the MPL was not distributed with this
4
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6
#ifndef nsAppShellSingleton_h__
7
#define nsAppShellSingleton_h__
8
9
/**
10
 * This file is designed to be included into the file that provides the
11
 * nsIModule implementation for a particular widget toolkit.
12
 *
13
 * The following functions are defined:
14
 *   nsAppShellInit
15
 *   nsAppShellShutdown
16
 *   nsAppShellConstructor
17
 *
18
 * The nsAppShellInit function is designed to be used as a module constructor.
19
 * If you already have a module constructor, then call nsAppShellInit from your
20
 * module constructor.
21
 *
22
 * The nsAppShellShutdown function is designed to be used as a module
23
 * destructor.  If you already have a module destructor, then call
24
 * nsAppShellShutdown from your module destructor.
25
 *
26
 * The nsAppShellConstructor function is designed to be used as a factory
27
 * method for the nsAppShell class.
28
 */
29
30
#include "nsXULAppAPI.h"
31
32
static nsIAppShell *sAppShell;
33
34
static nsresult
35
nsAppShellInit()
36
0
{
37
0
  NS_ASSERTION(!sAppShell, "already initialized");
38
0
39
0
  sAppShell = new nsAppShell();
40
0
  if (!sAppShell)
41
0
    return NS_ERROR_OUT_OF_MEMORY;
42
0
  NS_ADDREF(sAppShell);
43
0
44
0
  nsresult rv;
45
0
  rv = static_cast<nsAppShell*>(sAppShell)->Init();
46
0
  if (NS_FAILED(rv)) {
47
0
    NS_RELEASE(sAppShell);
48
0
    return rv;
49
0
  }
50
0
51
0
  return NS_OK;
52
0
}
53
54
static void
55
nsAppShellShutdown()
56
0
{
57
0
  NS_RELEASE(sAppShell);
58
0
}
59
60
static nsresult
61
nsAppShellConstructor(nsISupports *outer, const nsIID &iid, void **result)
62
0
{
63
0
  NS_ENSURE_TRUE(!outer, NS_ERROR_NO_AGGREGATION);
64
0
  NS_ENSURE_TRUE(sAppShell, NS_ERROR_NOT_INITIALIZED);
65
0
66
0
  return sAppShell->QueryInterface(iid, result);
67
0
}
68
69
#endif  // nsAppShellSingleton_h__