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

Unified Diff: src/plugin/PluginClass.cpp

Issue 11013110: Cleanup (Closed)
Patch Set: More refactoring. Removing main thread, tab counting. Implementing SetPref and GetPref. Addressing … Created July 9, 2013, 12:59 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/plugin/PluginClass.cpp
===================================================================
--- a/src/plugin/PluginClass.cpp
+++ b/src/plugin/PluginClass.cpp
@@ -70,34 +70,18 @@
m_tab = new CPluginTab(this);
- // Load / create settings
+ // Load settings (fetch the available subscriptions, if still not fetched)
CPluginSettings* settings = CPluginSettings::GetInstance();
CPluginSystem* system = CPluginSystem::GetInstance();
std::wstring locale((LPCWSTR)system->GetBrowserLanguage());
Dictionary::Create(locale);
-
- bool isMainTab = settings->IncrementTabCount();
-
- if (isMainTab)
- {
- // Prepare settings
- settings->SetMainProcessId();
- settings->SetMainUiThreadId();
-#ifdef ENABLE_DEBUG_RESULT
- CPluginDebug::DebugResultClear();
-#endif
- }
}
CPluginClass::~CPluginClass()
{
delete m_tab;
-
- CPluginSettings* settings = CPluginSettings::GetInstance();
-
- settings->DecrementTabCount();
}
@@ -230,41 +214,6 @@
return url;
}
-void CPluginClass::LaunchUpdater(const CString& strPath)
-{
- PROCESS_INFORMATION pi;
- ::ZeroMemory(&pi, sizeof(pi));
-
- STARTUPINFO si;
- ::ZeroMemory(&si, sizeof(si));
- si.cb = sizeof(si);
- si.wShowWindow = FALSE;
- CString cpath;
- if (strPath.Find(L".exe") == strPath.GetLength() - 4)
- {
- cpath = strPath;
- }
- else
- {
- cpath = _T("\"msiexec.exe\" /i \"") + strPath + _T("\" UPDATEPLUGIN=\"True\"");
- }
-
- if (!::CreateProcess(NULL, cpath.GetBuffer(), NULL, NULL, FALSE, CREATE_BREAKAWAY_FROM_JOB, NULL, NULL, &si, &pi))
- {
- DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_UPDATER, PLUGIN_ERROR_UPDATER_CREATE_PROCESS, "Class::Updater - Failed to start process");
- return;
- }
-#ifndef AUTOMATIC_SHUTDOWN
- else
- {
- ::WaitForSingleObject(pi.hProcess, INFINITE);
- }
-#endif // not AUTOMATIC_SHUTDOWN
-
- ::CloseHandle(pi.hProcess);
- ::CloseHandle(pi.hThread);
-}
-
DWORD WINAPI CPluginClass::StartInitObject(LPVOID thisPtr)
{
if (thisPtr == NULL)
@@ -297,14 +246,7 @@
if (unknownSite)
{
- if (settings->IsMainProcess() && settings->IsMainUiThread())
- {
- DEBUG_GENERAL(L"================================================================================\nMAIN TAB UI\n================================================================================")
- }
- else
- {
- DEBUG_GENERAL(L"================================================================================\nNEW TAB UI\n================================================================================")
- }
+ DEBUG_GENERAL(L"================================================================================\nNEW TAB UI\n================================================================================")
HRESULT hr = ::CoInitialize(NULL);
if (FAILED(hr))
@@ -429,15 +371,6 @@
{
s_instances.Remove(this);
- if (s_instances.GetSize() == 0)
- {
- if (settings->IsMainProcess() && settings->IsMainUiThread())
- {
- hMainThread = s_hMainThread;
- s_hMainThread = NULL;
- }
- }
-
std::map<DWORD,CPluginClass*>::iterator it = s_threadInstances.find(::GetCurrentThreadId());
if (it != s_threadInstances.end())
{
@@ -450,14 +383,6 @@
}
s_criticalSectionLocal.Unlock();
- if (hMainThread != NULL)
- {
- s_isMainThreadDone = true;
-
- ::WaitForSingleObject(hMainThread, INFINITE);
- ::CloseHandle(hMainThread);
- }
-
// Release browser interface
s_criticalSectionBrowser.Lock();
{
@@ -465,14 +390,7 @@
}
s_criticalSectionBrowser.Unlock();
- if (settings->IsMainProcess() && settings->IsMainUiThread())
- {
- DEBUG_GENERAL("================================================================================\nMAIN TAB UI - END\n================================================================================")
- }
- else
- {
- DEBUG_GENERAL("================================================================================\nNEW TAB UI - END\n================================================================================")
- }
+ DEBUG_GENERAL("================================================================================\nNEW TAB UI - END\n================================================================================")
::CoUninitialize();
}
@@ -511,6 +429,9 @@
CPluginSettings* settings = CPluginSettings::GetInstance();
+ //TODO: Remove the message box
+ MessageBox(NULL, L"", L"", MB_OK);
Wladimir Palant 2013/07/11 12:53:10 Please address that TODO comment ;)
+
CComQIPtr<IWebBrowser2> browser = GetAsyncBrowser();
if (browser)
{
@@ -525,7 +446,7 @@
SHANDLE_PTR pBrowserHWnd;
browser->get_HWND((SHANDLE_PTR*)&pBrowserHWnd);
Dictionary* dictionary = Dictionary::GetInstance();
- settings->SetStatusBarAsked(true);
+ settings->SetStatusBarAsked();
HKEY pHkey;
HKEY pHkeySub;
@@ -905,22 +826,6 @@
}
CPluginSettings* settings = CPluginSettings::GetInstance();
-
- // Create main thread
- if (GetMainThreadHandle() == NULL && settings->IsMainProcess() && settings->IsMainUiThread())
- {
- DWORD id;
- HANDLE handle = ::CreateThread(NULL, 0, MainThreadProc, (LPVOID)m_tab, CREATE_SUSPENDED, &id);
- if (handle == NULL)
- {
- DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_THREAD, PLUGIN_ERROR_MAIN_THREAD_CREATE_PROCESS, "Class::Thread - Failed to create main thread");
- }
-
- s_hMainThread = handle;
-
- ::ResumeThread(handle);
- }
-
return true;
}
@@ -1097,8 +1002,7 @@
SendMessage(m_hStatusBarWnd, WM_PAINT, (WPARAM)hdc, 0);
ReleaseDC(m_hStatusBarWnd, hdc);
return true;
-}/////////////////////////////////////////////////////////////////////////////
-// Implementation
+}
void CPluginClass::CloseTheme()
{

Powered by Google App Engine
This is Rietveld