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

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

Issue 5994126579335168: Noissue - Remove a dead inheritance and some dead code (Closed)
Patch Set: Created Feb. 18, 2015, 7:06 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
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 "PluginClientBase.h"
19 19
20 // Internet / FTP 20 #include <memory>
21 #include <wininet.h> 21 #include <WinInet.h>
22 22 #include <shlwapi.h>
23 // IP adapter
24 #include <iphlpapi.h>
25 23
26 #include "PluginSettings.h" 24 #include "PluginSettings.h"
27 #include "PluginSystem.h" 25 #include "Config.h"
28 #include "PluginMutex.h" 26 #include "PluginDebug.h"
29 #include "PluginClass.h"
30 27
31 #include "PluginClientBase.h" 28 CComAutoCriticalSection LogQueue::s_criticalSectionQueue;
29 std::vector<CPluginError> LogQueue::s_pluginErrors;
32 30
33 // IP adapter
34 #pragma comment(lib, "IPHLPAPI.lib")
35
36 // IE functions
37 #pragma comment(lib, "iepmapi.lib")
38
39 // Internet / FTP
40 #pragma comment(lib, "wininet.lib")
41
42
43 CComAutoCriticalSection CPluginClientBase::s_criticalSectionLocal;
44
45 std::vector<CPluginError> CPluginClientBase::s_pluginErrors;
46
47 bool CPluginClientBase::s_isErrorLogging = false;
48
49
50 CPluginClientBase::CPluginClientBase()
51 {
52 }
53
54
55 CPluginClientBase::~CPluginClientBase()
56 {
57 }
58 31
59 void UnescapeUrl(std::wstring& url) 32 void UnescapeUrl(std::wstring& url)
60 { 33 {
61 try 34 try
62 { 35 {
63 DWORD result_length = INTERNET_MAX_URL_LENGTH; 36 DWORD result_length = INTERNET_MAX_URL_LENGTH;
64 std::unique_ptr<wchar_t[]> result(new wchar_t[result_length]); 37 std::unique_ptr<wchar_t[]> result(new wchar_t[result_length]);
65 HRESULT hr = UrlUnescapeW(const_cast<wchar_t*>(url.c_str()), result.get(), & result_length, 0); 38 HRESULT hr = UrlUnescapeW(const_cast<wchar_t*>(url.c_str()), result.get(), & result_length, 0);
66 if (hr == S_OK) 39 if (hr == S_OK)
67 { 40 {
68 url = std::wstring(result.get(), result_length); 41 url = std::wstring(result.get(), result_length);
69 } 42 }
70 /* 43 /*
71 * Do nothing. This masks error return values from UrlUnescape without loggi ng the error. 44 * Do nothing. This masks error return values from UrlUnescape without loggi ng the error.
72 */ 45 */
73 } 46 }
74 catch(std::bad_alloc e) 47 catch(std::bad_alloc e)
75 { 48 {
76 /* 49 /*
77 * When the code has a systematic way of handling bad_alloc, we'll rethrow ( probably). 50 * When the code has a systematic way of handling bad_alloc, we'll rethrow ( probably).
78 * Until then, we mask the exception and make no modification. 51 * Until then, we mask the exception and make no modification.
79 */ 52 */
80 } 53 }
81 catch(...) 54 catch(...)
82 { 55 {
83 // no modification if any other exception 56 // no modification if any other exception
84 } 57 }
85 } 58 }
86 59
87 void CPluginClientBase::LogPluginError(DWORD errorCode, int errorId, int errorSu bid, const CString& description, bool isAsync, DWORD dwProcessId, DWORD dwThread Id) 60 void LogQueue::LogPluginError(DWORD errorCode, int errorId, int errorSubid, cons t CString& description, bool isAsync, DWORD dwProcessId, DWORD dwThreadId)
88 { 61 {
89 // Prevent circular references 62 // Prevent circular references
90 if (CPluginSettings::HasInstance() && isAsync) 63 if (CPluginSettings::HasInstance() && isAsync)
91 { 64 {
92 DEBUG_ERROR_CODE_EX(errorCode, description, dwProcessId, dwThreadId); 65 DEBUG_ERROR_CODE_EX(errorCode, description, dwProcessId, dwThreadId);
93 66
94 CString pluginError; 67 CString pluginError;
95 pluginError.Format(L"%2.2d%2.2d", errorId, errorSubid); 68 pluginError.Format(L"%2.2d%2.2d", errorId, errorSubid);
96 69
97 CString pluginErrorCode; 70 CString pluginErrorCode;
98 pluginErrorCode.Format(L"%u", errorCode); 71 pluginErrorCode.Format(L"%u", errorCode);
99 72
100 CPluginSettings* settings = CPluginSettings::GetInstance(); 73 CPluginSettings* settings = CPluginSettings::GetInstance();
101 74
102 settings->AddError(pluginError, pluginErrorCode); 75 settings->AddError(pluginError, pluginErrorCode);
103 } 76 }
104 77
105 // Post error to client for later submittal 78 // Post error to client for later submittal
106 if (!isAsync) 79 if (!isAsync)
107 { 80 {
108 CPluginClientBase::PostPluginError(errorId, errorSubid, errorCode, descripti on); 81 LogQueue::PostPluginError(errorId, errorSubid, errorCode, description);
109 } 82 }
110 } 83 }
111 84
112 85
113 void CPluginClientBase::PostPluginError(int errorId, int errorSubid, DWORD error Code, const CString& errorDescription) 86 void LogQueue::PostPluginError(int errorId, int errorSubid, DWORD errorCode, con st CString& errorDescription)
114 { 87 {
115 s_criticalSectionLocal.Lock(); 88 s_criticalSectionQueue.Lock();
116 { 89 {
117 CPluginError pluginError(errorId, errorSubid, errorCode, errorDescription); 90 CPluginError pluginError(errorId, errorSubid, errorCode, errorDescription);
118 91
119 s_pluginErrors.push_back(pluginError); 92 s_pluginErrors.push_back(pluginError);
120 } 93 }
121 s_criticalSectionLocal.Unlock(); 94 s_criticalSectionQueue.Unlock();
122 } 95 }
123 96
124 97
125 bool CPluginClientBase::PopFirstPluginError(CPluginError& pluginError) 98 bool LogQueue::PopFirstPluginError(CPluginError& pluginError)
126 { 99 {
127 bool hasError = false; 100 bool hasError = false;
128 101
129 s_criticalSectionLocal.Lock(); 102 s_criticalSectionQueue.Lock();
130 { 103 {
131 std::vector<CPluginError>::iterator it = s_pluginErrors.begin(); 104 std::vector<CPluginError>::iterator it = s_pluginErrors.begin();
132 if (it != s_pluginErrors.end()) 105 if (it != s_pluginErrors.end())
133 { 106 {
134 pluginError = *it; 107 pluginError = *it;
135 108
136 hasError = true; 109 hasError = true;
137 110
138 s_pluginErrors.erase(it); 111 s_pluginErrors.erase(it);
139 } 112 }
140 } 113 }
141 s_criticalSectionLocal.Unlock(); 114 s_criticalSectionQueue.Unlock();
142 115
143 return hasError; 116 return hasError;
144 } 117 }
OLDNEW

Powered by Google App Engine
This is Rietveld