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: full patch Created July 23, 2014, 11:28 a.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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 254
255 //register the mimefilter 255 //register the mimefilter
256 //and only mimefilter 256 //and only mimefilter
257 //on some few computers the mimefilter does not get properly registered when it is done on another thread 257 //on some few computers the mimefilter does not get properly registered when it is done on another thread
258 258
259 s_criticalSectionLocal.Lock(); 259 s_criticalSectionLocal.Lock();
260 { 260 {
261 // Always register on startup, then check if we need to unregister in a se parate thread 261 // Always register on startup, then check if we need to unregister in a se parate thread
262 s_mimeFilter = CPluginClientFactory::GetMimeFilterClientInstance(); 262 s_mimeFilter = CPluginClientFactory::GetMimeFilterClientInstance();
263 s_asyncWebBrowser2 = unknownSite; 263 s_asyncWebBrowser2 = unknownSite;
264 s_instances.Add(this); 264 s_instances.insert(this);
265 } 265 }
266 s_criticalSectionLocal.Unlock(); 266 s_criticalSectionLocal.Unlock();
267 267
268 try 268 try
269 { 269 {
270 // Check if loaded as BHO 270 // Check if loaded as BHO
271 if (GetBrowser()) 271 if (GetBrowser())
272 { 272 {
273 DEBUG_GENERAL("Loaded as BHO"); 273 DEBUG_GENERAL("Loaded as BHO");
274 CComPtr<IConnectionPoint> pPoint = GetConnectionPoint(); 274 CComPtr<IConnectionPoint> pPoint = GetConnectionPoint();
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 358
359 m_hTabWnd = NULL; 359 m_hTabWnd = NULL;
360 m_hStatusBarWnd = NULL; 360 m_hStatusBarWnd = NULL;
361 361
362 // Remove instance from the list, shutdown threads 362 // Remove instance from the list, shutdown threads
363 HANDLE hMainThread = NULL; 363 HANDLE hMainThread = NULL;
364 HANDLE hTabThread = NULL; 364 HANDLE hTabThread = NULL;
365 365
366 s_criticalSectionLocal.Lock(); 366 s_criticalSectionLocal.Lock();
367 { 367 {
368 s_instances.Remove(this); 368 s_instances.erase(this);
369 369
370 std::map<DWORD,CPluginClass*>::iterator it = s_threadInstances.find(::GetC urrentThreadId()); 370 std::map<DWORD,CPluginClass*>::iterator it = s_threadInstances.find(::GetC urrentThreadId());
371 if (it != s_threadInstances.end()) 371 if (it != s_threadInstances.end())
372 { 372 {
373 s_threadInstances.erase(it); 373 s_threadInstances.erase(it);
374 } 374 }
375 if (s_instances.GetSize() == 0) 375 if (s_instances.empty())
376 { 376 {
377 CPluginClientFactory::ReleaseMimeFilterClientInstance(); 377 CPluginClientFactory::ReleaseMimeFilterClientInstance();
378 } 378 }
379 } 379 }
380 s_criticalSectionLocal.Unlock(); 380 s_criticalSectionLocal.Unlock();
381 381
382 // Release browser interface 382 // Release browser interface
383 s_criticalSectionBrowser.Lock(); 383 s_criticalSectionBrowser.Lock();
384 { 384 {
385 m_webBrowser2.Release(); 385 m_webBrowser2.Release();
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 if (hTabWnd2) 886 if (hTabWnd2)
887 { 887 {
888 DWORD nProcessId; 888 DWORD nProcessId;
889 ::GetWindowThreadProcessId(hTabWnd2, &nProcessId); 889 ::GetWindowThreadProcessId(hTabWnd2, &nProcessId);
890 if (::GetCurrentProcessId() == nProcessId) 890 if (::GetCurrentProcessId() == nProcessId)
891 { 891 {
892 bool bExistingTab = false; 892 bool bExistingTab = false;
893 893
894 s_criticalSectionLocal.Lock(); 894 s_criticalSectionLocal.Lock();
895 { 895 {
896 for (int i = 0; i < s_instances.GetSize(); i++) 896 for (auto instance : s_instances)
897 { 897 {
898 if (s_instances[i]->m_hTabWnd == hTabWnd2) 898 if (instance->m_hTabWnd == hTabWnd2)
899 { 899 {
900
901 bExistingTab = true; 900 bExistingTab = true;
902 break; 901 break;
903 } 902 }
904 } 903 }
905 } 904 }
906 s_criticalSectionLocal.Unlock(); 905 s_criticalSectionLocal.Unlock();
907 906
908 if (!bExistingTab) 907 if (!bExistingTab)
909 { 908 {
910 amoundOfNewTabs ++; 909 amoundOfNewTabs ++;
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
1055 m_hTheme = pfnOpenThemeData(m_hPaneWnd, L"STATUS"); 1054 m_hTheme = pfnOpenThemeData(m_hPaneWnd, L"STATUS");
1056 if (!m_hTheme) 1055 if (!m_hTheme)
1057 { 1056 {
1058 } 1057 }
1059 } 1058 }
1060 } 1059 }
1061 1060
1062 1061
1063 CPluginClass* CPluginClass::FindInstance(HWND hStatusBarWnd) 1062 CPluginClass* CPluginClass::FindInstance(HWND hStatusBarWnd)
1064 { 1063 {
1065 CPluginClass* instance = NULL; 1064 CPluginClass* return_instance = nullptr;
Wladimir Palant 2014/07/24 06:41:53 Nit: this variable should simply be called "result
Eric 2014/07/24 12:33:48 Done.
1066 1065
1067 s_criticalSectionLocal.Lock(); 1066 s_criticalSectionLocal.Lock();
1068 { 1067 {
1069 for (int i = 0; i < s_instances.GetSize(); i++) 1068 for (auto instance : s_instances)
1070 { 1069 {
1071 if (s_instances[i]->m_hStatusBarWnd == hStatusBarWnd) 1070 if (instance->m_hStatusBarWnd == hStatusBarWnd)
1072 { 1071 {
1073 instance = s_instances[i]; 1072 return_instance = instance;
1074 break; 1073 break;
1075 } 1074 }
1076 } 1075 }
1077 } 1076 }
1078 s_criticalSectionLocal.Unlock(); 1077 s_criticalSectionLocal.Unlock();
1079 1078
1080 return instance; 1079 return return_instance;
1081 } 1080 }
1082 1081
1083 CPluginTab* CPluginClass::GetTab() 1082 CPluginTab* CPluginClass::GetTab()
1084 { 1083 {
1085 return m_tab; 1084 return m_tab;
1086 } 1085 }
1087 1086
1088 CPluginTab* CPluginClass::GetTab(DWORD dwThreadId) 1087 CPluginTab* CPluginClass::GetTab(DWORD dwThreadId)
1089 { 1088 {
1090 CPluginTab* tab = NULL; 1089 CPluginTab* tab = NULL;
(...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after
1942 if (hTabWnd2) 1941 if (hTabWnd2)
1943 { 1942 {
1944 DWORD nProcessId; 1943 DWORD nProcessId;
1945 ::GetWindowThreadProcessId(hTabWnd2, &nProcessId); 1944 ::GetWindowThreadProcessId(hTabWnd2, &nProcessId);
1946 if (::GetCurrentProcessId() == nProcessId) 1945 if (::GetCurrentProcessId() == nProcessId)
1947 { 1946 {
1948 bool bExistingTab = false; 1947 bool bExistingTab = false;
1949 s_criticalSectionLocal.Lock(); 1948 s_criticalSectionLocal.Lock();
1950 1949
1951 { 1950 {
1952 for (int i = 0; i < s_instances.GetSize(); i++) 1951 for (auto instance : s_instances)
1953 { 1952 {
1954 if (s_instances[i]->m_hTabWnd == hTabWnd2) 1953 if (instance->m_hTabWnd == hTabWnd2)
1955 { 1954 {
1956 bExistingTab = true; 1955 bExistingTab = true;
1957 break; 1956 break;
1958 } 1957 }
1959 } 1958 }
1960 } 1959 }
1961 1960
1962 if (!bExistingTab) 1961 if (!bExistingTab)
1963 { 1962 {
1964 hBrowserWnd = hTabWnd2; 1963 hBrowserWnd = hTabWnd2;
1965 hTabWnd = hTabWnd2; 1964 hTabWnd = hTabWnd2;
1966 s_criticalSectionLocal.Unlock(); 1965 s_criticalSectionLocal.Unlock();
1967 break; 1966 break;
1968 } 1967 }
1969 s_criticalSectionLocal.Unlock(); 1968 s_criticalSectionLocal.Unlock();
1970 1969
1971 } 1970 }
1972 } 1971 }
1973 } 1972 }
1974 1973
1975 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); 1974 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT);
1976 } 1975 }
1977 1976
1978 return hTabWnd; 1977 return hTabWnd;
1979 1978
1980 } 1979 }
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