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: rebase only Created July 27, 2016, 9:11 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
« no previous file with comments | « src/plugin/PluginTabBase.h ('k') | test/plugin/ActiveQueueTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,40 +25,17 @@
#include <Mshtmhst.h>
CPluginTab::CPluginTab()
- : m_isActivated(false)
- , m_continueThreadRunning(true)
{
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(&CPluginTab::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));
}
-
CPluginTab::~CPluginTab()
{
delete m_traverser;
m_traverser = NULL;
- m_continueThreadRunning = false;
- if (m_thread.joinable()) {
- m_thread.join();
- }
-}
-
/**
* ABP only intercepts protocols "http:" and "https:".
* We can disable any domain used in those protocol with an appropriate whitelist filter.
@@ -71,15 +47,6 @@
return BeginsWith(url, L"http:") || BeginsWith(url, L"https:");
}
-void CPluginTab::OnActivate()
-{
- m_isActivated = true;
-}
-
-
-void CPluginTab::OnUpdate()
-{
- m_isActivated = true;
}
namespace
@@ -394,59 +361,3 @@
m_criticalSectionCache.Unlock();
}
-void CPluginTab::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++;
- }
-}
« no previous file with comments | « src/plugin/PluginTabBase.h ('k') | test/plugin/ActiveQueueTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld