From aad41eecdd47c0ec9504be1e5bf5ec0b07b167f7 Mon Sep 17 00:00:00 2001 From: dcheng Date: Fri, 21 Nov 2014 13:08:45 -0800 Subject: Remove implicit conversions from scoped_refptr to T* in win8/ This patch was generated by running the rewrite_scoped_refptr clang tool on a Windows build. BUG=110610 Review URL: https://codereview.chromium.org/740653005 Cr-Commit-Position: refs/heads/master@{#305279} --- win8/metro_driver/ime/input_source.cc | 9 +++++---- win8/metro_driver/ime/text_service.cc | 30 +++++++++++++----------------- win8/metro_driver/ime/text_store.cc | 28 ++++++++++++++-------------- 3 files changed, 32 insertions(+), 35 deletions(-) (limited to 'win8/metro_driver') diff --git a/win8/metro_driver/ime/input_source.cc b/win8/metro_driver/ime/input_source.cc index 9f549d7..6a63751 100644 --- a/win8/metro_driver/ime/input_source.cc +++ b/win8/metro_driver/ime/input_source.cc @@ -53,7 +53,7 @@ class ATL_NO_VTABLE InputSourceMonitor } void Unadvise() { - if (cookie_ == TF_INVALID_COOKIE || !source_) + if (cookie_ == TF_INVALID_COOKIE || !source_.get()) return; if (FAILED(source_->UnadviseSink(cookie_))) return; @@ -145,7 +145,7 @@ scoped_ptr InputSource::Create() { return scoped_ptr(); } base::win::ScopedComPtr profiles_source; - hr = profiles_source.QueryFrom(profile_manager); + hr = profiles_source.QueryFrom(profile_manager.get()); if (FAILED(hr)) { LOG(ERROR) << "QueryFrom to ITfSource failed. hr = " << hr; return scoped_ptr(); @@ -158,13 +158,14 @@ scoped_ptr InputSource::Create() { << " hr = " << hr; return scoped_ptr(); } - if (!monitor->Initialize(profiles_source)) { + if (!monitor->Initialize(profiles_source.get())) { LOG(ERROR) << "Failed to initialize the monitor."; return scoped_ptr(); } // Transfer the ownership. - return scoped_ptr(new InputSourceImpl(profile_manager, monitor)); + return scoped_ptr( + new InputSourceImpl(profile_manager.get(), monitor)); } } // namespace metro_driver diff --git a/win8/metro_driver/ime/text_service.cc b/win8/metro_driver/ime/text_service.cc index 1135619..6eec40f 100644 --- a/win8/metro_driver/ime/text_service.cc +++ b/win8/metro_driver/ime/text_service.cc @@ -176,7 +176,7 @@ class EventSink { : cookie_(cookie), source_(source) {} ~EventSink() { - if (!source_ || cookie_ != TF_INVALID_COOKIE) + if (!source_.get() || cookie_ != TF_INVALID_COOKIE) return; source_->UnadviseSink(cookie_); cookie_ = TF_INVALID_COOKIE; @@ -218,7 +218,7 @@ scoped_ptr CreateTextEditSink(ITfContext* context, class DocumentBinding { public: ~DocumentBinding() { - if (!document_manager_) + if (!document_manager_.get()) return; document_manager_->Pop(TF_POPF_ALL); } @@ -244,7 +244,7 @@ class DocumentBinding { scoped_refptr text_store; if (!use_null_text_store) { text_store = TextStore::Create(window_handle, input_scopes, delegate); - if (!text_store) { + if (!text_store.get()) { LOG(ERROR) << "Failed to create TextStore."; return scoped_ptr(); } @@ -266,20 +266,20 @@ class DocumentBinding { // If null-TextStore is used or |input_scopes| looks like a password field, // set special properties to tell IMEs to be disabled. if ((use_null_text_store || IsPasswordField(input_scopes)) && - !InitializeDisabledContext(context, client_id)) { + !InitializeDisabledContext(context.get(), client_id)) { LOG(ERROR) << "InitializeDisabledContext failed."; return scoped_ptr(); } scoped_ptr text_edit_sink; if (!use_null_text_store) { - text_edit_sink = CreateTextEditSink(context, text_store); + text_edit_sink = CreateTextEditSink(context.get(), text_store.get()); if (!text_edit_sink) { LOG(ERROR) << "CreateTextEditSink failed."; return scoped_ptr(); } } - hr = document_manager->Push(context); + hr = document_manager->Push(context.get()); if (FAILED(hr)) { LOG(ERROR) << "ITfDocumentMgr::Push failed. hr = " << hr; return scoped_ptr(); @@ -290,9 +290,7 @@ class DocumentBinding { text_edit_sink.Pass())); } - ITfDocumentMgr* document_manager() const { - return document_manager_; - } + ITfDocumentMgr* document_manager() const { return document_manager_.get(); } scoped_refptr text_store() const { return text_store_; @@ -326,7 +324,7 @@ class TextServiceImpl : public TextService, thread_manager_(thread_manager) { DCHECK_NE(TF_CLIENTID_NULL, client_id); DCHECK(window_handle != NULL); - DCHECK(thread_manager_); + DCHECK(thread_manager_.get()); } virtual ~TextServiceImpl() { thread_manager_->Deactivate(); @@ -339,8 +337,8 @@ class TextServiceImpl : public TextService, VLOG(0) << "|current_document_| is NULL due to the previous error."; return; } - TextStore* text_store = current_document_->text_store(); - if (!text_store) + scoped_refptr text_store = current_document_->text_store(); + if (!text_store.get()) return; text_store->CancelComposition(); } @@ -479,15 +477,13 @@ CreateTextService(TextServiceDelegate* delegate, HWND window_handle) { LOG(ERROR) << "ITfThreadMgr::Activate failed. hr = " << hr; return scoped_ptr(); } - if (!InitializeSentenceMode(thread_manager, client_id)) { + if (!InitializeSentenceMode(thread_manager.get(), client_id)) { LOG(ERROR) << "InitializeSentenceMode failed."; thread_manager->Deactivate(); return scoped_ptr(); } - return scoped_ptr(new TextServiceImpl(thread_manager, - client_id, - window_handle, - delegate)); + return scoped_ptr(new TextServiceImpl( + thread_manager.get(), client_id, window_handle, delegate)); } } // namespace metro_driver diff --git a/win8/metro_driver/ime/text_store.cc b/win8/metro_driver/ime/text_store.cc index 0c0389b..eff30b7 100644 --- a/win8/metro_driver/ime/text_store.cc +++ b/win8/metro_driver/ime/text_store.cc @@ -59,7 +59,7 @@ scoped_refptr TextStore::Create( } base::win::ScopedComPtr input_scope = CreteInputScope(input_scopes); - if (!input_scope) { + if (!input_scope.get()) { LOG(ERROR) << "Failed to initialize InputScope."; return scoped_refptr(); } @@ -72,10 +72,8 @@ scoped_refptr TextStore::Create( << hr; return scoped_refptr(); } - object->Initialize(window_handle, - category_manager, - display_attribute_manager, - input_scope, + object->Initialize(window_handle, category_manager.get(), + display_attribute_manager.get(), input_scope.get(), delegate); return scoped_refptr(object); } @@ -98,7 +96,7 @@ STDMETHODIMP TextStore::AdviseSink(REFIID iid, DWORD mask) { if (!IsEqualGUID(iid, IID_ITextStoreACPSink)) return E_INVALIDARG; - if (text_store_acp_sink_) { + if (text_store_acp_sink_.get()) { if (text_store_acp_sink_.IsSameObject(unknown)) { text_store_acp_sink_mask_ = mask; return S_OK; @@ -581,7 +579,7 @@ STDMETHODIMP TextStore::RequestSupportedAttrs( const TS_ATTRID* attribute_buffer) { if (!attribute_buffer) return E_INVALIDARG; - if (!input_scope_) + if (!input_scope_.get()) return E_FAIL; // We support only input scope attribute. for (size_t i = 0; i < attribute_buffer_size; ++i) { @@ -600,7 +598,7 @@ STDMETHODIMP TextStore::RetrieveRequestedAttrs( *attribute_buffer_copied = 0; if (!attribute_buffer) return E_INVALIDARG; - if (!input_scope_) + if (!input_scope_.get()) return E_UNEXPECTED; // We support only input scope attribute. *attribute_buffer_copied = 0; @@ -751,14 +749,14 @@ bool TextStore::GetCompositionStatus( } if (FAILED(context->GetEnd(read_only_edit_cookie, end_range.Receive()))) return false; - if (FAILED(start_to_end_range->ShiftEndToRange(read_only_edit_cookie, - end_range, TF_ANCHOR_END))) { + if (FAILED(start_to_end_range->ShiftEndToRange( + read_only_edit_cookie, end_range.get(), TF_ANCHOR_END))) { return false; } base::win::ScopedComPtr ranges; if (FAILED(track_property->EnumRanges(read_only_edit_cookie, ranges.Receive(), - start_to_end_range))) { + start_to_end_range.get()))) { return false; } @@ -768,7 +766,7 @@ bool TextStore::GetCompositionStatus( return true; base::win::ScopedVariant value; base::win::ScopedComPtr enum_prop_value; - if (FAILED(track_property->GetValue(read_only_edit_cookie, range, + if (FAILED(track_property->GetValue(read_only_edit_cookie, range.get(), value.Receive()))) { return false; } @@ -792,7 +790,7 @@ bool TextStore::GetCompositionStatus( } base::win::ScopedComPtr range_acp; - range_acp.QueryFrom(range); + range_acp.QueryFrom(range.get()); LONG start_pos, length; range_acp->GetExtent(&start_pos, &length); if (is_composition) { @@ -879,8 +877,10 @@ bool TextStore::ConfirmComposition() { } void TextStore::SendOnLayoutChange() { - if (text_store_acp_sink_ && (text_store_acp_sink_mask_ & TS_AS_LAYOUT_CHANGE)) + if (text_store_acp_sink_.get() && + (text_store_acp_sink_mask_ & TS_AS_LAYOUT_CHANGE)) { text_store_acp_sink_->OnLayoutChange(TS_LC_CHANGE, 0); + } } bool TextStore::HasReadLock() const { -- cgit v1.1