nsITimelineService.idl revision 677833bc953b6cb418c701facbdcf4aa18d6c44e
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
%{C++
%}
/**
* nsITimelineService is used to constuct a timeline of program
* execution. The timeline is output to a file, either stderr or the
* value of the environment variable NS_TIMELINE_LOG_FILE. On the
* Mac, the timeline is output to the file named "timeline.txt". The
* reason it's different on the Mac is that the Mac environment
* initialization code happens after timeline initialization code.
*
* If NS_TIMELINE_INIT_TIME is set in the environment, that will be
* used as the time of startup; otherwise the current time when mark()
* is first called will be used.
*
* mark() is used to put marks on the timeline.
*
* indent() and outdent() are used to format the timeline a bit to
* show nesting. This doesn't produce perfect results in the face of
* asychrony and multiple threads.
*
* enter() and leave() are convenience functions that add marks to the
* timeline and do indentation.
*
* startTimer() and stopTimer() control named stop watches. If
* startTimer() is called more than once, an equal number of
* stopTimer() calls are needed to actually stop the timer. This
* makes these timers slightly useful in a threaded environment.
*
* markTimer() puts a mark on the timeline containing the total for
* the named timer.
*
* Don't use nsITimelineService in C++ code; use the NS_TIMELINE
* macros instead. nsITimelineService exists so that JavaScript code
* can mark the timeline.
*/
interface nsITimelineService : nsISupports
{
/**
* mark()
* Print "<elapsed time>: <text>\n" in the timeline log file.
*/
/**
* causes subsequent marks to be indented for a more readable
* report.
*/
void indent();
/**
* Causes subsequent marks to be outdented.
*/
void outdent();
/**
* well as indentation.
*/
// Mark a timer, plus an additional comment
};
%{C++
#endif /* MOZ_TIMELINE */
%}
%{C++
/*
* These are equivalent to the corresponding nsITimelineService
* methods, and can be called before XPCOM is initialized.
*/
/*
* Use these macros for the above calls so we can easily compile them
* out.
*/
/*
* Helper class to time functions. Use only static strings.
*/
class nsFunctionTimer {
public:
const char *mTimer;
const char *mMarkStr;
{
}
{
if (mMark)
if (mMarkStr)
else
}
};
/*
* NS_TIMELINE_MARK_ macros for various data types. Each of these
* macros replaces "%s" in its "text" argument with a string
* representation of its last argument.
*
* Please feel free to add more NS_TIMELINE_MARK_ macros for
* various data types so that code using NS_TIMELINE is uncluttered.
* Don't forget the empty versions in the #else section below for
* non-timeline builds.
*/
{ \
if (uri) { \
} \
} else { \
} \
}
{ \
if (channel) { \
} \
}
{ \
}
#define NS_TIMELINE_TIME_FUNCTION(timer) nsFunctionTimer functionTimer(timer, PR_FALSE) /* no mark, only time */
#else /* !defined(MOZ_TIMELINE) */
#endif /* defined(MOZ_TIMELINE) */
%}