1 // Copyright 2015 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.
5 #ifndef CHROME_BROWSER_SESSIONS_SESSION_RESTORE_TEST_HELPER_H_
6 #define CHROME_BROWSER_SESSIONS_SESSION_RESTORE_TEST_HELPER_H_
8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h"
11 #include "chrome/browser/sessions/session_restore.h"
14 class MessageLoopRunner
;
17 // This class waits on the SessionRestore notification. It is a replacement for
18 // content::WindowedNotificationObserver, which uses notification service. This
19 // class uses the callback-based notification instead.
20 class SessionRestoreTestHelper
{
22 SessionRestoreTestHelper();
23 ~SessionRestoreTestHelper();
25 // Blocks until OnSessionRestore() is called.
29 // Callback for session restore notifications.
30 void OnSessionRestoreDone(int /* num_tabs_restored */);
32 // Indicates whether a session restore notification has been received.
33 bool restore_notification_seen_
;
35 // Indicates whether |message_loop_runner_| is running.
36 bool loop_is_running_
;
38 // Loop that runs while waiting for notification callback.
39 scoped_refptr
<content::MessageLoopRunner
> message_loop_runner_
;
41 // For automatically unsubscribing from callback-based notifications.
42 SessionRestore::CallbackSubscription callback_subscription_
;
44 // For safely binding pointers to callbacks.
45 base::WeakPtrFactory
<SessionRestoreTestHelper
> weak_ptr_factory
;
47 DISALLOW_COPY_AND_ASSIGN(SessionRestoreTestHelper
);
50 #endif // CHROME_BROWSER_SESSIONS_SESSION_RESTORE_TEST_HELPER_H_