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: rebase only Created July 27, 2016, 10:26 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/Instances.h ('k') | src/plugin/PluginClass.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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 class ATL_NO_VTABLE CPluginClass : 44 class ATL_NO_VTABLE CPluginClass :
45 public ATL::CComObjectRootEx<ATL::CComMultiThreadModel>, 45 public ATL::CComObjectRootEx<ATL::CComMultiThreadModel>,
46 public ATL::CComCoClass<CPluginClass, &CLSID_PluginClass>, 46 public ATL::CComCoClass<CPluginClass, &CLSID_PluginClass>,
47 public ATL::IObjectWithSiteImpl<CPluginClass>, 47 public ATL::IObjectWithSiteImpl<CPluginClass>,
48 public IOleCommandTarget, 48 public IOleCommandTarget,
49 public ATL::IDispEventImpl<1, CPluginClass, &DIID_DWebBrowserEvents2, &LIBID_S HDocVw, 1, 1> 49 public ATL::IDispEventImpl<1, CPluginClass, &DIID_DWebBrowserEvents2, &LIBID_S HDocVw, 1, 1>
50 { 50 {
51 51
52 friend class CPluginTab; 52 friend class CPluginTab;
53 friend class AnyCurrentSiteBrowser;
53 54
54 private: 55 private:
55 56
56 CPluginTab* m_tab; 57 CPluginTab* m_tab;
57 58
58 public: 59 public:
59 60
60 DECLARE_REGISTRY_RESOURCEID(IDR_PLUGIN_CLASS) 61 DECLARE_REGISTRY_RESOURCEID(IDR_PLUGIN_CLASS)
61 62
62 DECLARE_PROTECT_FINAL_CONSTRUCT() 63 DECLARE_PROTECT_FINAL_CONSTRUCT()
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 96
96 bool SetMenuBar(HMENU hMenu, const std::wstring& url); 97 bool SetMenuBar(HMENU hMenu, const std::wstring& url);
97 HMENU CreatePluginMenu(const std::wstring& url); 98 HMENU CreatePluginMenu(const std::wstring& url);
98 99
99 void DisplayPluginMenu(HMENU hMenu, int nToolbarCmdID, POINT pt, UINT nMenuFla gs); 100 void DisplayPluginMenu(HMENU hMenu, int nToolbarCmdID, POINT pt, UINT nMenuFla gs);
100 bool CreateStatusBarPane(); 101 bool CreateStatusBarPane();
101 102
102 public: 103 public:
103 HWND GetBrowserHWND() const; 104 HWND GetBrowserHWND() const;
104 bool IsRootBrowser(IWebBrowser2*); 105 bool IsRootBrowser(IWebBrowser2*);
105
106 static CPluginMimeFilterClient* s_mimeFilter; 106 static CPluginMimeFilterClient* s_mimeFilter;
107 107
108 private: 108 private:
109 109
110 std::wstring GetBrowserUrl() const; 110 std::wstring GetBrowserUrl() const;
111 111
112 static DWORD WINAPI StartInitObject(LPVOID thisPtr); 112 static DWORD WINAPI StartInitObject(LPVOID thisPtr);
113 bool InitObject(); 113 bool InitObject();
114 void CloseTheme(); 114 void CloseTheme();
115 void UpdateTheme(); 115 void UpdateTheme();
(...skipping 12 matching lines...) Expand all
128 VARIANT* Headers /**< [in] */, 128 VARIANT* Headers /**< [in] */,
129 VARIANT_BOOL* Cancel /* [in, out] */) ; 129 VARIANT_BOOL* Cancel /* [in, out] */) ;
130 void STDMETHODCALLTYPE OnDownloadComplete(); 130 void STDMETHODCALLTYPE OnDownloadComplete();
131 void STDMETHODCALLTYPE OnDocumentComplete(IDispatch* frameBrowserDisp, VARIANT * /*urlOrPidl*/); 131 void STDMETHODCALLTYPE OnDocumentComplete(IDispatch* frameBrowserDisp, VARIANT * /*urlOrPidl*/);
132 void STDMETHODCALLTYPE OnWindowStateChanged(unsigned long flags, unsigned long validFlagsMask); 132 void STDMETHODCALLTYPE OnWindowStateChanged(unsigned long flags, unsigned long validFlagsMask);
133 void STDMETHODCALLTYPE OnCommandStateChange(long command, VARIANT_BOOL enable) ; 133 void STDMETHODCALLTYPE OnCommandStateChange(long command, VARIANT_BOOL enable) ;
134 void STDMETHODCALLTYPE OnOnQuit(); 134 void STDMETHODCALLTYPE OnOnQuit();
135 void Unadvise(); 135 void Unadvise();
136 136
137 void ShowStatusBar(); 137 void ShowStatusBar();
138 bool IsStatusBarEnabled();
139 138
140 /** 139 /**
141 * A browser interface pointer to our site object 140 * A browser interface pointer to our site object
142 * 141 *
143 * It's values are set and reset solely in SetSite(). 142 * It's values are set and reset solely in SetSite().
144 */ 143 */
145 CComPtr<IWebBrowser2> m_webBrowser2; 144 CComPtr<IWebBrowser2> m_webBrowser2;
145 /**
146 * Synchronizes SetSite() with references to our site pointer.
147 */
148 std::mutex siteGuard;
149
146 HWND m_hBrowserWnd; 150 HWND m_hBrowserWnd;
147 HWND m_hTabWnd; 151 HWND m_hTabWnd;
148 HWND m_hStatusBarWnd; 152 HWND m_hStatusBarWnd;
149 HWND m_hPaneWnd; 153 HWND m_hPaneWnd;
150 154
151 WNDPROC m_pWndProcStatus; 155 WNDPROC m_pWndProcStatus;
152 int m_nPaneWidth; 156 int m_nPaneWidth;
153 HANDLE m_hTheme; 157 HANDLE m_hTheme;
154 158
155 CriticalSection m_csStatusBar; 159 CriticalSection m_csStatusBar;
(...skipping 12 matching lines...) Expand all
168 static HICON s_hIcons[ICON_MAX]; 172 static HICON s_hIcons[ICON_MAX];
169 static DWORD s_hIconTypes[ICON_MAX]; 173 static DWORD s_hIconTypes[ICON_MAX];
170 174
171 static HICON GetIcon(int type); 175 static HICON GetIcon(int type);
172 176
173 // Main thread 177 // Main thread
174 static HANDLE s_hMainThread; 178 static HANDLE s_hMainThread;
175 static bool s_isMainThreadDone; 179 static bool s_isMainThreadDone;
176 180
177 static HINSTANCE s_hUxtheme; 181 static HINSTANCE s_hUxtheme;
178 static std::set<CPluginClass*> s_instances;
179 static CComAutoCriticalSection s_criticalSectionLocal; 182 static CComAutoCriticalSection s_criticalSectionLocal;
180 static CComAutoCriticalSection s_criticalSectionWindow; 183 static CComAutoCriticalSection s_criticalSectionWindow;
181
182 // Async browser
183 static CComQIPtr<IWebBrowser2> s_asyncWebBrowser2;
184 static CComQIPtr<IWebBrowser2> GetAsyncBrowser();
185 }; 184 };
186 185
187 OBJECT_ENTRY_AUTO(__uuidof(PluginClass), CPluginClass) 186 OBJECT_ENTRY_AUTO(__uuidof(PluginClass), CPluginClass)
188 187
189 #endif // _PLUGIN_CLASS_H_ 188 #endif // _PLUGIN_CLASS_H_
OLDNEW
« no previous file with comments | « src/plugin/Instances.h ('k') | src/plugin/PluginClass.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld