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

Unified Diff: src/plugin/PluginClass.cpp

Issue 5113230347206656: Issue #1356 - Improve detection of the issuer of the request (Closed)
Patch Set: Fix the deadlock Created Oct. 7, 2014, 11:22 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
@@ -1137,6 +1137,27 @@
return tab;
}
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
+CPluginTab* CPluginClass::GetTab(const std::wstring& url)
+{
+ CPluginTab* tab = NULL;
+
+ s_criticalSectionLocal.Lock();
+ {
+ std::map<DWORD,CPluginClass*>::const_iterator it;
+ 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
+ {
+ if (it->second->GetBrowserUrl() == url.c_str())
+ {
+ s_criticalSectionLocal.Unlock();
+ 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'
+ }
+ }
+ }
+ s_criticalSectionLocal.Unlock();
+
+ return tab;
+}
+
STDMETHODIMP CPluginClass::QueryStatus(const GUID* pguidCmdGroup, ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT* pCmdText)
{

Powered by Google App Engine
This is Rietveld