Index: chrome_frame/bind_context_info.cc |
=================================================================== |
--- chrome_frame/bind_context_info.cc (revision 47036) |
+++ chrome_frame/bind_context_info.cc (working copy) |
@@ -15,6 +15,9 @@ |
is_switching_(false) { |
} |
+BindContextInfo::~BindContextInfo() { |
+} |
+ |
BindContextInfo* BindContextInfo::FromBindContext(IBindCtx* bind_context) { |
if (!bind_context) { |
NOTREACHED(); |
@@ -24,14 +27,39 @@ |
ScopedComPtr<IUnknown> context; |
bind_context->GetObjectParam(kBindContextInfo, context.Receive()); |
if (context) { |
- return static_cast<BindContextInfo*>(context.get()); |
+ ScopedComPtr<IBindContextInfoInternal> internal; |
+ HRESULT hr = internal.QueryFrom(context); |
+ DCHECK(SUCCEEDED(hr)); |
+ if (SUCCEEDED(hr)) { |
+ BindContextInfo* ret = NULL; |
+ internal->GetCppObject(reinterpret_cast<void**>(&ret)); |
+ DCHECK(ret); |
+ DLOG_IF(WARNING, reinterpret_cast<void*>(ret) != |
+ reinterpret_cast<void*>(internal.get())) |
+ << "marshalling took place!"; |
+ return ret; |
+ } |
} |
CComObject<BindContextInfo>* bind_context_info = NULL; |
- CComObject<BindContextInfo>::CreateInstance(&bind_context_info); |
+ HRESULT hr = CComObject<BindContextInfo>::CreateInstance(&bind_context_info); |
DCHECK(bind_context_info != NULL); |
+ if (bind_context_info) { |
+ bind_context_info->AddRef(); |
+ hr = CoCreateFreeThreadedMarshaler(bind_context_info->GetUnknown(), |
+ bind_context_info->ftm_.Receive()); |
+ DCHECK(bind_context_info->ftm_); |
+ if (SUCCEEDED(hr)) { |
+ hr = bind_context->RegisterObjectParam(kBindContextInfo, |
+ bind_context_info); |
+ } |
- bind_context->RegisterObjectParam(kBindContextInfo, bind_context_info); |
+ DCHECK(SUCCEEDED(hr)) << "Failed to initialize BindContextInfo"; |
+ bind_context_info->Release(); |
+ if (FAILED(hr)) |
+ bind_context_info = NULL; |
+ } |
+ |
return bind_context_info; |
} |