frame_load_waiter.cc revision 1320f92c476a1ad9d19dba2a48c72b75566198e9
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/message_loop/message_loop.h"
9
10namespace content {
11
12FrameLoadWaiter::FrameLoadWaiter(RenderFrame* frame)
13    : RenderFrameObserver(frame) {
14}
15
16void FrameLoadWaiter::Wait() {
17  // Pump messages until Blink's threaded HTML parser finishes.
18  run_loop_.Run();
19}
20
21void FrameLoadWaiter::DidFinishLoad() {
22  // Post a task to quit instead of quitting directly, since the load completion
23  // may trigger other IPCs that tests are expecting.
24  base::MessageLoop::current()->PostTask(FROM_HERE, run_loop_.QuitClosure());
25}
26
27}  // namespace content
28