| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "win8/test/ui_automation_client.h" | 5 #include "win8/test/ui_automation_client.h" |
| 6 | 6 |
| 7 #include <atlbase.h> | 7 #include <atlbase.h> |
| 8 #include <atlcom.h> | 8 #include <atlcom.h> |
| 9 #include <oleauto.h> | 9 #include <oleauto.h> |
| 10 #include <uiautomation.h> | 10 #include <uiautomation.h> |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 base::Bind(&UIAutomationClient::Context::HandleAutomationEvent, context_, | 151 base::Bind(&UIAutomationClient::Context::HandleAutomationEvent, context_, |
| 152 base::win::ScopedComPtr<IUIAutomationElement>(sender), | 152 base::win::ScopedComPtr<IUIAutomationElement>(sender), |
| 153 eventId)); | 153 eventId)); |
| 154 | 154 |
| 155 return S_OK; | 155 return S_OK; |
| 156 } | 156 } |
| 157 | 157 |
| 158 base::WeakPtr<UIAutomationClient::Context> | 158 base::WeakPtr<UIAutomationClient::Context> |
| 159 UIAutomationClient::Context::Create() { | 159 UIAutomationClient::Context::Create() { |
| 160 Context* context = new Context(); | 160 Context* context = new Context(); |
| 161 base::WeakPtr<Context> context_ptr(context->weak_ptr_factory_.GetWeakPtr()); | 161 return context->weak_ptr_factory_.GetWeakPtr(); |
| 162 // Unbind from this thread so that the instance will bind to the automation | |
| 163 // thread when Initialize is called. | |
| 164 context->weak_ptr_factory_.DetachFromThread(); | |
| 165 return context_ptr; | |
| 166 } | 162 } |
| 167 | 163 |
| 168 void UIAutomationClient::Context::DeleteOnAutomationThread() { | 164 void UIAutomationClient::Context::DeleteOnAutomationThread() { |
| 169 DCHECK(thread_checker_.CalledOnValidThread()); | 165 DCHECK(thread_checker_.CalledOnValidThread()); |
| 170 delete this; | 166 delete this; |
| 171 } | 167 } |
| 172 | 168 |
| 173 UIAutomationClient::Context::Context() : weak_ptr_factory_(this) {} | 169 UIAutomationClient::Context::Context() : weak_ptr_factory_(this) {} |
| 174 | 170 |
| 175 UIAutomationClient::Context::~Context() { | 171 UIAutomationClient::Context::~Context() { |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 context_, | 618 context_, |
| 623 base::ThreadTaskRunnerHandle::Get(), | 619 base::ThreadTaskRunnerHandle::Get(), |
| 624 string16(class_name), | 620 string16(class_name), |
| 625 item_name, | 621 item_name, |
| 626 init_callback, | 622 init_callback, |
| 627 result_callback)); | 623 result_callback)); |
| 628 } | 624 } |
| 629 | 625 |
| 630 } // namespace internal | 626 } // namespace internal |
| 631 } // namespace win8 | 627 } // namespace win8 |
| OLD | NEW |