Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2478)

Unified Diff: chrome_frame/bind_context_info.cc

Issue 2011016: Use an interface to get to the C++ object pointer instead of casting directly... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome_frame/bind_context_info.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « chrome_frame/bind_context_info.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698