diff options
author | tommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-13 17:46:43 +0000 |
---|---|---|
committer | tommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-13 17:46:43 +0000 |
commit | 25299f2df64fa07dd8a94b2c5c301ea9b0a0b6f6 (patch) | |
tree | 92e605a5270f053a6389fe74741200b190111ca3 /chrome_frame/bind_context_info.cc | |
parent | a9ff2c0716e6ad021e555de88d54e8e199afe0d7 (diff) | |
download | chromium_src-25299f2df64fa07dd8a94b2c5c301ea9b0a0b6f6.zip chromium_src-25299f2df64fa07dd8a94b2c5c301ea9b0a0b6f6.tar.gz chromium_src-25299f2df64fa07dd8a94b2c5c301ea9b0a0b6f6.tar.bz2 |
Use an interface to get to the C++ object pointer instead of casting directly.
The object was being marshalled so, we were casting an ole32 proxy object to our implementation. To avoid marshalling altogether I'm also using the FTM. So, yeah, we're going belt and suspenders.
TEST=See bug.
BUG=43988
Review URL: http://codereview.chromium.org/2011016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47160 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/bind_context_info.cc')
-rw-r--r-- | chrome_frame/bind_context_info.cc | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/chrome_frame/bind_context_info.cc b/chrome_frame/bind_context_info.cc index 3eb2554..07ba1f3 100644 --- a/chrome_frame/bind_context_info.cc +++ b/chrome_frame/bind_context_info.cc @@ -15,6 +15,22 @@ BindContextInfo::BindContextInfo() is_switching_(false) { } +BindContextInfo::~BindContextInfo() { +} + +HRESULT BindContextInfo::Initialize(IBindCtx* bind_ctx) { + DCHECK(bind_ctx); + DCHECK(!ftm_); + HRESULT hr = CoCreateFreeThreadedMarshaler(GetUnknown(), ftm_.Receive()); + DCHECK(ftm_); + if (SUCCEEDED(hr)) { + hr = bind_ctx->RegisterObjectParam(kBindContextInfo, GetUnknown()); + } + + DCHECK(SUCCEEDED(hr)) << "Failed to initialize BindContextInfo"; + return hr; +} + BindContextInfo* BindContextInfo::FromBindContext(IBindCtx* bind_context) { if (!bind_context) { NOTREACHED(); @@ -24,14 +40,31 @@ BindContextInfo* BindContextInfo::FromBindContext(IBindCtx* bind_context) { 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(ERROR, 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 = bind_context_info->Initialize(bind_context); + bind_context_info->Release(); + if (FAILED(hr)) + bind_context_info = NULL; + } - bind_context->RegisterObjectParam(kBindContextInfo, bind_context_info); return bind_context_info; } |