Understanding the GRE
Doug Turner
Netscape Communications
<dougt@netscape.com>

What we are going to talk about.
Definition of the GRE.
GRE’s importance.
Deciding to use it.
How to use it.
Current Issues.

What is the GRE?
The Gecko Runtime Environment.
Plainly put, the GRE is the minimum set of “stuff’ required to embed the Gecko browsing engine.
Its goal is to allow multiple applications to share the same Gecko installation.

Who should use it?
Gecko application suites.
Anyone that wants to leverage Gecko’s functionality.
Small net utilities.
A simple “About Box” using Gecko.
Full blown XUL apps.

Gecko Application Overlap

What are the common pieces?
Type of Stuff that makes up the GRE
XPCOM, Necko, Embedding Support, Profile, preferences, i18n, accessibility, DOM, Layout, cookies, plugin support.
Type of Stuff that’s not.
XUL (directly), wallet, mail, typeaheadfind.

Adding functionality to a GRE
Application components directory.
Custom resources and chrome.

Private copies of the GRE
These copies can remove or add “stuff” depending on their requirements.
Applications may hide their copy of the GRE.
Effectively, that is what we have been doing.

Public GRE Versioning
A GRE version is atomic.
No functional updates are allowed.
Updates should create a new version of the GRE.

Application requirements
Your application requires NSPR and XPCOM Glue.
You don’t link against the GRE libraries.
Your application must decide what versions of the GRE to support.
Add custom components, chrome, etc. to your application’s directory.

XPCOM Glue and Simple GRE Startup
XPCOM Glue is a layer between an application or component and the XPCOM library.
Simple GRE Startup
Built in the XPCOM glue library.
Simple GRE Version matching support
What the Mozilla Client uses.

Show me some code.
void main(void)
{
GRE_Startup();
//…
    GRE_Shutdown();
}
That easy – well, almost.

How Mozilla works
At startup, Mozilla calls GRE_Startup() to
Find a GRE installation.
Load the XPCOM library.
At shutdown, Mozilla calls GRE_Shutdown() to clean up.

Where we look
Current Process Directory
USE_LOCAL_GRE=1 environment variable flag (CWD is implied.  Used for testing.)
GRE Configuration files
~/gre.config
File pointed at by MOZ_GRE_CONF
/etc/gre.conf
Windows registry location
HKEY_CURRENT_USER\Software\mozilla.org\GRE

GRE Config File Format
[1.3b]
GRE_PATH=/home/dougt/gre/1.3b/
[1.4a]
GRE_PATH=/home/dougt/gre/1.4a/
[1.4b]
GRE_PATH=/home/dougt/gre/1.4b/

Installer
Mozilla.org has a GRE installer.
It can be redistributed with your application.
Your installer can check for its existence and install the GRE if it doesn’t exists.
GRE Installations are reference counted.
GRE in Linux Distributions coming soon.

Current Issues
Hard to use Gecko
Knowledge of too many subsystems are required.
No boilerplate applications frameworks available.
Requirement of NSPR
Not enough frozen interface.
Support of res and chrome files in the GRE.
Nightly build support.
Library dependencies.

Conclusion
Application developer should begin to think in terms of the GRE
Work continues to be done to improve the GRE story
Q&A?
Follow up question:
XPCOM Newsgroup