mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-13 13:25:37 +00:00
bug 539552 - make PluginModuleParent write out more data to .extra file. r=bsmedberg
--HG-- extra : transplant_source : %C1P%99%80%8E%2C%92%7B%8C%BF%40c%40%FD%18%1F%AE%0E%D8%D9
This commit is contained in:
parent
f69b89b495
commit
cca33bca9a
@ -39,6 +39,7 @@
|
|||||||
#include "mozilla/plugins/PluginModuleParent.h"
|
#include "mozilla/plugins/PluginModuleParent.h"
|
||||||
#include "mozilla/plugins/BrowserStreamParent.h"
|
#include "mozilla/plugins/BrowserStreamParent.h"
|
||||||
|
|
||||||
|
#include "nsCRT.h"
|
||||||
#include "nsNPAPIPlugin.h"
|
#include "nsNPAPIPlugin.h"
|
||||||
|
|
||||||
using mozilla::PluginLibrary;
|
using mozilla::PluginLibrary;
|
||||||
@ -70,6 +71,7 @@ PluginModuleParent::PluginModuleParent(const char* aFilePath)
|
|||||||
, mShutdown(false)
|
, mShutdown(false)
|
||||||
, mNPNIface(NULL)
|
, mNPNIface(NULL)
|
||||||
, mPlugin(NULL)
|
, mPlugin(NULL)
|
||||||
|
, mProcessStartTime(time(NULL))
|
||||||
{
|
{
|
||||||
NS_ASSERTION(mSubprocess, "Out of memory!");
|
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
|
void
|
||||||
PluginModuleParent::ActorDestroy(ActorDestroyReason why)
|
PluginModuleParent::ActorDestroy(ActorDestroyReason why)
|
||||||
{
|
{
|
||||||
switch (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;
|
mShutdown = true;
|
||||||
// Defer the PluginCrashed method so that we don't re-enter
|
// Defer the PluginCrashed method so that we don't re-enter
|
||||||
// and potentially modify the actor child list while enumerating it.
|
// and potentially modify the actor child list while enumerating it.
|
||||||
@ -108,7 +175,7 @@ PluginModuleParent::ActorDestroy(ActorDestroyReason why)
|
|||||||
NS_DispatchToMainThread(r);
|
NS_DispatchToMainThread(r);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case NormalShutdown:
|
case NormalShutdown:
|
||||||
mShutdown = true;
|
mShutdown = true;
|
||||||
break;
|
break;
|
||||||
|
@ -58,6 +58,7 @@
|
|||||||
#include "nsAutoPtr.h"
|
#include "nsAutoPtr.h"
|
||||||
#include "nsTHashtable.h"
|
#include "nsTHashtable.h"
|
||||||
#include "nsHashKeys.h"
|
#include "nsHashKeys.h"
|
||||||
|
#include "nsIFileStreams.h"
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace plugins {
|
namespace plugins {
|
||||||
@ -210,11 +211,16 @@ private:
|
|||||||
char* argv[], NPSavedData* saved,
|
char* argv[], NPSavedData* saved,
|
||||||
NPError* error);
|
NPError* error);
|
||||||
private:
|
private:
|
||||||
|
void WriteExtraDataForMinidump(nsIFile* dumpFile);
|
||||||
|
void WriteExtraDataEntry(nsIFileOutputStream* stream,
|
||||||
|
const char* key,
|
||||||
|
const char* value);
|
||||||
PluginProcessParent* mSubprocess;
|
PluginProcessParent* mSubprocess;
|
||||||
bool mShutdown;
|
bool mShutdown;
|
||||||
const NPNetscapeFuncs* mNPNIface;
|
const NPNetscapeFuncs* mNPNIface;
|
||||||
nsTHashtable<nsVoidPtrHashKey> mValidIdentifiers;
|
nsTHashtable<nsVoidPtrHashKey> mValidIdentifiers;
|
||||||
nsNPAPIPlugin* mPlugin;
|
nsNPAPIPlugin* mPlugin;
|
||||||
|
time_t mProcessStartTime;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace plugins
|
} // namespace plugins
|
||||||
|
@ -72,6 +72,8 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::string& GetPluginFilePath() { return mPluginFilePath; }
|
||||||
|
|
||||||
using mozilla::ipc::GeckoChildProcessHost::GetShutDownEvent;
|
using mozilla::ipc::GeckoChildProcessHost::GetShutDownEvent;
|
||||||
using mozilla::ipc::GeckoChildProcessHost::GetChannel;
|
using mozilla::ipc::GeckoChildProcessHost::GetChannel;
|
||||||
using mozilla::ipc::GeckoChildProcessHost::GetChildProcessHandle;
|
using mozilla::ipc::GeckoChildProcessHost::GetChildProcessHandle;
|
||||||
|
Loading…
Reference in New Issue
Block a user