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

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

Issue 5747779603267584: Issue #1234 - Rework strings in debug facility (Closed)
Patch Set: Fixed spaces Created Feb. 25, 2015, 3:24 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
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 { 45 {
46 m_isActivated = true; 46 m_isActivated = true;
47 } 47 }
48 48
49 try 49 try
50 { 50 {
51 m_thread = std::thread(&CPluginTabBase::ThreadProc, this); 51 m_thread = std::thread(&CPluginTabBase::ThreadProc, this);
52 } 52 }
53 catch (const std::system_error& ex) 53 catch (const std::system_error& ex)
54 { 54 {
55 auto errDescription = std::string("Tab::Thread - Failed to create tab thread ") + 55 DEBUG_SYSTEM_EXCEPTION(ex, PLUGIN_ERROR_THREAD, PLUGIN_ERROR_TAB_THREAD_CREA TE_PROCESS,
56 ex.code().message() + ex.what(); 56 "Tab::Thread - Failed to create tab thread");
57 DEBUG_ERROR_LOG(ex.code().value(), PLUGIN_ERROR_THREAD, PLUGIN_ERROR_TAB_THR EAD_CREATE_PROCESS, errDescription.c_str());
58 } 57 }
59 m_traverser = new CPluginDomTraverser(static_cast<CPluginTab*>(this)); 58 m_traverser = new CPluginDomTraverser(static_cast<CPluginTab*>(this));
60 } 59 }
61 60
62 61
63 CPluginTabBase::~CPluginTabBase() 62 CPluginTabBase::~CPluginTabBase()
64 { 63 {
65 delete m_traverser; 64 delete m_traverser;
66 m_traverser = NULL; 65 m_traverser = NULL;
67 m_continueThreadRunning = false; 66 m_continueThreadRunning = false;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 ClearFrameCache(GetDocumentDomain()); 103 ClearFrameCache(GetDocumentDomain());
105 std::wstring domainString = GetDocumentDomain(); 104 std::wstring domainString = GetDocumentDomain();
106 ResetEvent(m_filter->hideFiltersLoadedEvent); 105 ResetEvent(m_filter->hideFiltersLoadedEvent);
107 try 106 try
108 { 107 {
109 std::thread filterLoaderThread(&FilterLoader, this); 108 std::thread filterLoaderThread(&FilterLoader, this);
110 filterLoaderThread.detach(); // TODO: but actually we should wait for the th read in the dtr. 109 filterLoaderThread.detach(); // TODO: but actually we should wait for the th read in the dtr.
111 } 110 }
112 catch (const std::system_error& ex) 111 catch (const std::system_error& ex)
113 { 112 {
114 auto errDescription = std::string("Class::Thread - Failed to start filter lo ader thread, ") + 113 DEBUG_SYSTEM_EXCEPTION(ex, PLUGIN_ERROR_THREAD, PLUGIN_ERROR_MAIN_THREAD_CRE ATE_PROCESS,
115 ex.code().message() + ex.what(); 114 "Class::Thread - Failed to start filter loader thread");
116 DEBUG_ERROR_LOG(ex.code().value(), PLUGIN_ERROR_THREAD, PLUGIN_ERROR_MAIN_TH READ_CREATE_PROCESS, errDescription.c_str());
117 } 115 }
118 m_traverser->ClearCache(); 116 m_traverser->ClearCache();
119 } 117 }
120 118
121 void CPluginTabBase::InjectABP(IWebBrowser2* browser) 119 void CPluginTabBase::InjectABP(IWebBrowser2* browser)
122 { 120 {
123 CriticalSection::Lock lock(m_csInject); 121 CriticalSection::Lock lock(m_csInject);
124 CString url = ToCString(GetDocumentUrl()); 122 auto url = GetDocumentUrl();
125 CString log; 123
126 log.Format(L"InjectABP. Current URL: %s, settings URL: %s", url, UserSettingsF ileUrl().c_str()); 124 std::wstring log = L"InjectABP. Current URL: ";
125 log += url;
126 log += L", settings URL: ";
127 log += UserSettingsFileUrl();
127 DEBUG_GENERAL(log); 128 DEBUG_GENERAL(log);
128 if (!(0 == url.CompareNoCase(CString(UserSettingsFileUrl().c_str())) || 129
129 0 == url.CompareNoCase(CString(FirstRunPageFileUrl().c_str())))) 130 CString urlLegacy = ToCString(url);
131 if (!(0 == urlLegacy.CompareNoCase(CString(UserSettingsFileUrl().c_str())) ||
132 0 == urlLegacy.CompareNoCase(CString(FirstRunPageFileUrl().c_str()))))
Oleksandr 2015/02/27 07:50:15 I really don't think there are many other options
Eric 2015/02/27 14:26:56 I changed only the code relevant to the DEBUG_GENE
130 { 133 {
131 DEBUG_GENERAL(L"Not injecting"); 134 DEBUG_GENERAL(L"Not injecting");
132 return; 135 return;
133 } 136 }
134 DEBUG_GENERAL(L"Going to inject"); 137 DEBUG_GENERAL(L"Going to inject");
135 CComPtr<IDispatch> pDocDispatch; 138 CComPtr<IDispatch> pDocDispatch;
136 browser->get_Document(&pDocDispatch); 139 browser->get_Document(&pDocDispatch);
137 CComQIPtr<IHTMLDocument2> pDoc2 = pDocDispatch; 140 CComQIPtr<IHTMLDocument2> pDoc2 = pDocDispatch;
138 if (!pDoc2) 141 if (!pDoc2)
139 { 142 {
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 m_cacheFrames.clear(); 311 m_cacheFrames.clear();
309 m_cacheDomain = domain; 312 m_cacheDomain = domain;
310 } 313 }
311 } 314 }
312 m_criticalSectionCache.Unlock(); 315 m_criticalSectionCache.Unlock();
313 } 316 }
314 317
315 void CPluginTabBase::ThreadProc() 318 void CPluginTabBase::ThreadProc()
316 { 319 {
317 // Force loading/creation of settings 320 // Force loading/creation of settings
318 CPluginSettings* settings = CPluginSettings::GetInstance(); 321 CPluginSettings::GetInstance()->SetWorkingThreadId();
319 322
320 settings->SetWorkingThreadId(); 323 std::string message =
321 324 "=========================================================================== =====\n"
322 CString threadInfo; 325 "TAB THREAD process=";
323 threadInfo.Format(L"%d.%d", ::GetCurrentProcessId(), ::GetCurrentThreadId()); 326 message += std::to_string(::GetCurrentProcessId());
324 327 message + " thread=";
325 CString debugText; 328 message += std::to_string(::GetCurrentThreadId());
326 329 message +=
327 debugText += L"=============================================================== ================="; 330 "\n"
328 debugText += L"\nTAB THREAD " + threadInfo; 331 "=========================================================================== =====";
329 debugText += L"\n============================================================= ==================="; 332 DEBUG_GENERAL(message);
330
331 DEBUG_GENERAL(debugText)
332 333
333 // -------------------------------------------------------------------- 334 // --------------------------------------------------------------------
334 // Tab loop 335 // Tab loop
335 // -------------------------------------------------------------------- 336 // --------------------------------------------------------------------
336 337
337 DWORD loopCount = 0; 338 DWORD loopCount = 0;
338 DWORD tabLoopIteration = 1; 339 DWORD tabLoopIteration = 1;
339 340
340 while (this->m_continueThreadRunning) 341 while (this->m_continueThreadRunning)
341 { 342 {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 CPluginClient::LogPluginError(pluginError.GetErrorCode(), pluginError. GetErrorId(), pluginError.GetErrorSubid(), pluginError.GetErrorDescription(), tr ue, pluginError.GetProcessId(), pluginError.GetThreadId()); 374 CPluginClient::LogPluginError(pluginError.GetErrorCode(), pluginError. GetErrorId(), pluginError.GetErrorSubid(), pluginError.GetErrorDescription(), tr ue, pluginError.GetProcessId(), pluginError.GetThreadId());
374 } 375 }
375 376
376 // Non-hanging sleep 377 // Non-hanging sleep
377 Sleep(50); 378 Sleep(50);
378 } 379 }
379 380
380 tabLoopIteration++; 381 tabLoopIteration++;
381 } 382 }
382 } 383 }
OLDNEW

Powered by Google App Engine
This is Rietveld