bug 539552 - make PluginModuleParent write out more data to .extra file. r=bsmedberg
This commit is contained in:
@@ -39,6 +39,7 @@
|
||||
#include "mozilla/plugins/PluginModuleParent.h"
|
||||
#include "mozilla/plugins/BrowserStreamParent.h"
|
||||
|
||||
#include "nsCRT.h"
|
||||
#include "nsNPAPIPlugin.h"
|
||||
|
||||
using mozilla::PluginLibrary;
|
||||
@@ -70,6 +71,7 @@ PluginModuleParent::PluginModuleParent(const char* aFilePath)
|
||||
, mShutdown(false)
|
||||
, mNPNIface(NULL)
|
||||
, mPlugin(NULL)
|
||||
, mProcessStartTime(time(NULL))
|
||||
{
|
||||
NS_ASSERTION(mSubprocess, "Out of memory!");
|
||||
|
||||
@@ -93,11 +95,76 @@ PluginModuleParent::~PluginModuleParent()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PluginModuleParent::WriteExtraDataEntry(nsIFileOutputStream* stream,
|
||||
const char* key,
|
||||
const char* value)
|
||||
{
|
||||
PRUint32 written;
|
||||
stream->Write(key, strlen(key), &written);
|
||||
stream->Write("=", 1, &written);
|
||||
stream->Write(value, strlen(value), &written);
|
||||
stream->Write("\n", 1, &written);
|
||||
}
|
||||
|
||||
void
|
||||
PluginModuleParent::WriteExtraDataForMinidump(nsIFile* dumpFile)
|
||||
{
|
||||
// get a reference to the extra file, and add some more entries
|
||||
nsCOMPtr<nsIFile> extraFile;
|
||||
nsresult rv = dumpFile->Clone(getter_AddRefs(extraFile));
|
||||
if (NS_FAILED(rv))
|
||||
return;
|
||||
|
||||
nsAutoString leafName;
|
||||
rv = extraFile->GetLeafName(leafName);
|
||||
if (NS_FAILED(rv))
|
||||
return;
|
||||
|
||||
leafName.Replace(leafName.Length() - 3, 3,
|
||||
NS_LITERAL_STRING("extra"));
|
||||
rv = extraFile->SetLeafName(leafName);
|
||||
if (NS_FAILED(rv))
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsIFileOutputStream> stream =
|
||||
do_CreateInstance("@mozilla.org/network/file-output-stream;1");
|
||||
// PR_WRONLY | PR_APPEND
|
||||
rv = stream->Init(extraFile, 0x12, 0600, 0);
|
||||
if (NS_FAILED(rv))
|
||||
return;
|
||||
WriteExtraDataEntry(stream, "ProcessType", "plugin");
|
||||
char startTime[32];
|
||||
sprintf(startTime, "%lld", static_cast<PRInt64>(mProcessStartTime));
|
||||
WriteExtraDataEntry(stream, "StartupTime", startTime);
|
||||
|
||||
// Get the plugin filename, try to get just the file leafname
|
||||
const std::string& pluginFile = mSubprocess->GetPluginFilePath();
|
||||
size_t filePos = pluginFile.rfind(FILE_PATH_SEPARATOR);
|
||||
if (filePos == std::string::npos)
|
||||
filePos = 0;
|
||||
else
|
||||
filePos++;
|
||||
WriteExtraDataEntry(stream, "PluginFilename",
|
||||
pluginFile.substr(filePos).c_str());
|
||||
//TODO: add plugin name and version: bug 539841
|
||||
// (as PluginName, PluginVersion)
|
||||
stream->Close();
|
||||
}
|
||||
|
||||
void
|
||||
PluginModuleParent::ActorDestroy(ActorDestroyReason why)
|
||||
{
|
||||
switch (why) {
|
||||
case AbnormalShutdown:
|
||||
case AbnormalShutdown: {
|
||||
nsCOMPtr<nsIFile> dump;
|
||||
if (GetMinidump(getter_AddRefs(dump))) {
|
||||
WriteExtraDataForMinidump(dump);
|
||||
}
|
||||
else {
|
||||
NS_WARNING("[PluginModuleParent::ActorDestroy] abnormal shutdown without minidump!");
|
||||
}
|
||||
|
||||
mShutdown = true;
|
||||
// Defer the PluginCrashed method so that we don't re-enter
|
||||
// and potentially modify the actor child list while enumerating it.
|
||||
@@ -108,7 +175,7 @@ PluginModuleParent::ActorDestroy(ActorDestroyReason why)
|
||||
NS_DispatchToMainThread(r);
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
case NormalShutdown:
|
||||
mShutdown = true;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user