| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| 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 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1129 std::map<DWORD,CPluginClass*>::const_iterator it = s_threadInstances.find(dw ThreadId); | 1129 std::map<DWORD,CPluginClass*>::const_iterator it = s_threadInstances.find(dw ThreadId); |
| 1130 if (it != s_threadInstances.end()) | 1130 if (it != s_threadInstances.end()) |
| 1131 { | 1131 { |
| 1132 tab = it->second->m_tab; | 1132 tab = it->second->m_tab; |
| 1133 } | 1133 } |
| 1134 } | 1134 } |
| 1135 s_criticalSectionLocal.Unlock(); | 1135 s_criticalSectionLocal.Unlock(); |
| 1136 | 1136 |
| 1137 return tab; | 1137 return tab; |
| 1138 } | 1138 } |
| 1139 | 1139 |
|
Eric
2014/10/08 17:37:54
I'm mildly concerned that this version of GetTab i
sergei
2014/10/09 13:46:22
I think it should be fast enough with linear searc
| |
| 1140 CPluginTab* CPluginClass::GetTab(const std::wstring& url) | |
| 1141 { | |
| 1142 CPluginTab* tab = NULL; | |
| 1143 | |
| 1144 s_criticalSectionLocal.Lock(); | |
| 1145 { | |
| 1146 std::map<DWORD,CPluginClass*>::const_iterator it; | |
| 1147 for (it = s_threadInstances.begin(); it != s_threadInstances.end(); ++it) | |
|
Eric
2014/10/08 17:37:54
We can use the range-for syntax here. It's support
| |
| 1148 { | |
| 1149 if (it->second->GetBrowserUrl() == url.c_str()) | |
| 1150 { | |
| 1151 s_criticalSectionLocal.Unlock(); | |
| 1152 return it->second->m_tab; | |
|
Eric
2014/10/08 17:37:54
If we were using a sentry object to control the mu
sergei
2014/10/09 13:46:22
+1 for scoped lock
I also don't like return if it'
| |
| 1153 } | |
| 1154 } | |
| 1155 } | |
| 1156 s_criticalSectionLocal.Unlock(); | |
| 1157 | |
| 1158 return tab; | |
| 1159 } | |
| 1160 | |
| 1140 | 1161 |
| 1141 STDMETHODIMP CPluginClass::QueryStatus(const GUID* pguidCmdGroup, ULONG cCmds, O LECMD prgCmds[], OLECMDTEXT* pCmdText) | 1162 STDMETHODIMP CPluginClass::QueryStatus(const GUID* pguidCmdGroup, ULONG cCmds, O LECMD prgCmds[], OLECMDTEXT* pCmdText) |
| 1142 { | 1163 { |
| 1143 if (cCmds == 0) return E_INVALIDARG; | 1164 if (cCmds == 0) return E_INVALIDARG; |
| 1144 if (prgCmds == 0) return E_POINTER; | 1165 if (prgCmds == 0) return E_POINTER; |
| 1145 | 1166 |
| 1146 prgCmds[0].cmdf = OLECMDF_ENABLED; | 1167 prgCmds[0].cmdf = OLECMDF_ENABLED; |
| 1147 | 1168 |
| 1148 return S_OK; | 1169 return S_OK; |
| 1149 } | 1170 } |
| (...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2001 } | 2022 } |
| 2002 } | 2023 } |
| 2003 } | 2024 } |
| 2004 | 2025 |
| 2005 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); | 2026 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); |
| 2006 } | 2027 } |
| 2007 | 2028 |
| 2008 return hTabWnd; | 2029 return hTabWnd; |
| 2009 | 2030 |
| 2010 } | 2031 } |
| OLD | NEW |