1 // Copyright 2018 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_NOTIFICATION_HELPER_COM_SERVER_MODULE_H_
6 #define CHROME_NOTIFICATION_HELPER_COM_SERVER_MODULE_H_
8 #include "base/synchronization/waitable_event.h"
9 #include "base/win/windows_types.h"
11 namespace notification_helper {
13 // This class is used to host the NotificationActivator COM component and serve
14 // as the module for an out-of-proc COM server.
15 class ComServerModule {
19 ComServerModule(const ComServerModule&) = delete;
20 ComServerModule& operator=(const ComServerModule&) = delete;
24 // Handles object registration and unregistration. Returns when all registered
25 // objects are released.
28 // Registers the NotificationActivator COM object so other applications can
29 // connect to it. Returns the registration status.
30 HRESULT RegisterClassObjects();
32 // Unregisters the NotificationActivator COM object. Returns the
33 // unregistration status.
34 HRESULT UnregisterClassObjects();
36 // Returns the state of the event.
37 bool IsEventSignaled();
40 // Waits for all instance objects are released from the module.
41 void WaitForZeroObjectCount();
43 // Sends out the signal that all objects are now released from the module.
44 void SignalObjectCountZero();
46 // Identifiers of registered class objects. Used for unregistration.
47 DWORD cookies_[1] = {0};
49 // This event starts "unsignaled", and is signaled when the last instance
50 // object is released from the module.
51 base::WaitableEvent object_zero_count_;
54 } // namespace notification_helper
56 #endif // CHROME_NOTIFICATION_HELPER_COM_SERVER_MODULE_H_