Chromium Code Reviews| Index: content/public/test/browser_test_utils.cc |
| diff --git a/content/public/test/browser_test_utils.cc b/content/public/test/browser_test_utils.cc |
| index 9ab9738bd8fbc4355a7b93f11dee9c6d0ca52349..011749454e04d77aa073d0dbb0933ca6265e6a98 100644 |
| --- a/content/public/test/browser_test_utils.cc |
| +++ b/content/public/test/browser_test_utils.cc |
| @@ -1296,4 +1296,33 @@ uint32_t InputMsgWatcher::WaitForAck() { |
| return ack_result_; |
| } |
| +struct FrameFocusedObserver::FrameTreeNodeObserverImpl |
|
alexmos
2016/06/24 01:38:50
Any reason why this is a struct and not a class?
alexmos
2016/07/26 21:08:30
Still have this question. :)
avallee
2016/07/27 21:35:01
Good point, it's not a POD and should be a class.
|
| + : public FrameTreeNode::Observer { |
| + explicit FrameTreeNodeObserverImpl(FrameTreeNode* owner) |
| + : owner_(owner), message_loop_runner_(new MessageLoopRunner) { |
| + owner->AddObserver(this); |
| + } |
| + ~FrameTreeNodeObserverImpl() override { owner_->RemoveObserver(this); } |
| + |
| + void Run() { message_loop_runner_->Run(); } |
| + |
| + void OnFrameTreeNodeFocused(FrameTreeNode* node) override { |
| + if (node == owner_) |
| + message_loop_runner_->Quit(); |
| + } |
| + |
| + FrameTreeNode* owner_; |
| + scoped_refptr<MessageLoopRunner> message_loop_runner_; |
| +}; |
| + |
| +FrameFocusedObserver::FrameFocusedObserver(RenderFrameHost* owner_host) |
| + : impl_(new FrameTreeNodeObserverImpl( |
| + static_cast<RenderFrameHostImpl*>(owner_host)->frame_tree_node())) {} |
| + |
| +FrameFocusedObserver::~FrameFocusedObserver() {} |
| + |
| +void FrameFocusedObserver::Wait() { |
| + impl_->Run(); |
| +} |
| + |
| } // namespace content |