Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: chrome/browser/sessions/session_restore_test_helper.h

Issue 871013006: Use callbacks in SessionRestore unit tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add destructor Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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.
4
5 #ifndef CHROME_BROWSER_SESSIONS_SESSION_RESTORE_TEST_HELPER_H_
6 #define CHROME_BROWSER_SESSIONS_SESSION_RESTORE_TEST_HELPER_H_
7
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"
12
13 namespace content {
14 class MessageLoopRunner;
15 }
16
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 {
21 public:
22 SessionRestoreTestHelper();
23 ~SessionRestoreTestHelper();
24
25 // Blocks until OnSessionRestore() is called.
26 void Wait();
27
28 private:
29 // Callback for session restore notifications.
30 void OnSessionRestoreDone();
31
32 // Indicates whether a session restore notification has been received.
33 bool restore_notification_seen_;
34
35 // Indicates whether |message_loop_runner_| is running.
36 bool loop_is_running_;
37
38 // Loop that runs while waiting for notification callback.
39 scoped_refptr<content::MessageLoopRunner> message_loop_runner_;
40
41 // For automatically unsubscribing from callback-based notifications.
42 SessionRestore::CallbackSubscription callback_subscription_;
43
44 // For safely binding pointers to callbacks.
45 base::WeakPtrFactory<SessionRestoreTestHelper> weak_ptr_factory;
46
47 DISALLOW_COPY_AND_ASSIGN(SessionRestoreTestHelper);
48 };
49
50 #endif // CHROME_BROWSER_SESSIONS_SESSION_RESTORE_TEST_HELPER_H_
OLDNEW
« no previous file with comments | « chrome/browser/sessions/session_restore_browsertest.cc ('k') | chrome/browser/sessions/session_restore_test_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698