mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 07:42:04 +00:00
Bug 901022 - write to MOZ_TRACE_FILE when the visual event tracer is stopped; r=honzab
DONTBUILD because NPOTB
This commit is contained in:
parent
3c42cfdae2
commit
a671e699c6
@ -580,6 +580,33 @@ VisualEventTracerLog::GetJSONString(nsACString & _retval)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
VisualEventTracerLog::WriteToProfilingFile()
|
||||
{
|
||||
const char* filename = PR_GetEnv("MOZ_TRACE_FILE");
|
||||
if (!filename) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRFileDesc* fd = PR_Open(filename, PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE,
|
||||
0644);
|
||||
if (!fd) {
|
||||
return NS_ERROR_FILE_ACCESS_DENIED;
|
||||
}
|
||||
|
||||
nsCString json;
|
||||
GetJSONString(json);
|
||||
|
||||
int32_t bytesWritten = PR_Write(fd, json.get(), json.Length());
|
||||
PR_Close(fd);
|
||||
|
||||
if (bytesWritten < json.Length()) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(VisualEventTracer, nsIVisualEventTracer)
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -622,7 +649,16 @@ VisualEventTracer::Stop()
|
||||
|
||||
gCapture = false;
|
||||
|
||||
return NS_OK;
|
||||
nsresult rv = NS_OK;
|
||||
if (PR_GetEnv("MOZ_TRACE_FILE")) {
|
||||
nsCOMPtr<nsIVisualEventTracerLog> tracelog;
|
||||
rv = Snapshot(getter_AddRefs(tracelog));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = tracelog->WriteToProfilingFile();
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -10,10 +10,10 @@
|
||||
* To enable this code at build time, add --enable-visual-profiling to your
|
||||
* configure options.
|
||||
*
|
||||
* To enable this code at run time, export MOZ_PROFILING_FILE env var with
|
||||
* a path to the file to write the log to. This is all you need to produce
|
||||
* the log of all events instrumentation in the mozilla code.
|
||||
* Check MOZ_EVENT_TRACER_* macros bellow to add your own.
|
||||
* To enable this code at run time, export MOZ_TRACE_FILE env var with a
|
||||
* path to the file to write the log to. This is all you need to * produce
|
||||
* the log of all events instrumentation in the mozilla code. Check
|
||||
* MOZ_EVENT_TRACER_* macros below to add your own.
|
||||
*
|
||||
* To let the event tracer log only some events to save disk space, export
|
||||
* MOZ_PROFILING_EVENTS with comma separated list of event names you want
|
||||
|
@ -13,7 +13,7 @@ interface nsIVisualEventTracerLog;
|
||||
* instrumentation around the mozilla code base.
|
||||
*/
|
||||
|
||||
[scriptable, uuid(D51F7867-42F3-4029-8C4E-C00676253A8E)]
|
||||
[builtinclass, scriptable, uuid(713ee3ca-95e0-4085-8616-f6d64a9508ad)]
|
||||
interface nsIVisualEventTracer : nsISupports
|
||||
{
|
||||
/**
|
||||
@ -43,11 +43,17 @@ interface nsIVisualEventTracer : nsISupports
|
||||
nsIVisualEventTracerLog snapshot();
|
||||
};
|
||||
|
||||
[scriptable, uuid(52EC8962-F67C-4f49-A9D6-89B8EBDA2649)]
|
||||
[builtinclass, scriptable, uuid(8ec6e36d-6cba-400b-bcd6-454679f5f75a)]
|
||||
interface nsIVisualEventTracerLog : nsISupports
|
||||
{
|
||||
/**
|
||||
* JSON string of the log. Use JSON.parse to get it as an object.
|
||||
*/
|
||||
readonly attribute ACString JSONString;
|
||||
|
||||
/**
|
||||
* Write the JSON string returned by JSONString to the log defined by
|
||||
* the environment variable MOZ_PROFILING_FILE.
|
||||
*/
|
||||
void writeToProfilingFile();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user