Closed Bug 1574298 Opened 2 years ago Closed 2 years ago

Add special ProcessRuntime constructor for the maintenance service


(Core :: IPC: MSCOM, task, P1)




Tracking Status
firefox70 --- fixed


(Reporter: bytesized, Assigned: aklotz)


(Blocks 1 open bug)



(1 file)

We want to use ProcessRuntime to initialize COM in the maintenance service, but the existing constructor requires a GeckoProcessType.

Flags: needinfo?(aklotz)
Blocks: 1570396
No longer blocks: 1570396
Blocks: 1574308

This is a quick one.

Assignee: nobody → aklotz
Flags: needinfo?(aklotz)
OS: Unspecified → Windows
Priority: -- → P1

In order to use mscom::ProcessRuntime in the maintenance service, we need
ProcessRuntime to be able to distinguish between more than just whether or not
the current process is the parent process.

I've added a new ProcessCategory enum to track this information, and revised
the constructors so that we now have one that accepts a ProcessCategory.

The ProcessCategory constructor is private inside XUL, since the
GeckoProcessType variant should always be used in that case.

We also slightly change apartment initialization to depend on the underlying
ProcessCategory value.

Finally, I modify the one case where we instantiate a ProcessRuntime in the
launcher process to use the new constructor.

Pushed by
Convert mscom::ProcessRuntime to use ProcessCategory enum and matching constructor; r=Jamie

Some notes for using this in the maintenance service:

  • The ProcessRuntime should be instantiated as early as possible in the life of the process and should remain running until near the end. I'd suggest instantiating it via RAII in main;
  • Instantiate it using the new constructor with the ProcessCategory::Service value;
  • ProcessRuntime supports operator bool, so you can use that to check whether the init failed (extremely unlikely, but you might want to log it or something);
  • Remove any other CoInitialize or CoInitializeEx calls, as well as their corresponding CoUninitialize calls;
  • Remove any other CoInitializeSecurity calls;
  • You will need to add ipc/mscom/ProcessRuntime.cpp to the service's SOURCES;
  • ProcessRuntime does have a dependency on mozglue. We could make further changes to eliminate that, but I'm hoping that isn't necessary.
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla70
You need to log in before you can comment on or make changes to this bug.