1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_FRAME_BIND_STATUS_CALLBACK_IMPL_H_
6 #define CHROME_FRAME_BIND_STATUS_CALLBACK_IMPL_H_
13 #include "base/win/scoped_comptr.h"
14 #include "chrome_frame/utils.h"
16 // A generic base class for IBindStatus callback implementation.
17 // If initialized with delegate, it will hand over all the calls
18 // to the delegate. This can also be used as a base class to
19 // provide the base implementation by not providing any delegate.
21 : public CComObjectRootEx
<CComMultiThreadModel
>,
22 public IBindStatusCallbackEx
,
23 public IHttpNegotiate3
,
24 public IServiceProvider
{
29 BEGIN_COM_MAP(BSCBImpl
)
30 COM_INTERFACE_ENTRY(IBindStatusCallback
)
31 COM_INTERFACE_ENTRY(IHttpNegotiate
)
32 COM_INTERFACE_ENTRY_IF_DELEGATE_SUPPORTS(IBindStatusCallbackEx
)
33 COM_INTERFACE_ENTRY_IF_DELEGATE_SUPPORTS(IHttpNegotiate2
)
34 COM_INTERFACE_ENTRY_IF_DELEGATE_SUPPORTS(IHttpNegotiate3
)
35 COM_INTERFACE_ENTRY_IF_DELEGATE_SUPPORTS(IServiceProvider
)
36 COM_INTERFACE_ENTRY_FUNC_BLIND(0, DelegateQI
)
39 static STDMETHODIMP
DelegateQI(void* obj
, REFIID iid
, void** ret
,
42 void Initialize(IBindStatusCallback
* original
);
43 HRESULT
AttachToBind(IBindCtx
* original
);
44 HRESULT
ReleaseBind();
46 // For the COM_INTERFACE_ENTRY_IF_DELEGATE_SUPPORTS macro.
47 IBindStatusCallback
* delegate() const {
51 IBindCtx
* bind_ctx() const {
56 STDMETHOD(QueryService
)(REFGUID service
, REFIID iid
, void** object
);
58 // IBindStatusCallback
59 STDMETHOD(OnStartBinding
)(DWORD reserved
, IBinding
* binding
);
60 STDMETHOD(GetPriority
)(LONG
* priority
);
61 STDMETHOD(OnLowResource
)(DWORD reserved
);
62 STDMETHOD(OnProgress
)(ULONG progress
, ULONG progress_max
, ULONG status_code
,
64 STDMETHOD(OnStopBinding
)(HRESULT hresult
, LPCWSTR error
);
65 STDMETHOD(GetBindInfo
)(DWORD
* bindf
, BINDINFO
* bind_info
);
66 STDMETHOD(OnDataAvailable
)(DWORD bscf
, DWORD size
, FORMATETC
* format_etc
,
68 STDMETHOD(OnObjectAvailable
)(REFIID iid
, IUnknown
* unk
);
70 // IBindStatusCallbackEx
71 STDMETHOD(GetBindInfoEx
)(DWORD
* bindf
, BINDINFO
* bind_info
, DWORD
* bindf2
,
75 STDMETHOD(BeginningTransaction
)(LPCWSTR url
, LPCWSTR headers
, DWORD reserved
,
76 LPWSTR
* additional_headers
);
77 STDMETHOD(OnResponse
)(DWORD response_code
, LPCWSTR response_headers
,
78 LPCWSTR request_headers
, LPWSTR
* additional_headers
);
81 STDMETHOD(GetRootSecurityId
)(BYTE
* security_id
, DWORD
* security_id_size
,
85 STDMETHOD(GetSerializedClientCertContext
)(BYTE
** cert
, DWORD
* cert_size
);
91 base::win::ScopedComPtr
<IBindStatusCallback
> delegate_
;
92 base::win::ScopedComPtr
<IBindCtx
> bind_ctx_
;
95 DISALLOW_COPY_AND_ASSIGN(BSCBImpl
);
98 #endif // CHROME_FRAME_BIND_STATUS_CALLBACK_IMPL_H_