Skip to content

Commit

Permalink
Monitor: Syncup with Metro plugin changes
Browse files Browse the repository at this point in the history
  • Loading branch information
HaseenaSainul authored and sborushevsky committed Mar 7, 2022
1 parent 951d221 commit bf735f5
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 21 deletions.
44 changes: 35 additions & 9 deletions Monitor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,59 @@
# See the License for the specific language governing permissions and
# limitations under the License.

project(Monitor)

cmake_minimum_required(VERSION 3.3)

find_package(WPEFramework)

set(PLUGIN_NAME Monitor)
set(MODULE_NAME ${NAMESPACE}${PLUGIN_NAME})
set(MODULE_NAME ${NAMESPACE}${PROJECT_NAME})

set(PLUGIN_MONITOR_AUTOSTART "true" CACHE STRING "Automatically start Monitor plugin")
# Plugins built from this repository that can be autmatically enabled or enabled manually when built externally
set(PLUGIN_MONITOR_OPENCDMI "${PLUGIN_OPENCDMI}" CACHE BOOL "Enable monitor for the OpenCDMI plugin")
set(PLUGIN_MONITOR_WEBKITBROWSER "${PLUGIN_WEBKITBROWSER}" CACHE BOOL "Enable monitor for the WebKitBrowser plugin")
set(PLUGIN_MONITOR_WEBKITBROWSER_APPS "${PLUGIN_WEBKITBROWSER_APPS}" CACHE BOOL "Enable monitor for the WebKitBrowser Apps plugin")
set(PLUGIN_MONITOR_WEBKITBROWSER_RESIDENT_APP "${PLUGIN_WEBKITBROWSER_RESIDENT_APP}" CACHE BOOL "Enable monitor for the WebKitBrowser Resident App plugin")
set(PLUGIN_MONITOR_WEBKITBROWSER_UX "${PLUGIN_WEBKITBROWSER_UX}" CACHE BOOL "Enable monitor for the WebKitBrowser UX plugin")
set(PLUGIN_MONITOR_WEBKITBROWSER_YOUTUBE "${PLUGIN_WEBKITBROWSER_YOUTUBE}" CACHE BOOL "Enable monitor for the WebKitBrowser Youtube plugin")
set(PLUGIN_MONITOR_OPENCDMI "${PLUGIN_OPENCDMI}" CACHE BOOL "Enable monitor for the OpenCDMI plugin")
set(PLUGIN_MONITOR_SYSTEMAUDIOPLAYER "${PLUGIN_SYSTEMAUDIOPLAYER}" CACHE BOOL "Enable monitor for the SystemAudioPlayer plugin")

# Plugins built from outside of this repository have to be enabled manually
set(PLUGIN_MONITOR_AMAZON OFF CACHE BOOL "Enable monitor for the Amazon plugin")
set(PLUGIN_MONITOR_COBALT OFF CACHE BOOL "Enable monitor for the Cobalt plugin")
set(PLUGIN_MONITOR_NETFLIX OFF CACHE BOOL "Enable monitor for the Netflix plugin")
set(PLUGIN_MONITOR_OUTOFPROCESS OFF CACHE BOOL "Enable monitor for the OutOfProcess plugin")
set(PLUGIN_MONITOR_TESTUTILITY OFF CACHE BOOL "Enable monitor for the TestUtility plugin")

# Options for each plugin
set(PLUGIN_MONITOR_WEBKITBROWSER_MEMORYLIMIT "614400" CACHE STRING "monitor webkit memory limit")
set(PLUGIN_MONITOR_YOUTUBE_MEMORYLIMIT "614400" CACHE STRING "monitor youtube memory limit")
set(PLUGIN_MONITOR_AMAZON_MEMORYLIMIT "614400" CACHE STRING "monitor amazon memory limit")
set(PLUGIN_MONITOR_COBALT_MEMORYLIMIT "614400" CACHE STRING "monitor cobalt memory limit")
set(PLUGIN_MONITOR_AMAZON_MEMORYLIMIT "614400" CACHE STRING "monitor amazon memory limit")
set(PLUGIN_MONITOR_APPS_MEMORYLIMIT "614400" CACHE STRING "monitor apps memory limit")
set(PLUGIN_MONITOR_UX_MEMORYLIMIT "614400" CACHE STRING "monitor ux memory limit")
set(PLUGIN_MONITOR_NETFLIX_MEMORYLIMIT "614400" CACHE STRING "monitor netflix memory limit")
set(PLUGIN_MONITOR_RESIDENT_APP_MEMORYLIMIT "614400" CACHE STRING "monitor resident app memory limit")
set(PLUGIN_MONITOR_WEBKITBROWSER_MEMORYLIMIT "614400" CACHE STRING "monitor webkit memory limit")
set(PLUGIN_MONITOR_WEBKITBROWSER_APPS_MEMORYLIMIT "614400" CACHE STRING "monitor apps memory limit")
set(PLUGIN_MONITOR_WEBKITBROWSER_RESIDENT_APP_MEMORYLIMIT "614400" CACHE STRING "monitor resident app memory limit")
set(PLUGIN_MONITOR_WEBKITBROWSER_UX_MEMORYLIMIT "614400" CACHE STRING "monitor ux memory limit")
set(PLUGIN_MONITOR_WEBKITBROWSER_YOUTUBE_MEMORYLIMIT "614400" CACHE STRING "monitor youtube memory limit")

# deprecated/legacy flags support
if(PLUGIN_MONITOR_APPS_MEMORYLIMIT)
set(PLUGIN_MONITOR_WEBKITBROWSER_APPS_MEMORYLIMIT ${PLUGIN_MONITOR_APPS_MEMORYLIMIT} CACHE STRING "monitor apps memory limit" FORCE)
unset(PLUGIN_MONITOR_APPS_MEMORYLIMIT CACHE)
endif()
if(PLUGIN_MONITOR_RESIDENT_APP_MEMORYLIMIT)
set(PLUGIN_MONITOR_WEBKITBROWSER_RESIDENT_APP_MEMORYLIMIT ${PLUGIN_MONITOR_RESIDENT_APP_MEMORYLIMIT} CACHE STRING "monitor resident app memory limit" FORCE)
unset(PLUGIN_MONITOR_RESIDENT_APP_MEMORYLIMIT CACHE)
endif()
if(PLUGIN_MONITOR_UX_MEMORYLIMIT)
set(PLUGIN_MONITOR_WEBKITBROWSER_UX_MEMORYLIMIT ${PLUGIN_MONITOR_UX_MEMORYLIMIT} CACHE STRING "monitor ux memory limit" FORCE)
unset(PLUGIN_MONITOR_UX_MEMORYLIMIT CACHE)
endif()
if(PLUGIN_MONITOR_YOUTUBE_MEMORYLIMIT)
set(PLUGIN_MONITOR_WEBKITBROWSER_YOUTUBE_MEMORYLIMIT ${PLUGIN_MONITOR_YOUTUBE_MEMORYLIMIT} CACHE STRING "monitor youtube memory limit" FORCE)
unset(PLUGIN_MONITOR_YOUTUBE_MEMORYLIMIT CACHE)
endif()

find_package(${NAMESPACE}Plugins REQUIRED)
find_package(CompileSettingsDebug CONFIG REQUIRED)
Expand All @@ -63,4 +89,4 @@ target_link_libraries(${MODULE_NAME}
install(TARGETS ${MODULE_NAME}
DESTINATION lib/${STORAGE_DIRECTORY}/plugins)

write_config(${PLUGIN_NAME})
write_config(${PROJECT_NAME})
29 changes: 23 additions & 6 deletions Monitor/Monitor.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
set (autostart true)
set(autostart ${PLUGIN_MONITOR_AUTOSTART})

map()
end()
Expand All @@ -25,7 +25,7 @@ if(PLUGIN_MONITOR_WEBKITBROWSER_YOUTUBE)
map()
kv(callsign YouTube)
kv(memory 5)
kv(memorylimit ${PLUGIN_MONITOR_COBALT_MEMORYLIMIT})
kv(memorylimit ${PLUGIN_MONITOR_WEBKITBROWSER_YOUTUBE_MEMORYLIMIT})
kv(operational 1)
key(restart)
map()
Expand All @@ -38,11 +38,28 @@ if(PLUGIN_MONITOR_WEBKITBROWSER_YOUTUBE)
map_append(${configuration} observables ${YOUTUBE_MONITOR_CONFIG})
endif()

if(PLUGIN_MONITOR_AMAZON)
map()
kv(callsign Amazon)
kv(memory 5)
kv(memorylimit ${PLUGIN_MONITOR_AMAZON_MEMORYLIMIT})
kv(operational 1)
key(restart)
map()
kv(window 60)
kv(limit 3)
end()
end()
ans(AMAZON_MONITOR_CONFIG)
map_append(${configuration} observables ___array___)
map_append(${configuration} observables ${AMAZON_MONITOR_CONFIG})
endif()

if(PLUGIN_MONITOR_COBALT)
map()
kv(callsign Cobalt)
kv(memory 5)
kv(memorylimit ${PLUGIN_MONITOR_YOUTUBE_MEMORYLIMIT})
kv(memorylimit ${PLUGIN_MONITOR_COBALT_MEMORYLIMIT})
kv(operational 1)
key(restart)
map()
Expand All @@ -59,7 +76,7 @@ if(PLUGIN_MONITOR_WEBKITBROWSER_APPS)
map()
kv(callsign Apps)
kv(memory 5)
kv(memorylimit ${PLUGIN_MONITOR_APPS_MEMORYLIMIT})
kv(memorylimit ${PLUGIN_MONITOR_WEBKITBROWSER_APPS_MEMORYLIMIT})
kv(operational 1)
key(restart)
map()
Expand All @@ -76,7 +93,7 @@ if(PLUGIN_MONITOR_WEBKITBROWSER_UX)
map()
kv(callsign UX)
kv(memory 5)
kv(memorylimit ${PLUGIN_MONITOR_UX_MEMORYLIMIT})
kv(memorylimit ${PLUGIN_MONITOR_WEBKITBROWSER_UX_MEMORYLIMIT})
kv(operational 1)
key(restart)
map()
Expand Down Expand Up @@ -174,7 +191,7 @@ if(PLUGIN_MONITOR_WEBKITBROWSER_RESIDENT_APP)
map()
kv(callsign ResidentApp)
kv(memory 5)
kv(memorylimit ${PLUGIN_MONITOR_RESIDENT_APP_MEMORYLIMIT})
kv(memorylimit ${PLUGIN_MONITOR_WEBKITBROWSER_RESIDENT_APP_MEMORYLIMIT})
kv(operational 1)
key(restart)
map()
Expand Down
23 changes: 17 additions & 6 deletions Monitor/Monitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ namespace Plugin {
Add(_T("limit"), &Limit);
}
RestartInfo(const RestartInfo& copy)
: Window(copy.Window)
: Core::JSON::Container()
, Window(copy.Window)
, Limit(copy.Limit)
{
Add(_T("window"), &Window);
Expand Down Expand Up @@ -84,6 +85,17 @@ namespace Plugin {
{
}

MetaData& operator= (const MetaData& rhs)
{
_resident = rhs._resident;
_allocated = rhs._allocated;
_shared = rhs._shared;
_process = rhs._process;
_operational = rhs._operational;

return (*this);
}

public:
void Measure(Exchange::IMemory* memInterface)
{
Expand Down Expand Up @@ -435,10 +447,6 @@ namespace Plugin {
};

class MonitorObjects : public PluginHost::IPlugin::INotification {
private:
MonitorObjects(const MonitorObjects&) = delete;
MonitorObjects& operator=(const MonitorObjects&) = delete;

public:
using Job = Core::ThreadPool::JobType<MonitorObjects>;

Expand Down Expand Up @@ -515,7 +523,7 @@ namespace Plugin {
}

public:
inline bool RegisterRestart(PluginHost::IShell::reason why)
inline bool RegisterRestart(PluginHost::IShell::reason why VARIABLE_IS_NOT_USED)
{
ASSERT(why == PluginHost::IShell::MEMORY_EXCEEDED || why == PluginHost::IShell::FAILURE);
ASSERT(HasRestartAllowed());
Expand Down Expand Up @@ -646,6 +654,9 @@ namespace Plugin {
};

public:
MonitorObjects(const MonitorObjects&) = delete;
MonitorObjects& operator=(const MonitorObjects&) = delete;

#ifdef __WINDOWS__
#pragma warning(disable : 4355)
#endif
Expand Down

0 comments on commit bf735f5

Please sign in to comment.