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

Side by Side Diff: src/plugin/PluginTabBase.cpp

Issue 29331767: Issue #1234 + Clean up - CPluginTab (dead code, nullptr defect fix, etc.) (Closed)
Patch Set: Created Dec. 2, 2015, 6:35 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/plugin/PluginTabBase.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 #include "PluginStdAfx.h" 18 #include "PluginStdAfx.h"
19 #include "AdblockPlusClient.h" 19 #include "AdblockPlusClient.h"
20 #include "PluginClientBase.h" 20 #include "PluginClientBase.h"
21 #include "PluginSettings.h" 21 #include "PluginSettings.h"
22 #include "AdblockPlusDomTraverser.h" 22 #include "AdblockPlusDomTraverser.h"
23 #include "PluginTabBase.h" 23 #include "PluginTabBase.h"
24 #include "IeVersion.h" 24 #include "IeVersion.h"
25 #include "../shared/Utils.h" 25 #include "../shared/Utils.h"
26 #include <Mshtmhst.h> 26 #include <Mshtmhst.h>
27 27
28 CPluginTabBase::CPluginTabBase(CPluginClass* plugin) 28 CPluginTabBase::CPluginTabBase()
29 : m_plugin(plugin) 29 : m_isActivated(false)
30 , m_isActivated(false)
31 , m_continueThreadRunning(true) 30 , m_continueThreadRunning(true)
32 { 31 {
33 m_filter = std::auto_ptr<CPluginFilter>(new CPluginFilter()); 32 m_filter.hideFiltersLoadedEvent = CreateEvent(NULL, true, false, NULL);
34 m_filter->hideFiltersLoadedEvent = CreateEvent(NULL, true, false, NULL);
35 33
36 CPluginClient* client = CPluginClient::GetInstance(); 34 CPluginClient* client = CPluginClient::GetInstance();
37 if (AdblockPlus::IE::InstalledMajorVersion() < 10) 35 if (AdblockPlus::IE::InstalledMajorVersion() < 10)
38 { 36 {
39 m_isActivated = true; 37 m_isActivated = true;
40 } 38 }
41 39
42 try 40 try
43 { 41 {
44 m_thread = std::thread(&CPluginTabBase::ThreadProc, this); 42 m_thread = std::thread(&CPluginTabBase::ThreadProc, this);
(...skipping 24 matching lines...) Expand all
69 67
70 68
71 void CPluginTabBase::OnUpdate() 69 void CPluginTabBase::OnUpdate()
72 { 70 {
73 m_isActivated = true; 71 m_isActivated = true;
74 } 72 }
75 73
76 namespace 74 namespace
77 { 75 {
78 // Entry Point 76 // Entry Point
79 void FilterLoader(CPluginTabBase* tabBase) 77 void FilterLoader(CPluginFilter* filter, const std::wstring& domain)
80 { 78 {
81 try 79 try
82 { 80 {
83 tabBase->m_filter->LoadHideFilters(CPluginClient::GetInstance()->GetElemen tHidingSelectors(tabBase->GetDocumentDomain())); 81 filter->LoadHideFilters(CPluginClient::GetInstance()->GetElementHidingSele ctors(domain));
84 SetEvent(tabBase->m_filter->hideFiltersLoadedEvent); 82 SetEvent(filter->hideFiltersLoadedEvent);
85 } 83 }
86 catch (...) 84 catch (...)
87 { 85 {
88 // As a thread-main function, we truncate any C++ exception. 86 // As a thread-main function, we truncate any C++ exception.
89 } 87 }
90 } 88 }
91 } 89 }
92 90
93 void CPluginTabBase::OnNavigate(const std::wstring& url) 91 void CPluginTabBase::OnNavigate(const std::wstring& url)
94 { 92 {
95 SetDocumentUrl(url); 93 SetDocumentUrl(url);
96 ClearFrameCache(GetDocumentDomain()); 94 ClearFrameCache(GetDocumentDomain());
97 std::wstring domainString = GetDocumentDomain(); 95 std::wstring domainString = GetDocumentDomain();
98 ResetEvent(m_filter->hideFiltersLoadedEvent); 96 ResetEvent(m_filter.hideFiltersLoadedEvent);
99 try 97 try
100 { 98 {
101 std::thread filterLoaderThread(&FilterLoader, this); 99 std::thread filterLoaderThread(&FilterLoader, &m_filter, GetDocumentDomain() );
102 filterLoaderThread.detach(); // TODO: but actually we should wait for the th read in the dtr. 100 filterLoaderThread.detach(); // TODO: but actually we should wait for the th read in the dtr.
103 } 101 }
104 catch (const std::system_error& ex) 102 catch (const std::system_error& ex)
105 { 103 {
106 DEBUG_SYSTEM_EXCEPTION(ex, PLUGIN_ERROR_THREAD, PLUGIN_ERROR_MAIN_THREAD_CRE ATE_PROCESS, 104 DEBUG_SYSTEM_EXCEPTION(ex, PLUGIN_ERROR_THREAD, PLUGIN_ERROR_MAIN_THREAD_CRE ATE_PROCESS,
107 "Class::Thread - Failed to start filter loader thread"); 105 "Class::Thread - Failed to start filter loader thread");
108 } 106 }
109 m_traverser->ClearCache(); 107 m_traverser->ClearCache();
110 } 108 }
111 109
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 LogQueue::LogPluginError(pluginError.GetErrorCode(), pluginError.GetEr rorId(), pluginError.GetErrorSubid(), pluginError.GetErrorDescription(), true, p luginError.GetProcessId(), pluginError.GetThreadId()); 432 LogQueue::LogPluginError(pluginError.GetErrorCode(), pluginError.GetEr rorId(), pluginError.GetErrorSubid(), pluginError.GetErrorDescription(), true, p luginError.GetProcessId(), pluginError.GetThreadId());
435 } 433 }
436 434
437 // Non-hanging sleep 435 // Non-hanging sleep
438 Sleep(50); 436 Sleep(50);
439 } 437 }
440 438
441 tabLoopIteration++; 439 tabLoopIteration++;
442 } 440 }
443 } 441 }
OLDNEW
« no previous file with comments | « src/plugin/PluginTabBase.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld