1 // Copyright 2014 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "content/public/test/frame_load_waiter.h" 6 7 #include "base/location.h" 8 #include "base/single_thread_task_runner.h" 9 #include "base/threading/thread_task_runner_handle.h" 10 11 namespace content { 12 FrameLoadWaiter(RenderFrame * frame)13FrameLoadWaiter::FrameLoadWaiter(RenderFrame* frame) 14 : RenderFrameObserver(frame) { 15 } 16 Wait()17void FrameLoadWaiter::Wait() { 18 if (did_load_) 19 return; 20 21 run_loop_.Run(); 22 } 23 DidFinishLoad()24void FrameLoadWaiter::DidFinishLoad() { 25 did_load_ = true; 26 // Post a task to quit instead of quitting directly, since the load completion 27 // may trigger other IPCs that tests are expecting. 28 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, 29 run_loop_.QuitClosure()); 30 } 31 OnDestruct()32void FrameLoadWaiter::OnDestruct() { 33 delete this; 34 } 35 36 } // namespace content 37