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

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

Issue 29334386: Issue #2230 - Refactor filter life cycle and use
Patch Set: rebase only Created May 17, 2016, 7:45 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-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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
(...skipping 28 matching lines...) Expand all
39 39
40 try 40 try
41 { 41 {
42 m_thread = std::thread(&CPluginTab::ThreadProc, this); 42 m_thread = std::thread(&CPluginTab::ThreadProc, this);
43 } 43 }
44 catch (const std::system_error& ex) 44 catch (const std::system_error& ex)
45 { 45 {
46 DEBUG_SYSTEM_EXCEPTION(ex, PLUGIN_ERROR_THREAD, PLUGIN_ERROR_TAB_THREAD_CREA TE_PROCESS, 46 DEBUG_SYSTEM_EXCEPTION(ex, PLUGIN_ERROR_THREAD, PLUGIN_ERROR_TAB_THREAD_CREA TE_PROCESS,
47 "Tab::Thread - Failed to create tab thread"); 47 "Tab::Thread - Failed to create tab thread");
48 } 48 }
49 m_traverser = new CPluginDomTraverser(static_cast<CPluginTab*>(this));
50 } 49 }
51 50
52 51
53 CPluginTab::~CPluginTab() 52 CPluginTab::~CPluginTab()
54 { 53 {
55 delete m_traverser;
56 m_traverser = NULL;
57 m_continueThreadRunning = false; 54 m_continueThreadRunning = false;
58 if (m_thread.joinable()) { 55 if (m_thread.joinable()) {
59 m_thread.join(); 56 m_thread.join();
60 } 57 }
61 } 58 }
62 59
63 /** 60 /**
64 * ABP only intercepts protocols "http:" and "https:". 61 * ABP only intercepts protocols "http:" and "https:".
65 * We can disable any domain used in those protocol with an appropriate whitelis t filter. 62 * We can disable any domain used in those protocol with an appropriate whitelis t filter.
66 * Thus, the possibility to disable on a particular site depends only on the pro tocol. 63 * Thus, the possibility to disable on a particular site depends only on the pro tocol.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 try 105 try
109 { 106 {
110 std::thread filterLoaderThread(&FilterLoader, &m_filter, GetDocumentDomain() ); 107 std::thread filterLoaderThread(&FilterLoader, &m_filter, GetDocumentDomain() );
111 filterLoaderThread.detach(); // TODO: but actually we should wait for the th read in the dtr. 108 filterLoaderThread.detach(); // TODO: but actually we should wait for the th read in the dtr.
112 } 109 }
113 catch (const std::system_error& ex) 110 catch (const std::system_error& ex)
114 { 111 {
115 DEBUG_SYSTEM_EXCEPTION(ex, PLUGIN_ERROR_THREAD, PLUGIN_ERROR_MAIN_THREAD_CRE ATE_PROCESS, 112 DEBUG_SYSTEM_EXCEPTION(ex, PLUGIN_ERROR_THREAD, PLUGIN_ERROR_MAIN_THREAD_CRE ATE_PROCESS,
116 "Class::Thread - Failed to start filter loader thread"); 113 "Class::Thread - Failed to start filter loader thread");
117 } 114 }
118 m_traverser->ClearCache();
119 } 115 }
120 116
121 namespace 117 namespace
122 { 118 {
123 /** 119 /**
124 * Determine if the HTML file is one of ours. 120 * Determine if the HTML file is one of ours.
125 * The criterion is that it appear in the "html/templates" folder within our i nstallation. 121 * The criterion is that it appear in the "html/templates" folder within our i nstallation.
126 * 122 *
127 * Warning: This function may fail if the argument is not a "file://" URL. 123 * Warning: This function may fail if the argument is not a "file://" URL.
128 * This is occasionally the case in circumstances yet to be characterized. 124 * This is occasionally the case in circumstances yet to be characterized.
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 || client->IsElemhideWhitelistedOnDomain(url, frameHierarchy); 254 || client->IsElemhideWhitelistedOnDomain(url, frameHierarchy);
259 } 255 }
260 } 256 }
261 257
262 void CPluginTab::OnDownloadComplete(IWebBrowser2* browser) 258 void CPluginTab::OnDownloadComplete(IWebBrowser2* browser)
263 { 259 {
264 CPluginClient* client = CPluginClient::GetInstance(); 260 CPluginClient* client = CPluginClient::GetInstance();
265 std::wstring url = GetDocumentUrl(); 261 std::wstring url = GetDocumentUrl();
266 if (!client->IsWhitelistedUrl(url) && !client->IsElemhideWhitelistedOnDomain(u rl)) 262 if (!client->IsWhitelistedUrl(url) && !client->IsElemhideWhitelistedOnDomain(u rl))
267 { 263 {
268 m_traverser->TraverseDocument(browser, GetDocumentDomain(), GetDocumentUrl() ); 264 CPluginDomTraverser traversal(&m_filter);
265 traversal.TraverseDocumentRoot(browser, GetDocumentDomain(), GetDocumentUrl( ));
269 } 266 }
270 InjectABP(browser); 267 InjectABP(browser);
271 } 268 }
272 269
273 void CPluginTab::OnDocumentComplete(IWebBrowser2* browser, const std::wstring& u rl, bool isDocumentBrowser) 270 void CPluginTab::OnDocumentComplete(IWebBrowser2* browser, const std::wstring& u rl, bool isDocumentBrowser)
274 { 271 {
275 std::wstring documentUrl = GetDocumentUrl(); 272 std::wstring documentUrl = GetDocumentUrl();
276 273
277 if (isDocumentBrowser) 274 if (isDocumentBrowser)
278 { 275 {
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 LogQueue::LogPluginError(pluginError.GetErrorCode(), pluginError.GetEr rorId(), pluginError.GetErrorSubid(), pluginError.GetErrorDescription(), true, p luginError.GetProcessId(), pluginError.GetThreadId()); 440 LogQueue::LogPluginError(pluginError.GetErrorCode(), pluginError.GetEr rorId(), pluginError.GetErrorSubid(), pluginError.GetErrorDescription(), true, p luginError.GetProcessId(), pluginError.GetThreadId());
444 } 441 }
445 442
446 // Non-hanging sleep 443 // Non-hanging sleep
447 Sleep(50); 444 Sleep(50);
448 } 445 }
449 446
450 tabLoopIteration++; 447 tabLoopIteration++;
451 } 448 }
452 } 449 }
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