diff --git a/src/WallpaperEngine/WebBrowser/CWebBrowserContext.cpp b/src/WallpaperEngine/WebBrowser/CWebBrowserContext.cpp index 4553f8f..61df7be 100644 --- a/src/WallpaperEngine/WebBrowser/CWebBrowserContext.cpp +++ b/src/WallpaperEngine/WebBrowser/CWebBrowserContext.cpp @@ -6,42 +6,16 @@ using namespace WallpaperEngine::WebBrowser; -CWebBrowserContext::CWebBrowserContext (int argc, char** argv) : m_stopped (true), m_argc (argc), m_argv (argv) {} - -CWebBrowserContext::~CWebBrowserContext () { - this->stop (); -} - -void CWebBrowserContext::markAsUsed () { - if (this->m_stopped) { - this->delayedInitialization(); - } -} - -void CWebBrowserContext::stop () { - if (this->m_stopped) { - return; - } - - sLog.out ("Shutting down CEF"); - - this->m_stopped = true; - - CefShutdown (); -} - -void CWebBrowserContext::delayedInitialization () { - this->m_stopped = false; - +CWebBrowserContext::CWebBrowserContext (int argc, char** argv) : m_stopped (false) { // clone original argc/argv as they'll be modified by cef - char** argv2 = new char*[this->m_argc]; + char** argv2 = new char*[argc]; - for (int i = 0; i < this->m_argc; i++) { - argv2 [i] = new char [strlen (this->m_argv [i]) + 1]; - strcpy (argv2 [i], this->m_argv [i]); + for (int i = 0; i < argc; i++) { + argv2 [i] = new char [strlen (argv [i]) + 1]; + strcpy (argv2 [i], argv [i]); } - CefMainArgs args (this->m_argc, argv2); + CefMainArgs args (argc, argv2); int exit_code = CefExecuteProcess ( args, nullptr, nullptr); // Spawned processes will terminate here(see CefIninitilize below). Maybe implementing @@ -72,4 +46,28 @@ void CWebBrowserContext::delayedInitialization () { if (!result) { sLog.exception ("CefInitialize: failed"); } +} + +CWebBrowserContext::~CWebBrowserContext () { + this->stop (); +} + +void CWebBrowserContext::markAsUsed () { + this->m_inUse = true; +} + +bool CWebBrowserContext::isUsed () { + return this->m_inUse; +} + +void CWebBrowserContext::stop () { + if (this->m_stopped) { + return; + } + + sLog.out ("Shutting down CEF"); + + this->m_stopped = true; + + CefShutdown (); } \ No newline at end of file diff --git a/src/WallpaperEngine/WebBrowser/CWebBrowserContext.h b/src/WallpaperEngine/WebBrowser/CWebBrowserContext.h index 90b2410..d689ff1 100644 --- a/src/WallpaperEngine/WebBrowser/CWebBrowserContext.h +++ b/src/WallpaperEngine/WebBrowser/CWebBrowserContext.h @@ -7,16 +7,11 @@ namespace WallpaperEngine::WebBrowser { ~CWebBrowserContext(); void markAsUsed(); + bool isUsed(); void stop(); private: - /** - * Handles the actual initialization logic - */ - void delayedInitialization(); - - int m_argc; - char** m_argv; bool m_stopped; + bool m_inUse; }; } // namespace WallpaperEngine::WebBrowser