diff options
author | danakj <danakj@chromium.org> | 2015-03-09 17:41:03 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-03-10 00:41:36 +0000 |
commit | 8095bc45b602f704ef85df43f9913f48fbf4cf9c (patch) | |
tree | 8d2db4fcfcf0c0fbec95332ad0a5af4bc58d4457 /win8 | |
parent | 23ae3128db0d84a6b1ffa640568a5ec90cfc8808 (diff) | |
download | chromium_src-8095bc45b602f704ef85df43f9913f48fbf4cf9c.zip chromium_src-8095bc45b602f704ef85df43f9913f48fbf4cf9c.tar.gz chromium_src-8095bc45b602f704ef85df43f9913f48fbf4cf9c.tar.bz2 |
base: Remove operator& from ScopedVariant and ScopedPropVariant.
The operator& is dangerous as it makes code unclear what is happening.
For ScopedPropVariant there is already a get() method returning a
const& of the internal type. So doing &foo.get() will get a pointer to
the internal type.
For ScopedVariant, there is only operator&, so replace it with an
operator*() that returns a const&. This changes callsites from doing
something like V_FOO(&scoper) to V_FOO(&*scoper) which makes it clear
that it is getting the address of the thing inside scoper, not the
scoper itself.
R=Nico
BUG=464816
Review URL: https://codereview.chromium.org/985853005
Cr-Commit-Position: refs/heads/master@{#319795}
Diffstat (limited to 'win8')
-rw-r--r-- | win8/metro_driver/ime/text_service.cc | 6 | ||||
-rw-r--r-- | win8/test/ui_automation_client.cc | 19 |
2 files changed, 13 insertions, 12 deletions
diff --git a/win8/metro_driver/ime/text_service.cc b/win8/metro_driver/ime/text_service.cc index 6eec40f..4601f27 100644 --- a/win8/metro_driver/ime/text_service.cc +++ b/win8/metro_driver/ime/text_service.cc @@ -111,7 +111,7 @@ bool InitializeSentenceMode(ITfThreadMgr* thread_manager, base::win::ScopedVariant sentence_variant; sentence_variant.Set(TF_SENTENCEMODE_PHRASEPREDICT); - hr = sentence_compartment->SetValue(client_id, &sentence_variant); + hr = sentence_compartment->SetValue(client_id, sentence_variant.ptr()); if (FAILED(hr)) { LOG(ERROR) << "ITfCompartment::SetValue failed. hr = " << hr; return false; @@ -138,7 +138,7 @@ bool InitializeDisabledContext(ITfContext* context, TfClientId client_id) { base::win::ScopedVariant variant; variant.Set(1); - hr = disabled_compartment->SetValue(client_id, &variant); + hr = disabled_compartment->SetValue(client_id, variant.ptr()); if (FAILED(hr)) { LOG(ERROR) << "ITfCompartment::SetValue failed. hr = " << hr; return false; @@ -154,7 +154,7 @@ bool InitializeDisabledContext(ITfContext* context, TfClientId client_id) { base::win::ScopedVariant empty_context_variant; empty_context_variant.Set(static_cast<int32>(1)); - hr = empty_context->SetValue(client_id, &empty_context_variant); + hr = empty_context->SetValue(client_id, empty_context_variant.ptr()); if (FAILED(hr)) { LOG(ERROR) << "ITfCompartment::SetValue failed. hr = " << hr; return false; diff --git a/win8/test/ui_automation_client.cc b/win8/test/ui_automation_client.cc index 32d87f8..6a859af 100644 --- a/win8/test/ui_automation_client.cc +++ b/win8/test/ui_automation_client.cc @@ -315,12 +315,13 @@ void UIAutomationClient::Context::HandleWindowOpen( return; } - if (V_VT(&var) != VT_BSTR) { - LOG(ERROR) << __FUNCTION__ << " class name is not a BSTR: " << V_VT(&var); + if (V_VT(var.ptr()) != VT_BSTR) { + LOG(ERROR) << __FUNCTION__ + << " class name is not a BSTR: " << V_VT(var.ptr()); return; } - base::string16 class_name(V_BSTR(&var)); + base::string16 class_name(V_BSTR(var.ptr())); // Window class names are atoms, which are case-insensitive. if (class_name.size() == class_name_.size() && @@ -533,11 +534,11 @@ HRESULT UIAutomationClient::Context::GetInvokableItems( LOG(ERROR) << std::hex << result; continue; } - if (V_VT(&var) != VT_BSTR) { - LOG(ERROR) << __FUNCTION__ << " name is not a BSTR: " << V_VT(&var); + if (V_VT(var.ptr()) != VT_BSTR) { + LOG(ERROR) << __FUNCTION__ << " name is not a BSTR: " << V_VT(var.ptr()); continue; } - choices->push_back(base::string16(V_BSTR(&var))); + choices->push_back(base::string16(V_BSTR(var.ptr()))); var.Reset(); } @@ -564,13 +565,13 @@ void UIAutomationClient::Context::CloseWindow( return; } - if (V_VT(&var) != VT_I4) { + if (V_VT(var.ptr()) != VT_I4) { LOG(ERROR) << __FUNCTION__ - << " window handle is not an int: " << V_VT(&var); + << " window handle is not an int: " << V_VT(var.ptr()); return; } - HWND handle = reinterpret_cast<HWND>(V_I4(&var)); + HWND handle = reinterpret_cast<HWND>(V_I4(var.ptr())); uint32 scan_code = MapVirtualKey(VK_ESCAPE, MAPVK_VK_TO_VSC); PostMessage(handle, WM_KEYDOWN, VK_ESCAPE, |