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

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

Issue 29333107: Issue #1652, #3456 - Replace 's_asyncWebBrowser2' with thread-safe facilities
Patch Set: address comments Created Jan. 4, 2016, 5:51 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
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 10 matching lines...) Expand all
21 21
22 #ifndef _PLUGIN_CLASS_H_ 22 #ifndef _PLUGIN_CLASS_H_
23 #define _PLUGIN_CLASS_H_ 23 #define _PLUGIN_CLASS_H_
24 24
25 25
26 #include "Plugin.h" 26 #include "Plugin.h"
27 #include "PluginTabBase.h" 27 #include "PluginTabBase.h"
28 #define _CRTDBG_MAP_ALLOC 28 #define _CRTDBG_MAP_ALLOC
29 #include <stdlib.h> 29 #include <stdlib.h>
30 #include <crtdbg.h> 30 #include <crtdbg.h>
31 #include <set> 31 #include <mutex>
32 32
33 #include "NotificationMessage.h" 33 #include "NotificationMessage.h"
34 34
35 #define ICON_PLUGIN_DISABLED 0 35 #define ICON_PLUGIN_DISABLED 0
36 #define ICON_PLUGIN_ENABLED 1 36 #define ICON_PLUGIN_ENABLED 1
37 #define ICON_PLUGIN_DEACTIVATED 2 37 #define ICON_PLUGIN_DEACTIVATED 2
38 #define ICON_MAX 3 38 #define ICON_MAX 3
39 39
40 #define WM_LAUNCH_INFO (WM_APP + 10) 40 #define WM_LAUNCH_INFO (WM_APP + 10)
41 41
42 class CPluginMimeFilterClient; 42 class CPluginMimeFilterClient;
43 43
44 44
45 class ATL_NO_VTABLE CPluginClass : 45 class ATL_NO_VTABLE CPluginClass :
46 public ATL::CComObjectRootEx<ATL::CComMultiThreadModel>, 46 public ATL::CComObjectRootEx<ATL::CComMultiThreadModel>,
47 public ATL::CComCoClass<CPluginClass, &CLSID_PluginClass>, 47 public ATL::CComCoClass<CPluginClass, &CLSID_PluginClass>,
48 public ATL::IObjectWithSiteImpl<CPluginClass>, 48 public ATL::IObjectWithSiteImpl<CPluginClass>,
49 public IOleCommandTarget, 49 public IOleCommandTarget,
50 public ATL::IDispEventImpl<1, CPluginClass, &DIID_DWebBrowserEvents2, &LIBID_S HDocVw, 1, 1> 50 public ATL::IDispEventImpl<1, CPluginClass, &DIID_DWebBrowserEvents2, &LIBID_S HDocVw, 1, 1>
51 { 51 {
52 52
53 friend class CPluginTab; 53 friend class CPluginTab;
54 friend class AnyCurrentSiteBrowser;
54 55
55 private: 56 private:
56 57
57 CPluginTab* m_tab; 58 CPluginTab* m_tab;
58 59
59 public: 60 public:
60 61
61 DECLARE_REGISTRY_RESOURCEID(IDR_PLUGIN_CLASS) 62 DECLARE_REGISTRY_RESOURCEID(IDR_PLUGIN_CLASS)
62 63
63 DECLARE_PROTECT_FINAL_CONSTRUCT() 64 DECLARE_PROTECT_FINAL_CONSTRUCT()
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 97
97 bool SetMenuBar(HMENU hMenu, const std::wstring& url); 98 bool SetMenuBar(HMENU hMenu, const std::wstring& url);
98 HMENU CreatePluginMenu(const std::wstring& url); 99 HMENU CreatePluginMenu(const std::wstring& url);
99 100
100 void DisplayPluginMenu(HMENU hMenu, int nToolbarCmdID, POINT pt, UINT nMenuFla gs); 101 void DisplayPluginMenu(HMENU hMenu, int nToolbarCmdID, POINT pt, UINT nMenuFla gs);
101 bool CreateStatusBarPane(); 102 bool CreateStatusBarPane();
102 103
103 public: 104 public:
104 HWND GetBrowserHWND() const; 105 HWND GetBrowserHWND() const;
105 bool IsRootBrowser(IWebBrowser2*); 106 bool IsRootBrowser(IWebBrowser2*);
106
107 static CPluginMimeFilterClient* s_mimeFilter; 107 static CPluginMimeFilterClient* s_mimeFilter;
108 108
109 private: 109 private:
110 110
111 std::wstring GetBrowserUrl() const; 111 std::wstring GetBrowserUrl() const;
112 112
113 static DWORD WINAPI StartInitObject(LPVOID thisPtr); 113 static DWORD WINAPI StartInitObject(LPVOID thisPtr);
114 bool InitObject(); 114 bool InitObject();
115 void CloseTheme(); 115 void CloseTheme();
116 void UpdateTheme(); 116 void UpdateTheme();
(...skipping 12 matching lines...) Expand all
129 VARIANT* Headers /**< [in] */, 129 VARIANT* Headers /**< [in] */,
130 VARIANT_BOOL* Cancel /* [in, out] */) ; 130 VARIANT_BOOL* Cancel /* [in, out] */) ;
131 void STDMETHODCALLTYPE OnDownloadComplete(); 131 void STDMETHODCALLTYPE OnDownloadComplete();
132 void STDMETHODCALLTYPE OnDocumentComplete(IDispatch* frameBrowserDisp, VARIANT * /*urlOrPidl*/); 132 void STDMETHODCALLTYPE OnDocumentComplete(IDispatch* frameBrowserDisp, VARIANT * /*urlOrPidl*/);
133 void STDMETHODCALLTYPE OnWindowStateChanged(unsigned long flags, unsigned long validFlagsMask); 133 void STDMETHODCALLTYPE OnWindowStateChanged(unsigned long flags, unsigned long validFlagsMask);
134 void STDMETHODCALLTYPE OnCommandStateChange(long command, VARIANT_BOOL enable) ; 134 void STDMETHODCALLTYPE OnCommandStateChange(long command, VARIANT_BOOL enable) ;
135 void STDMETHODCALLTYPE OnOnQuit(); 135 void STDMETHODCALLTYPE OnOnQuit();
136 void Unadvise(); 136 void Unadvise();
137 137
138 void ShowStatusBar(); 138 void ShowStatusBar();
139 bool IsStatusBarEnabled();
Oleksandr 2016/02/01 18:03:14 Nit: Unrelated change.
140 139
141 /** 140 /**
142 * A browser interface pointer to our site object 141 * A browser interface pointer to our site object
143 * 142 *
144 * It's values are set and reset solely in SetSite(). 143 * It's values are set and reset solely in SetSite().
145 */ 144 */
146 CComPtr<IWebBrowser2> m_webBrowser2; 145 CComPtr<IWebBrowser2> m_webBrowser2;
146 /**
147 * Synchronizes SetSite() with references to our site pointer.
148 */
149 std::mutex siteGuard;
150
147 HWND m_hBrowserWnd; 151 HWND m_hBrowserWnd;
148 HWND m_hTabWnd; 152 HWND m_hTabWnd;
149 HWND m_hStatusBarWnd; 153 HWND m_hStatusBarWnd;
150 HWND m_hPaneWnd; 154 HWND m_hPaneWnd;
151 155
152 WNDPROC m_pWndProcStatus; 156 WNDPROC m_pWndProcStatus;
153 int m_nPaneWidth; 157 int m_nPaneWidth;
154 HANDLE m_hTheme; 158 HANDLE m_hTheme;
155 159
156 CriticalSection m_csStatusBar; 160 CriticalSection m_csStatusBar;
(...skipping 12 matching lines...) Expand all
169 static HICON s_hIcons[ICON_MAX]; 173 static HICON s_hIcons[ICON_MAX];
170 static DWORD s_hIconTypes[ICON_MAX]; 174 static DWORD s_hIconTypes[ICON_MAX];
171 175
172 static HICON GetIcon(int type); 176 static HICON GetIcon(int type);
173 177
174 // Main thread 178 // Main thread
175 static HANDLE s_hMainThread; 179 static HANDLE s_hMainThread;
176 static bool s_isMainThreadDone; 180 static bool s_isMainThreadDone;
177 181
178 static HINSTANCE s_hUxtheme; 182 static HINSTANCE s_hUxtheme;
179 static std::set<CPluginClass*> s_instances;
180 static std::map<DWORD,CPluginClass*> s_threadInstances; 183 static std::map<DWORD,CPluginClass*> s_threadInstances;
181 static CComAutoCriticalSection s_criticalSectionLocal; 184 static CComAutoCriticalSection s_criticalSectionLocal;
182 static CComAutoCriticalSection s_criticalSectionWindow; 185 static CComAutoCriticalSection s_criticalSectionWindow;
183
184 // Async browser
185 static CComQIPtr<IWebBrowser2> s_asyncWebBrowser2;
186 static CComQIPtr<IWebBrowser2> GetAsyncBrowser();
187 }; 186 };
188 187
189 OBJECT_ENTRY_AUTO(__uuidof(PluginClass), CPluginClass) 188 OBJECT_ENTRY_AUTO(__uuidof(PluginClass), CPluginClass)
190 189
191 190
192 #endif // _PLUGIN_CLASS_H_ 191 #endif // _PLUGIN_CLASS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld