Skip to content

Commit

Permalink
[Plugins] Favor inline Register/Unregister (rdkcentral#1573)
Browse files Browse the repository at this point in the history
Co-authored-by: Pierre Wielders <[email protected]>
  • Loading branch information
sebaszm and pwielders authored Apr 21, 2024
1 parent b54b0b8 commit 259c1bb
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 9 deletions.
8 changes: 4 additions & 4 deletions Source/WPEFramework/PluginServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -1242,11 +1242,11 @@ namespace PluginHost {
{
_administrator.Unregister(sink);
}
void Register(IShell::ICOMLink::INotification* sink)
void Register(IShell::ICOMLink::INotification* sink) override
{
_administrator.Register(sink);
}
void Unregister(IShell::ICOMLink::INotification* sink)
void Unregister(const IShell::ICOMLink::INotification* sink) override
{
_administrator.Unregister(sink);
}
Expand Down Expand Up @@ -2116,7 +2116,7 @@ namespace PluginHost {
_adminLock.Unlock();
}
}
void Unregister(IShell::ICOMLink::INotification* sink)
void Unregister(const IShell::ICOMLink::INotification* sink)
{
ASSERT(sink != nullptr);

Expand Down Expand Up @@ -2817,7 +2817,7 @@ namespace PluginHost {
{
_processAdministrator.Register(sink);
}
void Unregister(IShell::ICOMLink::INotification* sink)
void Unregister(const IShell::ICOMLink::INotification* sink)
{
_processAdministrator.Unregister(sink);
}
Expand Down
33 changes: 28 additions & 5 deletions Source/plugins/IShell.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ namespace PluginHost {
virtual void Unregister(const RPC::IRemoteConnection::INotification* sink) = 0;

virtual void Register(INotification* sink) = 0;
virtual void Unregister(INotification* sink) = 0;
virtual void Unregister(const INotification* sink) = 0;

virtual RPC::IRemoteConnection* RemoteConnection(const uint32_t connectionId) = 0;
virtual void* Instantiate(const RPC::Object& object, const uint32_t waitTime, uint32_t& connectionId) = 0;
Expand Down Expand Up @@ -239,7 +239,7 @@ namespace PluginHost {
virtual Core::hresult Resumed(const bool value) = 0;

virtual string HashKey() const = 0;

virtual string ConfigLine() const = 0;
virtual Core::hresult ConfigLine(const string& config) = 0;
virtual Core::hresult Metadata(string& info /* @out */) const = 0;
Expand Down Expand Up @@ -273,9 +273,6 @@ namespace PluginHost {
virtual Core::hresult Hibernate(const uint32_t timeout) = 0;
virtual reason Reason() const = 0;

virtual void Register(IConnectionServer::INotification* sink) = 0;
virtual void Unregister(const IConnectionServer::INotification* sink) = 0;

// Method to access, in the main process space, the channel factory to submit JSON objects to be send.
// This method will return a error if it is NOT in the main process.
/* @stubgen:stub */
Expand Down Expand Up @@ -335,6 +332,32 @@ namespace PluginHost {
handler->Release();
}
}
inline void Register(IConnectionServer::INotification* sink)
{
ASSERT(sink != nullptr);

IConnectionServer* handler(QueryInterface<IConnectionServer>());

ASSERT(handler != nullptr);

if (handler != nullptr) {
handler->Register(sink);
handler->Release();
}
}
inline void Unregister(const IConnectionServer::INotification* sink)
{
ASSERT(sink != nullptr);

IConnectionServer* handler(QueryInterface<IConnectionServer>());

ASSERT(handler != nullptr);

if (handler != nullptr) {
handler->Unregister(sink);
handler->Release();
}
}
inline RPC::IRemoteConnection* RemoteConnection(const uint32_t connectionId)
{
RPC::IRemoteConnection* connection(nullptr);
Expand Down

0 comments on commit 259c1bb

Please sign in to comment.