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

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

Issue 5712621990838272: [IE] Replace ATL::CSimpleArray (Closed)
Patch Set: Created July 24, 2014, 12:31 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
« no previous file with comments | « src/plugin/PluginClass.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #include "PluginStdAfx.h" 1 #include "PluginStdAfx.h"
2 2
3 #include "PluginClass.h" 3 #include "PluginClass.h"
4 #include "PluginSettings.h" 4 #include "PluginSettings.h"
5 #include "PluginSystem.h" 5 #include "PluginSystem.h"
6 #ifdef SUPPORT_FILTER 6 #ifdef SUPPORT_FILTER
7 #include "PluginFilter.h" 7 #include "PluginFilter.h"
8 #endif 8 #endif
9 #include "PluginMimeFilterClient.h" 9 #include "PluginMimeFilterClient.h"
10 #include "PluginClient.h" 10 #include "PluginClient.h"
(...skipping 18 matching lines...) Expand all
29 DWORD CPluginClass::s_hIconTypes[ICON_MAX] = { IDI_ICON_DISABLED, IDI_ICON_ENABL ED, IDI_ICON_DEACTIVATED }; 29 DWORD CPluginClass::s_hIconTypes[ICON_MAX] = { IDI_ICON_DISABLED, IDI_ICON_ENABL ED, IDI_ICON_DEACTIVATED };
30 30
31 CPluginMimeFilterClient* CPluginClass::s_mimeFilter = NULL; 31 CPluginMimeFilterClient* CPluginClass::s_mimeFilter = NULL;
32 32
33 CLOSETHEMEDATA pfnClose = NULL; 33 CLOSETHEMEDATA pfnClose = NULL;
34 DRAWTHEMEBACKGROUND pfnDrawThemeBackground = NULL; 34 DRAWTHEMEBACKGROUND pfnDrawThemeBackground = NULL;
35 OPENTHEMEDATA pfnOpenThemeData = NULL; 35 OPENTHEMEDATA pfnOpenThemeData = NULL;
36 36
37 ATOM CPluginClass::s_atomPaneClass = NULL; 37 ATOM CPluginClass::s_atomPaneClass = NULL;
38 HINSTANCE CPluginClass::s_hUxtheme = NULL; 38 HINSTANCE CPluginClass::s_hUxtheme = NULL;
39 CSimpleArray<CPluginClass*> CPluginClass::s_instances; 39 std::set<CPluginClass*> CPluginClass::s_instances;
40 std::map<DWORD, CPluginClass*> CPluginClass::s_threadInstances; 40 std::map<DWORD, CPluginClass*> CPluginClass::s_threadInstances;
41 41
42 CComAutoCriticalSection CPluginClass::s_criticalSectionLocal; 42 CComAutoCriticalSection CPluginClass::s_criticalSectionLocal;
43 CComAutoCriticalSection CPluginClass::s_criticalSectionBrowser; 43 CComAutoCriticalSection CPluginClass::s_criticalSectionBrowser;
44 CComAutoCriticalSection CPluginClass::s_criticalSectionWindow; 44 CComAutoCriticalSection CPluginClass::s_criticalSectionWindow;
45 45
46 CComQIPtr<IWebBrowser2> CPluginClass::s_asyncWebBrowser2; 46 CComQIPtr<IWebBrowser2> CPluginClass::s_asyncWebBrowser2;
47 47
48 #ifdef SUPPORT_WHITELIST 48 #ifdef SUPPORT_WHITELIST
49 std::map<UINT,CString> CPluginClass::s_menuDomains; 49 std::map<UINT,CString> CPluginClass::s_menuDomains;
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 278
279 //register the mimefilter 279 //register the mimefilter
280 //and only mimefilter 280 //and only mimefilter
281 //on some few computers the mimefilter does not get properly registered when it is done on another thread 281 //on some few computers the mimefilter does not get properly registered when it is done on another thread
282 282
283 s_criticalSectionLocal.Lock(); 283 s_criticalSectionLocal.Lock();
284 { 284 {
285 // Always register on startup, then check if we need to unregister in a se parate thread 285 // Always register on startup, then check if we need to unregister in a se parate thread
286 s_mimeFilter = CPluginClientFactory::GetMimeFilterClientInstance(); 286 s_mimeFilter = CPluginClientFactory::GetMimeFilterClientInstance();
287 s_asyncWebBrowser2 = unknownSite; 287 s_asyncWebBrowser2 = unknownSite;
288 s_instances.Add(this); 288 s_instances.insert(this);
289 } 289 }
290 s_criticalSectionLocal.Unlock(); 290 s_criticalSectionLocal.Unlock();
291 291
292 try 292 try
293 { 293 {
294 // Check if loaded as BHO 294 // Check if loaded as BHO
295 if (GetBrowser()) 295 if (GetBrowser())
296 { 296 {
297 DEBUG_GENERAL("Loaded as BHO"); 297 DEBUG_GENERAL("Loaded as BHO");
298 CComPtr<IConnectionPoint> pPoint = GetConnectionPoint(); 298 CComPtr<IConnectionPoint> pPoint = GetConnectionPoint();
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 382
383 m_hTabWnd = NULL; 383 m_hTabWnd = NULL;
384 m_hStatusBarWnd = NULL; 384 m_hStatusBarWnd = NULL;
385 385
386 // Remove instance from the list, shutdown threads 386 // Remove instance from the list, shutdown threads
387 HANDLE hMainThread = NULL; 387 HANDLE hMainThread = NULL;
388 HANDLE hTabThread = NULL; 388 HANDLE hTabThread = NULL;
389 389
390 s_criticalSectionLocal.Lock(); 390 s_criticalSectionLocal.Lock();
391 { 391 {
392 s_instances.Remove(this); 392 s_instances.erase(this);
393 393
394 std::map<DWORD,CPluginClass*>::iterator it = s_threadInstances.find(::GetC urrentThreadId()); 394 std::map<DWORD,CPluginClass*>::iterator it = s_threadInstances.find(::GetC urrentThreadId());
395 if (it != s_threadInstances.end()) 395 if (it != s_threadInstances.end())
396 { 396 {
397 s_threadInstances.erase(it); 397 s_threadInstances.erase(it);
398 } 398 }
399 if (s_instances.GetSize() == 0) 399 if (s_instances.empty())
400 { 400 {
401 CPluginClientFactory::ReleaseMimeFilterClientInstance(); 401 CPluginClientFactory::ReleaseMimeFilterClientInstance();
402 } 402 }
403 } 403 }
404 s_criticalSectionLocal.Unlock(); 404 s_criticalSectionLocal.Unlock();
405 405
406 // Release browser interface 406 // Release browser interface
407 s_criticalSectionBrowser.Lock(); 407 s_criticalSectionBrowser.Lock();
408 { 408 {
409 m_webBrowser2.Release(); 409 m_webBrowser2.Release();
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 if (hTabWnd2) 910 if (hTabWnd2)
911 { 911 {
912 DWORD nProcessId; 912 DWORD nProcessId;
913 ::GetWindowThreadProcessId(hTabWnd2, &nProcessId); 913 ::GetWindowThreadProcessId(hTabWnd2, &nProcessId);
914 if (::GetCurrentProcessId() == nProcessId) 914 if (::GetCurrentProcessId() == nProcessId)
915 { 915 {
916 bool bExistingTab = false; 916 bool bExistingTab = false;
917 917
918 s_criticalSectionLocal.Lock(); 918 s_criticalSectionLocal.Lock();
919 { 919 {
920 for (int i = 0; i < s_instances.GetSize(); i++) 920 for (auto instance : s_instances)
921 { 921 {
922 if (s_instances[i]->m_hTabWnd == hTabWnd2) 922 if (instance->m_hTabWnd == hTabWnd2)
923 { 923 {
924
925 bExistingTab = true; 924 bExistingTab = true;
926 break; 925 break;
927 } 926 }
928 } 927 }
929 } 928 }
930 s_criticalSectionLocal.Unlock(); 929 s_criticalSectionLocal.Unlock();
931 930
932 if (!bExistingTab) 931 if (!bExistingTab)
933 { 932 {
934 amoundOfNewTabs ++; 933 amoundOfNewTabs ++;
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
1079 m_hTheme = pfnOpenThemeData(m_hPaneWnd, L"STATUS"); 1078 m_hTheme = pfnOpenThemeData(m_hPaneWnd, L"STATUS");
1080 if (!m_hTheme) 1079 if (!m_hTheme)
1081 { 1080 {
1082 } 1081 }
1083 } 1082 }
1084 } 1083 }
1085 1084
1086 1085
1087 CPluginClass* CPluginClass::FindInstance(HWND hStatusBarWnd) 1086 CPluginClass* CPluginClass::FindInstance(HWND hStatusBarWnd)
1088 { 1087 {
1089 CPluginClass* instance = NULL; 1088 CPluginClass* result = nullptr;
1090 1089
1091 s_criticalSectionLocal.Lock(); 1090 s_criticalSectionLocal.Lock();
1092 { 1091 {
1093 for (int i = 0; i < s_instances.GetSize(); i++) 1092 for (auto instance : s_instances)
1094 { 1093 {
1095 if (s_instances[i]->m_hStatusBarWnd == hStatusBarWnd) 1094 if (instance->m_hStatusBarWnd == hStatusBarWnd)
1096 { 1095 {
1097 instance = s_instances[i]; 1096 result = instance;
1098 break; 1097 break;
1099 } 1098 }
1100 } 1099 }
1101 } 1100 }
1102 s_criticalSectionLocal.Unlock(); 1101 s_criticalSectionLocal.Unlock();
1103 1102
1104 return instance; 1103 return result;
1105 } 1104 }
1106 1105
1107 CPluginTab* CPluginClass::GetTab() 1106 CPluginTab* CPluginClass::GetTab()
1108 { 1107 {
1109 return m_tab; 1108 return m_tab;
1110 } 1109 }
1111 1110
1112 CPluginTab* CPluginClass::GetTab(DWORD dwThreadId) 1111 CPluginTab* CPluginClass::GetTab(DWORD dwThreadId)
1113 { 1112 {
1114 CPluginTab* tab = NULL; 1113 CPluginTab* tab = NULL;
(...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after
1966 if (hTabWnd2) 1965 if (hTabWnd2)
1967 { 1966 {
1968 DWORD nProcessId; 1967 DWORD nProcessId;
1969 ::GetWindowThreadProcessId(hTabWnd2, &nProcessId); 1968 ::GetWindowThreadProcessId(hTabWnd2, &nProcessId);
1970 if (::GetCurrentProcessId() == nProcessId) 1969 if (::GetCurrentProcessId() == nProcessId)
1971 { 1970 {
1972 bool bExistingTab = false; 1971 bool bExistingTab = false;
1973 s_criticalSectionLocal.Lock(); 1972 s_criticalSectionLocal.Lock();
1974 1973
1975 { 1974 {
1976 for (int i = 0; i < s_instances.GetSize(); i++) 1975 for (auto instance : s_instances)
1977 { 1976 {
1978 if (s_instances[i]->m_hTabWnd == hTabWnd2) 1977 if (instance->m_hTabWnd == hTabWnd2)
1979 { 1978 {
1980 bExistingTab = true; 1979 bExistingTab = true;
1981 break; 1980 break;
1982 } 1981 }
1983 } 1982 }
1984 } 1983 }
1985 1984
1986 if (!bExistingTab) 1985 if (!bExistingTab)
1987 { 1986 {
1988 hBrowserWnd = hTabWnd2; 1987 hBrowserWnd = hTabWnd2;
1989 hTabWnd = hTabWnd2; 1988 hTabWnd = hTabWnd2;
1990 s_criticalSectionLocal.Unlock(); 1989 s_criticalSectionLocal.Unlock();
1991 break; 1990 break;
1992 } 1991 }
1993 s_criticalSectionLocal.Unlock(); 1992 s_criticalSectionLocal.Unlock();
1994 1993
1995 } 1994 }
1996 } 1995 }
1997 } 1996 }
1998 1997
1999 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); 1998 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT);
2000 } 1999 }
2001 2000
2002 return hTabWnd; 2001 return hTabWnd;
2003 2002
2004 } 2003 }
OLDNEW
« no previous file with comments | « src/plugin/PluginClass.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld