Upload upstream chromium 108.0.5359.1
[platform/framework/web/chromium-efl.git] / chrome / notification_helper / com_server_module.h
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.
4
5 #ifndef CHROME_NOTIFICATION_HELPER_COM_SERVER_MODULE_H_
6 #define CHROME_NOTIFICATION_HELPER_COM_SERVER_MODULE_H_
7
8 #include "base/synchronization/waitable_event.h"
9 #include "base/win/windows_types.h"
10
11 namespace notification_helper {
12
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 {
16  public:
17   ComServerModule();
18
19   ComServerModule(const ComServerModule&) = delete;
20   ComServerModule& operator=(const ComServerModule&) = delete;
21
22   ~ComServerModule();
23
24   // Handles object registration and unregistration. Returns when all registered
25   // objects are released.
26   HRESULT Run();
27
28   // Registers the NotificationActivator COM object so other applications can
29   // connect to it. Returns the registration status.
30   HRESULT RegisterClassObjects();
31
32   // Unregisters the NotificationActivator COM object. Returns the
33   // unregistration status.
34   HRESULT UnregisterClassObjects();
35
36   // Returns the state of the event.
37   bool IsEventSignaled();
38
39  private:
40   // Waits for all instance objects are released from the module.
41   void WaitForZeroObjectCount();
42
43   // Sends out the signal that all objects are now released from the module.
44   void SignalObjectCountZero();
45
46   // Identifiers of registered class objects. Used for unregistration.
47   DWORD cookies_[1] = {0};
48
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_;
52 };
53
54 }  // namespace notification_helper
55
56 #endif  // CHROME_NOTIFICATION_HELPER_COM_SERVER_MODULE_H_