Bug 1399787 - Part 8. Open PDFium protocol channel.
MozReview-Commit-ID: F9W9ykEtVmK
--- a/widget/windows/PDFiumProcessParent.cpp
+++ b/widget/windows/PDFiumProcessParent.cpp
@@ -21,23 +21,53 @@ PDFiumProcessParent::PDFiumProcessParent
: GeckoChildProcessHost(GeckoProcessType_PDFium)
{
MOZ_COUNT_CTOR(PDFiumProcessParent);
}
PDFiumProcessParent::~PDFiumProcessParent()
{
MOZ_COUNT_DTOR(PDFiumProcessParent);
+
+ if (mPDFiumParentActor) {
+ mPDFiumParentActor->Close();
+ }
}
bool
PDFiumProcessParent::Launch()
{
- return SyncLaunch();
+ mLaunchThread = NS_GetCurrentThread();
+
+ if (!SyncLaunch()) {
+ return false;
+ }
+
+ // Open the top level protocol for PDFium process.
+ MOZ_ASSERT(!mPDFiumParentActor);
+ mPDFiumParentActor = new PDFiumParent();
+ return mPDFiumParentActor->Init(GetChannel(),
+ base::GetProcId(GetChildProcessHandle()));
}
void
PDFiumProcessParent::Delete()
{
+ // PDFiumProcessParent::Launch is not called, protocol is not created.
+ // It is safe to destroy this object on any thread.
+ if (!mLaunchThread) {
+ delete this;
+ return;
+ }
+
+ if (mLaunchThread == NS_GetCurrentThread()) {
+ delete this;
+ return;
+ }
+
+ mLaunchThread->Dispatch(
+ NewNonOwningRunnableMethod("PDFiumProcessParent::Delete",
+ this,
+ &PDFiumProcessParent::Delete));
}
} // namespace widget
} // namespace mozilla
--- a/widget/windows/PDFiumProcessParent.h
+++ b/widget/windows/PDFiumProcessParent.h
@@ -6,16 +6,25 @@
#ifndef PDFIUMPROCESSPARENT_H
#define PDFIUMPROCESSPARENT_H
#include "chrome/common/child_process_host.h"
#include "mozilla/ipc/GeckoChildProcessHost.h"
class nsIRunnable;
+class nsDeviceContextSpecWin;
+
+#ifdef MOZ_ENABLE_SKIA_PDF
+namespace mozilla {
+namespace widget {
+class PDFiumParent;
+}
+}
+#endif
namespace mozilla {
namespace widget {
class PDFiumProcessParent final : public mozilla::ipc::GeckoChildProcessHost
{
public:
PDFiumProcessParent();
@@ -25,14 +34,17 @@ public:
void Delete();
bool CanShutdown() override { return true; }
private:
DISALLOW_COPY_AND_ASSIGN(PDFiumProcessParent);
+
+ RefPtr<PDFiumParent> mPDFiumParentActor;
+ nsCOMPtr<nsIThread> mLaunchThread;
};
} // namespace widget
} // namespace mozilla
#endif // ifndef PDFIUMPROCESSPARENT_H