| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | |
| 3 * Copyright (C) 2006-2015 Eyeo GmbH | |
| 4 * | |
| 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 | |
| 7 * published by the Free Software Foundation. | |
| 8 * | |
| 9 * Adblock Plus is distributed in the hope that it will be useful, | |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 12 * GNU General Public License for more details. | |
| 13 * | |
| 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/>. | |
| 16 */ | |
| 17 | |
| 18 #include "PluginClientBase.h" | |
| 19 | |
| 20 #include "PluginSettings.h" | |
| 21 #include "Config.h" | |
| 22 #include "PluginDebug.h" | |
| 23 | |
| 24 CComAutoCriticalSection LogQueue::s_criticalSectionQueue; | |
| 25 std::vector<CPluginError> LogQueue::s_pluginErrors; | |
| 26 | |
| 27 void LogQueue::LogPluginError(DWORD errorCode, int errorId, int errorSubid, cons
t std::string& description, bool isAsync, DWORD dwProcessId, DWORD dwThreadId) | |
| 28 { | |
| 29 // Prevent circular references | |
| 30 if (CPluginSettings::HasInstance() && isAsync) | |
| 31 { | |
| 32 DEBUG_ERROR_CODE_EX(errorCode, description, dwProcessId, dwThreadId); | |
| 33 | |
| 34 CString pluginError; | |
| 35 pluginError.Format(L"%2.2d%2.2d", errorId, errorSubid); | |
| 36 | |
| 37 CString pluginErrorCode; | |
| 38 pluginErrorCode.Format(L"%u", errorCode); | |
| 39 | |
| 40 CPluginSettings* settings = CPluginSettings::GetInstance(); | |
| 41 | |
| 42 settings->AddError(pluginError, pluginErrorCode); | |
| 43 } | |
| 44 | |
| 45 // Post error to client for later submittal | |
| 46 if (!isAsync) | |
| 47 { | |
| 48 LogQueue::PostPluginError(errorId, errorSubid, errorCode, description); | |
| 49 } | |
| 50 } | |
| 51 | |
| 52 | |
| 53 void LogQueue::PostPluginError(int errorId, int errorSubid, DWORD errorCode, con
st std::string& errorDescription) | |
| 54 { | |
| 55 s_criticalSectionQueue.Lock(); | |
| 56 { | |
| 57 CPluginError pluginError(errorId, errorSubid, errorCode, errorDescription); | |
| 58 | |
| 59 s_pluginErrors.push_back(pluginError); | |
| 60 } | |
| 61 s_criticalSectionQueue.Unlock(); | |
| 62 } | |
| 63 | |
| 64 | |
| 65 bool LogQueue::PopFirstPluginError(CPluginError& pluginError) | |
| 66 { | |
| 67 bool hasError = false; | |
| 68 | |
| 69 s_criticalSectionQueue.Lock(); | |
| 70 { | |
| 71 std::vector<CPluginError>::iterator it = s_pluginErrors.begin(); | |
| 72 if (it != s_pluginErrors.end()) | |
| 73 { | |
| 74 pluginError = *it; | |
| 75 | |
| 76 hasError = true; | |
| 77 | |
| 78 s_pluginErrors.erase(it); | |
| 79 } | |
| 80 } | |
| 81 s_criticalSectionQueue.Unlock(); | |
| 82 | |
| 83 return hasError; | |
| 84 } | |
| OLD | NEW |