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

Delta Between Two Patch Sets: src/plugin/PluginClass.h

Issue 29332848: Issue #3432 - Manage COM events with a resource class
Left Patch Set: rebase, address comments Created Jan. 7, 2016, 4:21 p.m.
Right Patch Set: rebase only Created July 27, 2016, 8:55 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | src/plugin/PluginClass.cpp » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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-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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 CComPtr<Source> producer; 57 CComPtr<Source> producer;
58 public: 58 public:
59 /** 59 /**
60 * \throw std::runtime_error 60 * \throw std::runtime_error
61 * If connection is not established 61 * If connection is not established
62 * 62 *
63 * \par Precondition 63 * \par Precondition
64 * - consumer is not nullptr (not checked) 64 * - consumer is not nullptr (not checked)
65 * - producer is not nullptr (not checked) 65 * - producer is not nullptr (not checked)
66 */ 66 */
67 AtlEventRegistration(Sink* consumer, Source* producer) 67 AtlEventRegistration(Sink* consumer, Source* producer)
sergei 2016/02/04 13:45:50 Just noticed, it would be better to call them as l
Eric 2016/02/04 17:00:28 Neither pair of words "source/sink" and "listener/
sergei 2016/02/04 19:41:57 I think we should not write the code how it would
Eric 2016/02/04 20:13:25 We've entered bikeshedding territory here. You hav
68 : consumer(consumer), producer(producer) 68 : consumer(consumer), producer(producer)
69 { 69 {
70 auto hr = consumer->DispEventAdvise(producer); 70 auto hr = consumer->DispEventAdvise(producer);
71 if (FAILED(hr)) 71 if (FAILED(hr))
72 { 72 {
73 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_ADVICE, " AtlEventRegistrationImpl::<constructor> - Advise"); 73 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_ADVICE, " AtlEventRegistrationImpl::<constructor> - Advise");
74 throw std::runtime_error("DispEventAdvise() failed"); 74 throw std::runtime_error("DispEventAdvise() failed");
75 } 75 }
76 } 76 }
77 77
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 return false; 123 return false;
124 } 124 }
125 return true; 125 return true;
126 } 126 }
127 127
128 void Stop() // noexcept 128 void Stop() // noexcept
129 { 129 {
130 impl.reset(); 130 impl.reset();
131 } 131 }
132 }; 132 };
133
134 class ATL_NO_VTABLE CPluginClass : 133 class ATL_NO_VTABLE CPluginClass :
135 public ATL::CComObjectRootEx<ATL::CComMultiThreadModel>, 134 public ATL::CComObjectRootEx<ATL::CComMultiThreadModel>,
136 public ATL::CComCoClass<CPluginClass, &CLSID_PluginClass>, 135 public ATL::CComCoClass<CPluginClass, &CLSID_PluginClass>,
137 public ATL::IObjectWithSiteImpl<CPluginClass>, 136 public ATL::IObjectWithSiteImpl<CPluginClass>,
138 public IOleCommandTarget, 137 public IOleCommandTarget,
139 public ATL::IDispEventImpl<1, CPluginClass, &DIID_DWebBrowserEvents2, &LIBID_S HDocVw, 1, 1> 138 public ATL::IDispEventImpl<1, CPluginClass, &DIID_DWebBrowserEvents2, &LIBID_S HDocVw, 1, 1>
140 { 139 {
141 140
142 friend class CPluginTab; 141 friend class CPluginTab;
143 142
(...skipping 24 matching lines...) Expand all
168 ~CPluginClass(); 167 ~CPluginClass();
169 168
170 // IObjectWithSite 169 // IObjectWithSite
171 STDMETHOD(SetSite)(IUnknown *pUnkSite); 170 STDMETHOD(SetSite)(IUnknown *pUnkSite);
172 171
173 // IOleCommandTarget 172 // IOleCommandTarget
174 STDMETHOD(QueryStatus)(const GUID* pguidCmdGroup, ULONG cCmds, OLECMD prgCmds[ ], OLECMDTEXT* pCmdText); 173 STDMETHOD(QueryStatus)(const GUID* pguidCmdGroup, ULONG cCmds, OLECMD prgCmds[ ], OLECMDTEXT* pCmdText);
175 STDMETHOD(Exec)(const GUID*, DWORD nCmdID, DWORD, VARIANTARG*, VARIANTARG* pva Out); 174 STDMETHOD(Exec)(const GUID*, DWORD nCmdID, DWORD, VARIANTARG*, VARIANTARG* pva Out);
176 175
177 176
178 static CPluginTab* GetTab(DWORD dwThreadId); 177 static CPluginTab* GetTabForCurrentThread();
179 CPluginTab* GetTab(); 178 CPluginTab* GetTab();
180 179
181 void UpdateStatusBar(); 180 void UpdateStatusBar();
182 181
183 private: 182 private:
184 183
185 bool SetMenuBar(HMENU hMenu, const std::wstring& url); 184 bool SetMenuBar(HMENU hMenu, const std::wstring& url);
186 HMENU CreatePluginMenu(const std::wstring& url); 185 HMENU CreatePluginMenu(const std::wstring& url);
187 186
188 void DisplayPluginMenu(HMENU hMenu, int nToolbarCmdID, POINT pt, UINT nMenuFla gs); 187 void DisplayPluginMenu(HMENU hMenu, int nToolbarCmdID, POINT pt, UINT nMenuFla gs);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 static DWORD s_hIconTypes[ICON_MAX]; 260 static DWORD s_hIconTypes[ICON_MAX];
262 261
263 static HICON GetIcon(int type); 262 static HICON GetIcon(int type);
264 263
265 // Main thread 264 // Main thread
266 static HANDLE s_hMainThread; 265 static HANDLE s_hMainThread;
267 static bool s_isMainThreadDone; 266 static bool s_isMainThreadDone;
268 267
269 static HINSTANCE s_hUxtheme; 268 static HINSTANCE s_hUxtheme;
270 static std::set<CPluginClass*> s_instances; 269 static std::set<CPluginClass*> s_instances;
271 static std::map<DWORD,CPluginClass*> s_threadInstances;
272 static CComAutoCriticalSection s_criticalSectionLocal; 270 static CComAutoCriticalSection s_criticalSectionLocal;
273 static CComAutoCriticalSection s_criticalSectionWindow; 271 static CComAutoCriticalSection s_criticalSectionWindow;
274 272
275 // Async browser 273 // Async browser
276 static CComQIPtr<IWebBrowser2> s_asyncWebBrowser2; 274 static CComQIPtr<IWebBrowser2> s_asyncWebBrowser2;
277 static CComQIPtr<IWebBrowser2> GetAsyncBrowser(); 275 static CComQIPtr<IWebBrowser2> GetAsyncBrowser();
278 }; 276 };
279 277
280 OBJECT_ENTRY_AUTO(__uuidof(PluginClass), CPluginClass) 278 OBJECT_ENTRY_AUTO(__uuidof(PluginClass), CPluginClass)
281 279
282
283 #endif // _PLUGIN_CLASS_H_ 280 #endif // _PLUGIN_CLASS_H_
LEFTRIGHT

Powered by Google App Engine
This is Rietveld