Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: src/plugin/PluginTabBase.cpp

Issue 29323611: Issue #1234, #2058 - Rewrite log facility, improving thread implementation
Patch Set: Created Aug. 19, 2015, 5:42 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/plugin/PluginTabBase.cpp
===================================================================
--- a/src/plugin/PluginTabBase.cpp
+++ b/src/plugin/PluginTabBase.cpp
@@ -17,7 +17,6 @@
#include "PluginStdAfx.h"
#include "AdblockPlusClient.h"
-#include "PluginClientBase.h"
#include "PluginSettings.h"
#include "AdblockPlusDomTraverser.h"
#include "PluginTabBase.h"
@@ -26,27 +25,11 @@
CPluginTabBase::CPluginTabBase(CPluginClass* plugin)
: m_plugin(plugin)
- , m_isActivated(false)
- , m_continueThreadRunning(true)
{
m_filter = std::auto_ptr<CPluginFilter>(new CPluginFilter());
m_filter->hideFiltersLoadedEvent = CreateEvent(NULL, true, false, NULL);
CPluginClient* client = CPluginClient::GetInstance();
- if (AdblockPlus::IE::InstalledMajorVersion() < 10)
- {
- m_isActivated = true;
- }
-
- try
- {
- m_thread = std::thread(&CPluginTabBase::ThreadProc, this);
- }
- catch (const std::system_error& ex)
- {
- DEBUG_SYSTEM_EXCEPTION(ex, PLUGIN_ERROR_THREAD, PLUGIN_ERROR_TAB_THREAD_CREATE_PROCESS,
- "Tab::Thread - Failed to create tab thread");
- }
m_traverser = new CPluginDomTraverser(static_cast<CPluginTab*>(this));
}
@@ -55,21 +38,6 @@
{
delete m_traverser;
m_traverser = NULL;
- m_continueThreadRunning = false;
- if (m_thread.joinable()) {
- m_thread.join();
- }
-}
-
-void CPluginTabBase::OnActivate()
-{
- m_isActivated = true;
-}
-
-
-void CPluginTabBase::OnUpdate()
-{
- m_isActivated = true;
}
namespace
@@ -307,59 +275,3 @@
m_criticalSectionCache.Unlock();
}
-void CPluginTabBase::ThreadProc()
-{
- // Force loading/creation of settings
- CPluginSettings::GetInstance();
-
- std::string message =
- "================================================================================\n"
- "TAB THREAD process=";
- message += std::to_string(::GetCurrentProcessId());
- message + " thread=";
- message += std::to_string(::GetCurrentThreadId());
- message +=
- "\n"
- "================================================================================";
- DEBUG_GENERAL(message);
-
- // --------------------------------------------------------------------
- // Tab loop
- // --------------------------------------------------------------------
-
- DWORD loopCount = 0;
- DWORD tabLoopIteration = 1;
-
- while (this->m_continueThreadRunning)
- {
-#ifdef ENABLE_DEBUG_THREAD
- CStringA sTabLoopIteration;
- sTabLoopIteration.Format("%u", tabLoopIteration);
-
- DEBUG_THREAD("--------------------------------------------------------------------------------")
- DEBUG_THREAD("Loop iteration " + sTabLoopIteration);
- DEBUG_THREAD("--------------------------------------------------------------------------------")
-#endif
- this->m_isActivated = false;
-
- // --------------------------------------------------------------------
- // End loop
- // --------------------------------------------------------------------
-
- // Sleep loop
- while (this->m_continueThreadRunning && !this->m_isActivated && (++loopCount % (TIMER_THREAD_SLEEP_TAB_LOOP / 50)) != 0)
- {
- // Post async plugin error
- CPluginError pluginError;
- if (LogQueue::PopFirstPluginError(pluginError))
- {
- LogQueue::LogPluginError(pluginError.GetErrorCode(), pluginError.GetErrorId(), pluginError.GetErrorSubid(), pluginError.GetErrorDescription(), true, pluginError.GetProcessId(), pluginError.GetThreadId());
- }
-
- // Non-hanging sleep
- Sleep(50);
- }
-
- tabLoopIteration++;
- }
-}

Powered by Google App Engine
This is Rietveld