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

Side by Side Diff: src/plugin/passthroughapp/ProtocolImpl.h

Issue 29332980: Issue #1484 - Use the currently distributed version of PassthroughAPP unaltered
Patch Set: use OnStartEx() instead of OnStart() Created Dec. 23, 2015, 3:18 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 // Copyright 2007 Igor Tandetnik
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #ifndef PASSTHROUGHAPP_PROTOCOLIMPL_H 1 #ifndef PASSTHROUGHAPP_PROTOCOLIMPL_H
16 #define PASSTHROUGHAPP_PROTOCOLIMPL_H 2 #define PASSTHROUGHAPP_PROTOCOLIMPL_H
17 3
18 #if _MSC_VER > 1000 4 #if _MSC_VER > 1000
19 #pragma once 5 » #pragma once
20 #endif // _MSC_VER > 1000 6 #endif // _MSC_VER > 1000
21 7
22 #include <urlmon.h> 8 #include <urlmon.h>
23 #pragma comment(lib, "urlmon.lib") 9 #pragma comment(lib, "urlmon.lib")
24 10
11 #include "PassthroughObject.h"
12
25 namespace PassthroughAPP 13 namespace PassthroughAPP
26 { 14 {
27 15
28 namespace Detail 16 namespace Detail
29 { 17 {
30 struct PassthroughItfData 18
31 { 19 struct PassthroughItfData
32 DWORD_PTR offsetItf; 20 {
33 DWORD_PTR offsetUnk; 21 » DWORD_PTR offsetItf;
34 const IID* piidBase; 22 » DWORD_PTR offsetUnk;
35 }; 23 » const IID* piidBase;
36 24 };
37 template <class itf, class impl, DWORD_PTR offsetUnk, const IID* piidBase> 25
38 struct PassthroughItfHelper 26 template <class itf, class impl, DWORD_PTR offsetUnk, const IID* piidBase>
39 { 27 struct PassthroughItfHelper
40 static PassthroughItfData data; 28 {
41 }; 29 » static PassthroughItfData data;
42 30 };
43 template <class itf, class impl, DWORD_PTR offsetUnk, const IID* piidBase> 31
44 PassthroughItfData 32 template <class itf, class impl, DWORD_PTR offsetUnk, const IID* piidBase>
45 PassthroughItfHelper<itf, impl, offsetUnk, piidBase>:: 33 PassthroughItfData
46 data = {offsetofclass(itf, impl), offsetUnk, piidBase}; 34 » PassthroughItfHelper<itf, impl, offsetUnk, piidBase>::
35 » » » data = {offsetofclass(itf, impl), offsetUnk, piidBase};
47 36
48 #define COM_INTERFACE_ENTRY_PASSTHROUGH(itf, punk)\ 37 #define COM_INTERFACE_ENTRY_PASSTHROUGH(itf, punk)\
49 {&_ATL_IIDOF(itf),\ 38 » {&_ATL_IIDOF(itf),\
50 (DWORD_PTR)&::PassthroughAPP::Detail::PassthroughItfHelper<\ 39 » (DWORD_PTR)&::PassthroughAPP::Detail::PassthroughItfHelper<\
51 itf, _ComMapClass,\ 40 » » itf, _ComMapClass,\
52 (DWORD_PTR)offsetof(_ComMapClass, punk),\ 41 » » (DWORD_PTR)offsetof(_ComMapClass, punk),\
53 0\ 42 » » 0\
54 >::data,\ 43 » >::data,\
55 ::PassthroughAPP::Detail::QIPassthrough<_ComMapClass>::\ 44 » ::PassthroughAPP::Detail::QIPassthrough<_ComMapClass>::\
56 QueryInterfacePassthroughT\ 45 » » QueryInterfacePassthroughT\
57 }, 46 » },
58 47
59 #define COM_INTERFACE_ENTRY_PASSTHROUGH2(itf, punk, itfBase)\ 48 #define COM_INTERFACE_ENTRY_PASSTHROUGH2(itf, punk, itfBase)\
60 {&_ATL_IIDOF(itf),\ 49 » {&_ATL_IIDOF(itf),\
61 (DWORD_PTR)&::PassthroughAPP::Detail::PassthroughItfHelper<\ 50 » (DWORD_PTR)&::PassthroughAPP::Detail::PassthroughItfHelper<\
62 itf, _ComMapClass,\ 51 » » itf, _ComMapClass,\
63 (DWORD_PTR)offsetof(_ComMapClass, punk),\ 52 » » (DWORD_PTR)offsetof(_ComMapClass, punk),\
64 &_ATL_IIDOF(itfBase)\ 53 » » &_ATL_IIDOF(itfBase)\
65 >::data,\ 54 » >::data,\
66 ::PassthroughAPP::Detail::QIPassthrough<_ComMapClass>::\ 55 » ::PassthroughAPP::Detail::QIPassthrough<_ComMapClass>::\
67 QueryInterfacePassthroughT\ 56 » » QueryInterfacePassthroughT\
68 }, 57 » },
69 58
70 59
71 #ifdef DEBUG 60 #ifdef DEBUG
72 61
73 #define COM_INTERFACE_ENTRY_PASSTHROUGH_DEBUG()\ 62 » #define COM_INTERFACE_ENTRY_PASSTHROUGH_DEBUG()\
74 {0, 0,\ 63 » » {0, 0,\
75 ::PassthroughAPP::Detail::QIPassthrough<_ComMapClass>::\ 64 » » ::PassthroughAPP::Detail::QIPassthrough<_ComMapClass>::\
76 QueryInterfaceDebugT\ 65 » » » QueryInterfaceDebugT\
77 }, 66 » » },
78 67
79 #else 68 #else
80 #define COM_INTERFACE_ENTRY_PASSTHROUGH_DEBUG() 69 » #define COM_INTERFACE_ENTRY_PASSTHROUGH_DEBUG()
81 #endif 70 #endif
82 71
83 #define DECLARE_GET_TARGET_UNKNOWN(x) \ 72 #define DECLARE_GET_TARGET_UNKNOWN(x) \
84 inline IUnknown* GetTargetUnknown() {return x;} 73 inline IUnknown* GetTargetUnknown() {return x;}
85 74
86 // Workaround for VC6's deficiencies in dealing with function templates. 75 // Workaround for VC6's deficiencies in dealing with function templates.
87 // We'd use non-member template functions, but VC6 does not handle those wel l. 76 // We'd use non-member template functions, but VC6 does not handle those well.
88 // Static members of class templates work much better, and we don't need 77 // Static members of class templates work much better, and we don't need
89 // parameter deduction here 78 // parameter deduction here
90 template <class T> 79 template <class T>
91 struct QIPassthrough 80 struct QIPassthrough
92 { 81 {
93 static HRESULT WINAPI QueryInterfacePassthroughT(void* pv, REFIID riid, 82 static HRESULT WINAPI QueryInterfacePassthroughT(void* pv, REFIID riid,
94 LPVOID* ppv, DWORD_PTR dw); 83 LPVOID* ppv, DWORD_PTR dw);
95 static HRESULT WINAPI QueryInterfaceDebugT(void* pv, REFIID riid, 84 static HRESULT WINAPI QueryInterfaceDebugT(void* pv, REFIID riid,
96 LPVOID* ppv, DWORD_PTR dw); 85 LPVOID* ppv, DWORD_PTR dw);
97 }; 86 };
98 87
99 HRESULT WINAPI QueryInterfacePassthrough(void* pv, REFIID riid, 88 HRESULT WINAPI QueryInterfacePassthrough(void* pv, REFIID riid,
100 LPVOID* ppv, DWORD_PTR dw, IUnknown* punkTarget, IUnknown* punkWrapper); 89 LPVOID* ppv, DWORD_PTR dw, IUnknown* punkTarget, IUnknown* punkWrapper);
101 90
102 HRESULT WINAPI QueryInterfaceDebug(void* pv, REFIID riid, 91 HRESULT WINAPI QueryInterfaceDebug(void* pv, REFIID riid,
103 LPVOID* ppv, DWORD_PTR dw, IUnknown* punkTarget); 92 LPVOID* ppv, DWORD_PTR dw, IUnknown* punkTarget);
104 93
105 HRESULT QueryServicePassthrough(REFGUID guidService, 94 HRESULT QueryServicePassthrough(REFGUID guidService,
106 IUnknown* punkThis, REFIID riid, void** ppv, 95 IUnknown* punkThis, REFIID riid, void** ppv,
107 IServiceProvider* pClientProvider); 96 IServiceProvider* pClientProvider);
108 97
109 } // end namespace PassthroughAPP::Detail 98 } // end namespace PassthroughAPP::Detail
110 99
111 class ATL_NO_VTABLE IInternetProtocolImpl : 100 class ATL_NO_VTABLE IInternetProtocolImpl :
112 public IPassthroughObject, 101 public IPassthroughObject,
113 public IInternetProtocol, 102 public IInternetProtocolEx,
114 public IInternetProtocolInfo, 103 public IInternetProtocolInfo,
115 public IInternetPriority, 104 public IInternetPriority,
116 public IInternetThreadSwitch, 105 public IInternetThreadSwitch,
117 public IWinInetHttpInfo 106 public IWinInetHttpInfo,
118 { 107 public IWinInetCacheHints2
119 public: 108 {
120 void ReleaseAll(); 109 public:
121 110 void ReleaseAll();
122 DECLARE_GET_TARGET_UNKNOWN(m_spInternetProtocolUnk) 111
123 public: 112 DECLARE_GET_TARGET_UNKNOWN(m_spInternetProtocolUnk)
124 // IPassthroughObject 113 public:
125 STDMETHODIMP SetTargetUnknown(IUnknown* punkTarget); 114 // IPassthroughObject
126 115 STDMETHODIMP SetTargetUnknown(IUnknown* punkTarget);
127 // IInternetProtocolRoot 116
128 STDMETHODIMP Start( 117 // IInternetProtocolRoot
129 /* [in] */ LPCWSTR szUrl, 118 STDMETHODIMP Start(
130 /* [in] */ IInternetProtocolSink *pOIProtSink, 119 /* [in] */ LPCWSTR szUrl,
131 /* [in] */ IInternetBindInfo *pOIBindInfo, 120 /* [in] */ IInternetProtocolSink *pOIProtSink,
132 /* [in] */ DWORD grfPI, 121 /* [in] */ IInternetBindInfo *pOIBindInfo,
133 /* [in] */ HANDLE_PTR dwReserved); 122 /* [in] */ DWORD grfPI,
134 123 /* [in] */ HANDLE_PTR dwReserved);
135 STDMETHODIMP Continue( 124
136 /* [in] */ PROTOCOLDATA *pProtocolData); 125 STDMETHODIMP Continue(
137 126 /* [in] */ PROTOCOLDATA *pProtocolData);
138 STDMETHODIMP Abort( 127
139 /* [in] */ HRESULT hrReason, 128 STDMETHODIMP Abort(
140 /* [in] */ DWORD dwOptions); 129 /* [in] */ HRESULT hrReason,
141 130 /* [in] */ DWORD dwOptions);
142 STDMETHODIMP Terminate( 131
143 /* [in] */ DWORD dwOptions); 132 STDMETHODIMP Terminate(
144 133 /* [in] */ DWORD dwOptions);
145 STDMETHODIMP Suspend(); 134
146 135 STDMETHODIMP Suspend();
147 STDMETHODIMP Resume(); 136
148 137 STDMETHODIMP Resume();
149 // IInternetProtocol 138
150 STDMETHODIMP Read( 139 // IInternetProtocol
151 /* [in, out] */ void *pv, 140 STDMETHODIMP Read(
152 /* [in] */ ULONG cb, 141 /* [in, out] */ void *pv,
153 /* [out] */ ULONG *pcbRead); 142 /* [in] */ ULONG cb,
154 143 /* [out] */ ULONG *pcbRead);
155 STDMETHODIMP Seek( 144
156 /* [in] */ LARGE_INTEGER dlibMove, 145 STDMETHODIMP Seek(
157 /* [in] */ DWORD dwOrigin, 146 /* [in] */ LARGE_INTEGER dlibMove,
158 /* [out] */ ULARGE_INTEGER *plibNewPosition); 147 /* [in] */ DWORD dwOrigin,
159 148 /* [out] */ ULARGE_INTEGER *plibNewPosition);
160 STDMETHODIMP LockRequest( 149
161 /* [in] */ DWORD dwOptions); 150 STDMETHODIMP LockRequest(
162 151 /* [in] */ DWORD dwOptions);
163 STDMETHODIMP UnlockRequest(); 152
164 153 STDMETHODIMP UnlockRequest();
165 // IInternetProtocolInfo 154
166 STDMETHODIMP ParseUrl( 155 // IInternetProtocolEx
167 /* [in] */ LPCWSTR pwzUrl, 156 STDMETHODIMP StartEx(
168 /* [in] */ PARSEACTION ParseAction, 157 IUri *pUri,
169 /* [in] */ DWORD dwParseFlags, 158 IInternetProtocolSink *pOIProtSink,
170 /* [out] */ LPWSTR pwzResult, 159 IInternetBindInfo *pOIBindInfo,
171 /* [in] */ DWORD cchResult, 160 DWORD grfPI,
172 /* [out] */ DWORD *pcchResult, 161 HANDLE_PTR dwReserved);
173 /* [in] */ DWORD dwReserved); 162
174 163 // IInternetProtocolInfo
175 STDMETHODIMP CombineUrl( 164 STDMETHODIMP ParseUrl(
176 /* [in] */ LPCWSTR pwzBaseUrl, 165 /* [in] */ LPCWSTR pwzUrl,
177 /* [in] */ LPCWSTR pwzRelativeUrl, 166 /* [in] */ PARSEACTION ParseAction,
178 /* [in] */ DWORD dwCombineFlags, 167 /* [in] */ DWORD dwParseFlags,
179 /* [out] */ LPWSTR pwzResult, 168 /* [out] */ LPWSTR pwzResult,
180 /* [in] */ DWORD cchResult, 169 /* [in] */ DWORD cchResult,
181 /* [out] */ DWORD *pcchResult, 170 /* [out] */ DWORD *pcchResult,
182 /* [in] */ DWORD dwReserved); 171 /* [in] */ DWORD dwReserved);
183 172
184 STDMETHODIMP CompareUrl( 173 STDMETHODIMP CombineUrl(
185 /* [in] */ LPCWSTR pwzUrl1, 174 /* [in] */ LPCWSTR pwzBaseUrl,
186 /* [in] */ LPCWSTR pwzUrl2, 175 /* [in] */ LPCWSTR pwzRelativeUrl,
187 /* [in] */ DWORD dwCompareFlags); 176 /* [in] */ DWORD dwCombineFlags,
188 177 /* [out] */ LPWSTR pwzResult,
189 STDMETHODIMP QueryInfo( 178 /* [in] */ DWORD cchResult,
190 /* [in] */ LPCWSTR pwzUrl, 179 /* [out] */ DWORD *pcchResult,
191 /* [in] */ QUERYOPTION QueryOption, 180 /* [in] */ DWORD dwReserved);
192 /* [in] */ DWORD dwQueryFlags, 181
193 /* [in, out] */ LPVOID pBuffer, 182 STDMETHODIMP CompareUrl(
194 /* [in] */ DWORD cbBuffer, 183 /* [in] */ LPCWSTR pwzUrl1,
195 /* [in, out] */ DWORD *pcbBuf, 184 /* [in] */ LPCWSTR pwzUrl2,
196 /* [in] */ DWORD dwReserved); 185 /* [in] */ DWORD dwCompareFlags);
197 186
198 // IInternetPriority 187 STDMETHODIMP QueryInfo(
199 STDMETHODIMP SetPriority( 188 /* [in] */ LPCWSTR pwzUrl,
200 /* [in] */ LONG nPriority); 189 /* [in] */ QUERYOPTION QueryOption,
201 190 /* [in] */ DWORD dwQueryFlags,
202 STDMETHODIMP GetPriority( 191 /* [in, out] */ LPVOID pBuffer,
203 /* [out] */ LONG *pnPriority); 192 /* [in] */ DWORD cbBuffer,
204 193 /* [in, out] */ DWORD *pcbBuf,
205 // IInternetThreadSwitch 194 /* [in] */ DWORD dwReserved);
206 STDMETHODIMP Prepare(); 195
207 196 // IInternetPriority
208 STDMETHODIMP Continue(); 197 STDMETHODIMP SetPriority(
209 198 /* [in] */ LONG nPriority);
210 // IWinInetInfo 199
211 STDMETHODIMP QueryOption( 200 STDMETHODIMP GetPriority(
212 /* [in] */ DWORD dwOption, 201 /* [out] */ LONG *pnPriority);
213 /* [in, out] */ LPVOID pBuffer, 202
214 /* [in, out] */ DWORD *pcbBuf); 203 // IInternetThreadSwitch
215 204 STDMETHODIMP Prepare();
216 // IWinInetHttpInfo 205
217 STDMETHODIMP QueryInfo( 206 STDMETHODIMP Continue();
218 /* [in] */ DWORD dwOption, 207
219 /* [in, out] */ LPVOID pBuffer, 208 // IWinInetInfo
220 /* [in, out] */ DWORD *pcbBuf, 209 STDMETHODIMP QueryOption(
221 /* [in, out] */ DWORD *pdwFlags, 210 /* [in] */ DWORD dwOption,
222 /* [in, out] */ DWORD *pdwReserved); 211 /* [in, out] */ LPVOID pBuffer,
223 212 /* [in, out] */ DWORD *pcbBuf);
224 public: 213
225 CComPtr<IUnknown> m_spInternetProtocolUnk; 214 // IWinInetHttpInfo
226 CComPtr<IInternetProtocol> m_spInternetProtocol; 215 STDMETHODIMP QueryInfo(
227 CComPtr<IInternetProtocolInfo> m_spInternetProtocolInfo; 216 /* [in] */ DWORD dwOption,
228 CComPtr<IInternetPriority> m_spInternetPriority; 217 /* [in, out] */ LPVOID pBuffer,
229 CComPtr<IInternetThreadSwitch> m_spInternetThreadSwitch; 218 /* [in, out] */ DWORD *pcbBuf,
230 CComPtr<IWinInetInfo> m_spWinInetInfo; 219 /* [in, out] */ DWORD *pdwFlags,
231 CComPtr<IWinInetHttpInfo> m_spWinInetHttpInfo; 220 /* [in, out] */ DWORD *pdwReserved);
232 }; 221
233 222 // IWinInetCacheHints
234 class ATL_NO_VTABLE IInternetProtocolSinkImpl : 223 STDMETHODIMP SetCacheExtension(
235 public IInternetProtocolSink, 224 /* [in] */ LPCWSTR pwzExt,
236 public IServiceProvider 225 /* [in, out] */ LPVOID pszCacheFile,
237 { 226 /* [in, out] */ DWORD *pcbCacheFile,
238 public: 227 /* [in, out] */ DWORD *pdwWinInetError,
239 HRESULT OnStart(LPCWSTR szUrl, IInternetProtocolSink *pOIProtSink, 228 /* [in, out] */ DWORD *pdwReserved);
240 IInternetBindInfo *pOIBindInfo, DWORD grfPI, HANDLE_PTR dwReserved, 229
241 IInternetProtocol* pTargetProtocol); 230 // IWinInetCacheHints2
242 void ReleaseAll(); 231 STDMETHODIMP SetCacheExtension2(
243 232 /* [in] */ LPCWSTR pwzExt,
244 DECLARE_GET_TARGET_UNKNOWN(m_spInternetProtocolSink) 233 /* [out] */ WCHAR *pwzCacheFile,
245 234 /* [in, out] */ DWORD *pcchCacheFile,
246 IServiceProvider* GetClientServiceProvider(); 235 /* [out] */ DWORD *pdwWinInetError,
247 236 /* [out] */ DWORD *pdwReserved);
248 HRESULT QueryServiceFromClient(REFGUID guidService, REFIID riid, 237
249 void** ppvObject); 238 public:
250 template <class Q> 239 CComPtr<IUnknown> m_spInternetProtocolUnk;
251 HRESULT QueryServiceFromClient(REFGUID guidService, Q** pp) 240 CComPtr<IInternetProtocol> m_spInternetProtocol;
252 { 241 CComPtr<IInternetProtocolEx> m_spInternetProtocolEx;
253 return QueryServiceFromClient(guidService, _ATL_IIDOF(Q), 242 CComPtr<IInternetProtocolInfo> m_spInternetProtocolInfo;
254 reinterpret_cast<void**>(pp)); 243 CComPtr<IInternetPriority> m_spInternetPriority;
255 } 244 CComPtr<IInternetThreadSwitch> m_spInternetThreadSwitch;
256 template <class Q> 245 CComPtr<IWinInetInfo> m_spWinInetInfo;
257 HRESULT QueryServiceFromClient(Q** pp) 246 CComPtr<IWinInetHttpInfo> m_spWinInetHttpInfo;
258 { 247 CComPtr<IWinInetCacheHints> m_spWinInetCacheHints;
259 return QueryServiceFromClient(_ATL_IIDOF(Q), _ATL_IIDOF(Q), 248 CComPtr<IWinInetCacheHints2> m_spWinInetCacheHints2;
260 reinterpret_cast<void**>(pp)); 249 };
261 } 250
262 public: 251 class ATL_NO_VTABLE IInternetProtocolSinkImpl :
263 // IInternetProtocolSink 252 public IInternetProtocolSink,
264 STDMETHODIMP Switch( 253 public IServiceProvider,
265 /* [in] */ PROTOCOLDATA *pProtocolData); 254 public IInternetBindInfoEx,
266 255 public IUriContainer
267 STDMETHODIMP ReportProgress( 256 {
268 /* [in] */ ULONG ulStatusCode, 257 public:
269 /* [in] */ LPCWSTR szStatusText); 258 HRESULT OnStart(LPCWSTR szUrl, IInternetProtocolSink *pOIProtSink,
270 259 IInternetBindInfo *pOIBindInfo, DWORD grfPI, HANDLE_PTR dwReserv ed,
271 STDMETHODIMP ReportData( 260 IInternetProtocol* pTargetProtocol);
272 /* [in] */ DWORD grfBSCF, 261 HRESULT OnStartEx(IUri* pUri, IInternetProtocolSink *pOIProtSink,
273 /* [in] */ ULONG ulProgress, 262 IInternetBindInfo *pOIBindInfo, DWORD grfPI, HANDLE_PTR dwReserv ed,
274 /* [in] */ ULONG ulProgressMax); 263 IInternetProtocol* pTargetProtocol);
275 264 void ReleaseAll();
276 STDMETHODIMP ReportResult( 265
277 /* [in] */ HRESULT hrResult, 266 DECLARE_GET_TARGET_UNKNOWN(m_spInternetProtocolSink)
278 /* [in] */ DWORD dwError, 267
279 /* [in] */ LPCWSTR szResult); 268 IServiceProvider* GetClientServiceProvider();
280 269
281 // IServiceProvider 270 HRESULT QueryServiceFromClient(REFGUID guidService, REFIID riid,
282 STDMETHODIMP QueryService( 271 void** ppvObject);
283 /* [in] */ REFGUID guidService, 272 template <class Q>
284 /* [in] */ REFIID riid, 273 HRESULT QueryServiceFromClient(REFGUID guidService, Q** pp)
285 /* [out] */ void** ppvObject); 274 {
286 275 return QueryServiceFromClient(guidService, _ATL_IIDOF(Q),
287 public: 276 reinterpret_cast<void**>(pp));
288 CComPtr<IInternetProtocolSink> m_spInternetProtocolSink; 277 }
289 CComPtr<IServiceProvider> m_spServiceProvider; 278 template <class Q>
290 CComPtr<IInternetProtocol> m_spTargetProtocol; 279 HRESULT QueryServiceFromClient(Q** pp)
291 }; 280 {
292 281 return QueryServiceFromClient(_ATL_IIDOF(Q), _ATL_IIDOF(Q),
293 template <class ThreadModel> 282 reinterpret_cast<void**>(pp));
294 class CInternetProtocolSinkTM : 283 }
295 public CComObjectRootEx<ThreadModel>, 284 public:
296 public IInternetProtocolSinkImpl 285 // IInternetProtocolSink
297 { 286 STDMETHODIMP Switch(
298 private: 287 /* [in] */ PROTOCOLDATA *pProtocolData);
288
289 STDMETHODIMP ReportProgress(
290 /* [in] */ ULONG ulStatusCode,
291 /* [in] */ LPCWSTR szStatusText);
292
293 STDMETHODIMP ReportData(
294 /* [in] */ DWORD grfBSCF,
295 /* [in] */ ULONG ulProgress,
296 /* [in] */ ULONG ulProgressMax);
297
298 STDMETHODIMP ReportResult(
299 /* [in] */ HRESULT hrResult,
300 /* [in] */ DWORD dwError,
301 /* [in] */ LPCWSTR szResult);
302
303 // IServiceProvider
304 STDMETHODIMP QueryService(
305 /* [in] */ REFGUID guidService,
306 /* [in] */ REFIID riid,
307 /* [out] */ void** ppvObject);
308
309 // IInternetBindInfo
310 STDMETHODIMP GetBindInfo(
311 /* [out] */ DWORD *grfBINDF,
312 /* [in, out] */ BINDINFO *pbindinfo);
313
314 STDMETHODIMP GetBindString(
315 /* [in] */ ULONG ulStringType,
316 /* [in, out] */ LPOLESTR *ppwzStr,
317 /* [in] */ ULONG cEl,
318 /* [in, out] */ ULONG *pcElFetched);
319
320 // IInternetBindInfoEx
321 STDMETHODIMP GetBindInfoEx(
322 DWORD *grfBINDF,
323 BINDINFO *pbindinfo,
324 DWORD *grfBINDF2,
325 DWORD *pdwReserved);
326
327 // IUriContainer
328 STDMETHODIMP GetIUri(
329 /* [out] */ IUri **ppIUri);
330
331 protected:
332 HRESULT InitMembers(IInternetProtocolSink *pOIProtSink, IInternetBindInf o *pOIBindInfo,
333 IInternetProtocol* pTargetProtocol);
334
335 public:
336 CComPtr<IInternetProtocolSink> m_spInternetProtocolSink;
337 CComPtr<IServiceProvider> m_spServiceProvider;
338 CComPtr<IInternetBindInfo> m_spInternetBindInfo;
339 CComPtr<IInternetBindInfoEx> m_spInternetBindInfoEx;
340 CComPtr<IUriContainer> m_spUriContainer;
341
342 CComPtr<IInternetProtocol> m_spTargetProtocol;
343 };
344
345 template <class ThreadModel = CComMultiThreadModel>
346 class CInternetProtocolSinkTM :
347 public CComObjectRootEx<ThreadModel>,
348 public IInternetProtocolSinkImpl
349 {
350 private:
299 static HRESULT WINAPI OnDelegateIID(void* pv, REFIID riid, LPVOID* ppv, DWORD_PTR dw) 351 static HRESULT WINAPI OnDelegateIID(void* pv, REFIID riid, LPVOID* ppv, DWORD_PTR dw)
300 { 352 {
301 IInternetProtocolSink* pSink = ((CInternetProtocolSinkTM<ThreadM odel> *) pv)->m_spInternetProtocolSink; 353 IInternetProtocolSink* pSink = ((CInternetProtocolSinkTM<ThreadM odel> *) pv)->m_spInternetProtocolSink;
302 ATLASSERT(pSink != 0); 354 ATLASSERT(pSink != 0);
303 return pSink ? pSink->QueryInterface(riid, ppv) : E_UNEXPECTED; 355 return pSink ? pSink->QueryInterface(riid, ppv) : E_UNEXPECTED;
304 } 356 }
305 357
306 public: 358 public:
307 BEGIN_COM_MAP(CInternetProtocolSinkTM) 359 » BEGIN_COM_MAP(CInternetProtocolSinkTM)
308 COM_INTERFACE_ENTRY(IInternetProtocolSink) 360 » » COM_INTERFACE_ENTRY(IInternetProtocolSink)
309 COM_INTERFACE_ENTRY_PASSTHROUGH(IServiceProvider, 361 » » COM_INTERFACE_ENTRY_PASSTHROUGH(IServiceProvider,
310 m_spServiceProvider.p) 362 » » » m_spServiceProvider.p)
311 » COM_INTERFACE_ENTRY_FUNC_BLIND(0, OnDelegateIID) 363 » » COM_INTERFACE_ENTRY(IInternetBindInfo)
312 COM_INTERFACE_ENTRY_PASSTHROUGH_DEBUG() 364 » » COM_INTERFACE_ENTRY(IInternetBindInfoEx)
313 END_COM_MAP() 365 » » COM_INTERFACE_ENTRY_PASSTHROUGH(IUriContainer, m_spUriContainer. p)
366 » » COM_INTERFACE_ENTRY_FUNC_BLIND(0, OnDelegateIID)
367 » » COM_INTERFACE_ENTRY_PASSTHROUGH_DEBUG()
368 » END_COM_MAP()
369 };
314 370
315 }; 371 typedef CInternetProtocolSinkTM<> CInternetProtocolSink;
316 372
317 typedef CInternetProtocolSinkTM<CComMultiThreadModel> CInternetProtocolSink; 373 template <class T, class ThreadModel = CComMultiThreadModel>
374 class CInternetProtocolSinkWithSP :
375 » public CInternetProtocolSinkTM<ThreadModel>
376 {
377 » typedef CInternetProtocolSinkTM<ThreadModel> BaseClass;
378 public:
379 » HRESULT OnStart(LPCWSTR szUrl, IInternetProtocolSink *pOIProtSink,
380 » » IInternetBindInfo *pOIBindInfo, DWORD grfPI, HANDLE_PTR dwReserv ed,
381 » » IInternetProtocol* pTargetProtocol);
382 » HRESULT OnStartEx(IUri* pUri, IInternetProtocolSink *pOIProtSink,
383 » » IInternetBindInfo *pOIBindInfo, DWORD grfPI, HANDLE_PTR dwReserv ed,
384 » » IInternetProtocol* pTargetProtocol);
318 385
319 template <class T, class ThreadModel = CComMultiThreadModel> 386 » STDMETHODIMP QueryService(REFGUID guidService, REFIID riid, void** ppv);
320 class CInternetProtocolSinkWithSP :
321 public CInternetProtocolSinkTM<ThreadModel>
322 {
323 typedef CInternetProtocolSinkTM<ThreadModel> BaseClass;
324 public:
325 HRESULT OnStart(LPCWSTR szUrl, IInternetProtocolSink *pOIProtSink,
326 IInternetBindInfo *pOIBindInfo, DWORD grfPI, HANDLE_PTR dwReserved,
327 IInternetProtocol* pTargetProtocol);
328 387
329 STDMETHODIMP QueryService(REFGUID guidService, REFIID riid, void** ppv); 388 » HRESULT _InternalQueryService(REFGUID guidService, REFIID riid,
389 » » void** ppvObject);
330 390
331 HRESULT _InternalQueryService(REFGUID guidService, REFIID riid, 391 » BEGIN_COM_MAP(CInternetProtocolSinkWithSP)
332 void** ppvObject); 392 » » COM_INTERFACE_ENTRY(IServiceProvider)
333 393 » » COM_INTERFACE_ENTRY_CHAIN(BaseClass)
334 BEGIN_COM_MAP(CInternetProtocolSinkWithSP) 394 » END_COM_MAP()
335 COM_INTERFACE_ENTRY(IServiceProvider) 395 };
336 COM_INTERFACE_ENTRY_CHAIN(BaseClass)
337 END_COM_MAP()
338 };
339 396
340 #define SERVICE_ENTRY_PASSTHROUGH(x) \ 397 #define SERVICE_ENTRY_PASSTHROUGH(x) \
341 if (InlineIsEqualGUID(guidService, x)) \ 398 » if (InlineIsEqualGUID(guidService, x)) \
342 { \ 399 » { \
343 return ::PassthroughAPP::Detail::QueryServicePassthrough(guidService, \ 400 » » return ::PassthroughAPP::Detail::QueryServicePassthrough(guidSer vice, \
344 GetUnknown(), riid, ppvObject, GetClientServiceProvider()); \ 401 » » » GetUnknown(), riid, ppvObject, GetClientServiceProvider( )); \
345 } 402 » }
346 403
347 struct __declspec(uuid("C7A98E66-1010-492c-A1C8-C809E1F75905")) IInternetProto colEx; 404 template <class StartPolicy, class ThreadModel = CComMultiThreadModel>
405 class ATL_NO_VTABLE CInternetProtocol :
406 » public CComObjectRootEx<ThreadModel>,
407 » public IInternetProtocolImpl,
408 » public StartPolicy
409 {
410 private:
411 » static HRESULT WINAPI OnDelegateIID(void* pv, REFIID riid, LPVOID* ppv, DWORD_PTR dw)
412 » {
413 » » IInternetProtocol* pProtocol = ((CInternetProtocol<StartPolicy, ThreadModel> *) pv)->m_spInternetProtocol;
414 » » ATLASSERT(pProtocol != 0);
415 » » return pProtocol ? pProtocol->QueryInterface(riid, ppv) : E_UNEX PECTED;
416 » }
348 417
349 template <class StartPolicy, class ThreadModel = CComMultiThreadModel> 418 public:
350 class ATL_NO_VTABLE CInternetProtocol : 419 » BEGIN_COM_MAP(CInternetProtocol)
351 public CComObjectRootEx<ThreadModel>, 420 » » COM_INTERFACE_ENTRY(IPassthroughObject)
352 public IInternetProtocolImpl, 421 » » COM_INTERFACE_ENTRY(IInternetProtocolRoot)
353 public StartPolicy 422 » » COM_INTERFACE_ENTRY(IInternetProtocol)
354 { 423 » » COM_INTERFACE_ENTRY(IInternetProtocolEx)
355 private: 424 » » COM_INTERFACE_ENTRY_PASSTHROUGH(IInternetProtocolInfo,
356 static HRESULT WINAPI OnDelegateIID(void* pv, REFIID riid, LPVOID* ppv, DWOR D_PTR dw) 425 » » » m_spInternetProtocolInfo.p)
357 { 426 » » COM_INTERFACE_ENTRY_PASSTHROUGH(IInternetPriority,
358 IInternetProtocol* pProtocol = ((CInternetProtocol<StartPolicy, ThreadMode l> *) pv)->m_spInternetProtocol; 427 » » » m_spInternetPriority.p)
359 ATLASSERT(pProtocol != 0); 428 » » COM_INTERFACE_ENTRY_PASSTHROUGH(IInternetThreadSwitch,
360 // TODO: don't need this once we support IInternetProtocolEx 429 » » » m_spInternetThreadSwitch.p)
361 if (InlineIsEqualGUID(riid, __uuidof(IInternetProtocolEx))) return E_NOINT ERFACE; 430 » » COM_INTERFACE_ENTRY_PASSTHROUGH(IWinInetInfo, m_spWinInetInfo.p)
362 return pProtocol ? pProtocol->QueryInterface(riid, ppv) : E_UNEXPECTED; 431 » » COM_INTERFACE_ENTRY_PASSTHROUGH2(IWinInetHttpInfo,
363 } 432 » » » m_spWinInetHttpInfo.p, IWinInetInfo)
364 public: 433 » » COM_INTERFACE_ENTRY_PASSTHROUGH(IWinInetCacheHints,
365 BEGIN_COM_MAP(CInternetProtocol) 434 » » » m_spWinInetCacheHints.p)
366 COM_INTERFACE_ENTRY(IPassthroughObject) 435 » » COM_INTERFACE_ENTRY_PASSTHROUGH2(IWinInetCacheHints2,
367 COM_INTERFACE_ENTRY(IInternetProtocolRoot) 436 » » » m_spWinInetCacheHints2.p, IWinInetCacheHints)
368 COM_INTERFACE_ENTRY(IInternetProtocol) 437 » » COM_INTERFACE_ENTRY_FUNC_BLIND(0, OnDelegateIID)
369 COM_INTERFACE_ENTRY_PASSTHROUGH(IInternetProtocolInfo, 438 » » COM_INTERFACE_ENTRY_PASSTHROUGH_DEBUG()
370 m_spInternetProtocolInfo.p) 439 » END_COM_MAP()
371 COM_INTERFACE_ENTRY_PASSTHROUGH(IInternetPriority, 440
372 m_spInternetPriority.p) 441 » // IInternetProtocolRoot
373 COM_INTERFACE_ENTRY_PASSTHROUGH(IInternetThreadSwitch, 442 » STDMETHODIMP Start(LPCWSTR szUrl, IInternetProtocolSink *pOIProtSink,
374 m_spInternetThreadSwitch.p) 443 » » IInternetBindInfo *pOIBindInfo, DWORD grfPI, HANDLE_PTR dwReserv ed);
375 COM_INTERFACE_ENTRY_PASSTHROUGH(IWinInetInfo, m_spWinInetInfo.p) 444
376 COM_INTERFACE_ENTRY_PASSTHROUGH2(IWinInetHttpInfo, 445 » // IInternetProtocolEx
377 m_spWinInetHttpInfo.p, IWinInetInfo) 446 » STDMETHODIMP StartEx(IUri *pUri, IInternetProtocolSink *pOIProtSink,
378 COM_INTERFACE_ENTRY_FUNC_BLIND(0, OnDelegateIID) 447 » » IInternetBindInfo *pOIBindInfo, DWORD grfPI, HANDLE_PTR dwReserv ed);
379 COM_INTERFACE_ENTRY_PASSTHROUGH_DEBUG() 448 };
380 END_COM_MAP()
381 };
382 449
383 } // end namespace PassthroughAPP 450 } // end namespace PassthroughAPP
384 451
385 #include "ProtocolImpl.inl" 452 #include "ProtocolImpl.inl"
386 453
387 #include "SinkPolicy.h" 454 #include "SinkPolicy.h"
388 455
389 #endif // PASSTHROUGHAPP_PROTOCOLIMPL_H 456 #endif // PASSTHROUGHAPP_PROTOCOLIMPL_H
OLDNEW

Powered by Google App Engine
This is Rietveld