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: rebase Created March 3, 2015, 8:03 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 29 matching lines...) Expand all
40 { 40 {
41 m_isActivated = true; 41 m_isActivated = true;
42 } 42 }
43 43
44 try 44 try
45 { 45 {
46 m_thread = std::thread(&CPluginTabBase::ThreadProc, this); 46 m_thread = std::thread(&CPluginTabBase::ThreadProc, this);
47 } 47 }
48 catch (const std::system_error& ex) 48 catch (const std::system_error& ex)
49 { 49 {
50 auto errDescription = std::string("Tab::Thread - Failed to create tab thread ") + 50 DEBUG_SYSTEM_EXCEPTION(ex, PLUGIN_ERROR_THREAD, PLUGIN_ERROR_TAB_THREAD_CREA TE_PROCESS,
51 ex.code().message() + ex.what(); 51 "Tab::Thread - Failed to create tab thread");
52 DEBUG_ERROR_LOG(ex.code().value(), PLUGIN_ERROR_THREAD, PLUGIN_ERROR_TAB_THR EAD_CREATE_PROCESS, errDescription.c_str());
53 } 52 }
54 m_traverser = new CPluginDomTraverser(static_cast<CPluginTab*>(this)); 53 m_traverser = new CPluginDomTraverser(static_cast<CPluginTab*>(this));
55 } 54 }
56 55
57 56
58 CPluginTabBase::~CPluginTabBase() 57 CPluginTabBase::~CPluginTabBase()
59 { 58 {
60 delete m_traverser; 59 delete m_traverser;
61 m_traverser = NULL; 60 m_traverser = NULL;
62 m_continueThreadRunning = false; 61 m_continueThreadRunning = false;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 ClearFrameCache(GetDocumentDomain()); 98 ClearFrameCache(GetDocumentDomain());
100 std::wstring domainString = GetDocumentDomain(); 99 std::wstring domainString = GetDocumentDomain();
101 ResetEvent(m_filter->hideFiltersLoadedEvent); 100 ResetEvent(m_filter->hideFiltersLoadedEvent);
102 try 101 try
103 { 102 {
104 std::thread filterLoaderThread(&FilterLoader, this); 103 std::thread filterLoaderThread(&FilterLoader, this);
105 filterLoaderThread.detach(); // TODO: but actually we should wait for the th read in the dtr. 104 filterLoaderThread.detach(); // TODO: but actually we should wait for the th read in the dtr.
106 } 105 }
107 catch (const std::system_error& ex) 106 catch (const std::system_error& ex)
108 { 107 {
109 auto errDescription = std::string("Class::Thread - Failed to start filter lo ader thread, ") + 108 DEBUG_SYSTEM_EXCEPTION(ex, PLUGIN_ERROR_THREAD, PLUGIN_ERROR_MAIN_THREAD_CRE ATE_PROCESS,
110 ex.code().message() + ex.what(); 109 "Class::Thread - Failed to start filter loader thread");
111 DEBUG_ERROR_LOG(ex.code().value(), PLUGIN_ERROR_THREAD, PLUGIN_ERROR_MAIN_TH READ_CREATE_PROCESS, errDescription.c_str());
112 } 110 }
113 m_traverser->ClearCache(); 111 m_traverser->ClearCache();
114 } 112 }
115 113
116 void CPluginTabBase::InjectABP(IWebBrowser2* browser) 114 void CPluginTabBase::InjectABP(IWebBrowser2* browser)
117 { 115 {
118 CriticalSection::Lock lock(m_csInject); 116 CriticalSection::Lock lock(m_csInject);
119 CString url = ToCString(GetDocumentUrl()); 117 auto url = GetDocumentUrl();
120 CString log; 118
121 log.Format(L"InjectABP. Current URL: %s, settings URL: %s", url, UserSettingsF ileUrl().c_str()); 119 std::wstring log = L"InjectABP. Current URL: ";
120 log += url;
121 log += L", settings URL: ";
122 log += UserSettingsFileUrl();
122 DEBUG_GENERAL(log); 123 DEBUG_GENERAL(log);
123 if (!(0 == url.CompareNoCase(CString(UserSettingsFileUrl().c_str())) || 124
124 0 == url.CompareNoCase(CString(FirstRunPageFileUrl().c_str())))) 125 CString urlLegacy = ToCString(url);
126 if (!(0 == urlLegacy.CompareNoCase(CString(UserSettingsFileUrl().c_str())) ||
127 0 == urlLegacy.CompareNoCase(CString(FirstRunPageFileUrl().c_str()))))
125 { 128 {
126 DEBUG_GENERAL(L"Not injecting"); 129 DEBUG_GENERAL(L"Not injecting");
127 return; 130 return;
128 } 131 }
129 DEBUG_GENERAL(L"Going to inject"); 132 DEBUG_GENERAL(L"Going to inject");
130 CComPtr<IDispatch> pDocDispatch; 133 CComPtr<IDispatch> pDocDispatch;
131 browser->get_Document(&pDocDispatch); 134 browser->get_Document(&pDocDispatch);
132 CComQIPtr<IHTMLDocument2> pDoc2 = pDocDispatch; 135 CComQIPtr<IHTMLDocument2> pDoc2 = pDocDispatch;
133 if (!pDoc2) 136 if (!pDoc2)
134 { 137 {
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 m_cacheFrames.clear(); 306 m_cacheFrames.clear();
304 m_cacheDomain = domain; 307 m_cacheDomain = domain;
305 } 308 }
306 } 309 }
307 m_criticalSectionCache.Unlock(); 310 m_criticalSectionCache.Unlock();
308 } 311 }
309 312
310 void CPluginTabBase::ThreadProc() 313 void CPluginTabBase::ThreadProc()
311 { 314 {
312 // Force loading/creation of settings 315 // Force loading/creation of settings
313 CPluginSettings* settings = CPluginSettings::GetInstance(); 316 CPluginSettings::GetInstance()->SetWorkingThreadId();
314 317
315 settings->SetWorkingThreadId(); 318 std::string message =
316 319 "=========================================================================== =====\n"
317 CString threadInfo; 320 "TAB THREAD process=";
318 threadInfo.Format(L"%d.%d", ::GetCurrentProcessId(), ::GetCurrentThreadId()); 321 message += std::to_string(::GetCurrentProcessId());
319 322 message + " thread=";
320 CString debugText; 323 message += std::to_string(::GetCurrentThreadId());
321 324 message +=
322 debugText += L"=============================================================== ================="; 325 "\n"
323 debugText += L"\nTAB THREAD " + threadInfo; 326 "=========================================================================== =====";
324 debugText += L"\n============================================================= ==================="; 327 DEBUG_GENERAL(message);
325
326 DEBUG_GENERAL(debugText)
327 328
328 // -------------------------------------------------------------------- 329 // --------------------------------------------------------------------
329 // Tab loop 330 // Tab loop
330 // -------------------------------------------------------------------- 331 // --------------------------------------------------------------------
331 332
332 DWORD loopCount = 0; 333 DWORD loopCount = 0;
333 DWORD tabLoopIteration = 1; 334 DWORD tabLoopIteration = 1;
334 335
335 while (this->m_continueThreadRunning) 336 while (this->m_continueThreadRunning)
336 { 337 {
(...skipping 21 matching lines...) Expand all
358 LogQueue::LogPluginError(pluginError.GetErrorCode(), pluginError.GetEr rorId(), pluginError.GetErrorSubid(), pluginError.GetErrorDescription(), true, p luginError.GetProcessId(), pluginError.GetThreadId()); 359 LogQueue::LogPluginError(pluginError.GetErrorCode(), pluginError.GetEr rorId(), pluginError.GetErrorSubid(), pluginError.GetErrorDescription(), true, p luginError.GetProcessId(), pluginError.GetThreadId());
359 } 360 }
360 361
361 // Non-hanging sleep 362 // Non-hanging sleep
362 Sleep(50); 363 Sleep(50);
363 } 364 }
364 365
365 tabLoopIteration++; 366 tabLoopIteration++;
366 } 367 }
367 } 368 }
OLDNEW

Powered by Google App Engine
This is Rietveld