embedding/components/appstartup/src/nsIAppStartupNotifier.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/embedding/components/appstartup/src/nsIAppStartupNotifier.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,59 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef nsIAppStartupNotifier_h___
    1.10 +#define nsIAppStartupNotifier_h___
    1.11 +
    1.12 +#include "nsIObserver.h"
    1.13 +
    1.14 +/*
    1.15 + Some components need to be run at the startup of mozilla or embedding - to 
    1.16 + start new services etc.
    1.17 +
    1.18 + This interface provides a generic way to start up arbitrary components 
    1.19 + without requiring them to hack into main1() (or into NS_InitEmbedding) as 
    1.20 + it's currently being done for services such as wallet, command line handlers 
    1.21 + etc.
    1.22 +
    1.23 + We will have a category called "app-startup" which components register 
    1.24 + themselves in using the CategoryManager.
    1.25 +
    1.26 + Components can also (optionally) add the word "service," as a prefix 
    1.27 + to the "value" they pass in during a call to AddCategoryEntry() as
    1.28 + shown below:
    1.29 +
    1.30 +    categoryManager->AddCategoryEntry(APPSTARTUP_CATEGORY, "testcomp",
    1.31 +                        "service," NS_WALLETSERVICE_CONTRACTID
    1.32 +                        true, true,
    1.33 +                        getter_Copies(previous));
    1.34 +
    1.35 + Presence of the "service" keyword indicates the components desire to 
    1.36 + be started as a service. When the "service" keyword is not present
    1.37 + we just do a do_CreateInstance.
    1.38 +
    1.39 + When mozilla starts (and when NS_InitEmbedding()) is invoked
    1.40 + we create an instance of the AppStartupNotifier component (which 
    1.41 + implements nsIObserver) and invoke its Observe() method. 
    1.42 +
    1.43 + Observe()  will enumerate the components registered into the
    1.44 + APPSTARTUP_CATEGORY and notify them that startup has begun
    1.45 + and release them.
    1.46 +*/
    1.47 +
    1.48 +#define NS_APPSTARTUPNOTIFIER_CONTRACTID "@mozilla.org/embedcomp/appstartup-notifier;1"
    1.49 +
    1.50 +#define APPSTARTUP_CATEGORY "app-startup"
    1.51 +#define APPSTARTUP_TOPIC    "app-startup"
    1.52 +
    1.53 +
    1.54 +/*
    1.55 + Please note that there's not a new interface in this file.
    1.56 + We're just leveraging nsIObserver instead of creating a
    1.57 + new one
    1.58 +
    1.59 + This file exists solely to provide the defines above
    1.60 +*/
    1.61 +
    1.62 +#endif /* nsIAppStartupNotifier_h___ */

mercurial