OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_SESSIONS_SESSION_RESTORE_TEST_HELPER_H_ | 5 #ifndef CHROME_BROWSER_SESSIONS_SESSION_RESTORE_TEST_HELPER_H_ |
6 #define CHROME_BROWSER_SESSIONS_SESSION_RESTORE_TEST_HELPER_H_ | 6 #define CHROME_BROWSER_SESSIONS_SESSION_RESTORE_TEST_HELPER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
11 #include "chrome/browser/sessions/session_restore.h" | 11 #include "chrome/browser/sessions/session_restore.h" |
12 | 12 |
13 namespace content { | 13 namespace content { |
14 class MessageLoopRunner; | 14 class MessageLoopRunner; |
15 } | 15 } |
16 | 16 |
17 // This class waits on the SessionRestore notification. It is a replacement for | 17 // This class waits on the SessionRestore notification. It is a replacement for |
18 // content::WindowedNotificationObserver, which uses notification service. This | 18 // content::WindowedNotificationObserver, which uses notification service. This |
19 // class uses the callback-based notification instead. | 19 // class uses the callback-based notification instead. |
20 class SessionRestoreTestHelper { | 20 class SessionRestoreTestHelper { |
21 public: | 21 public: |
22 SessionRestoreTestHelper(); | 22 SessionRestoreTestHelper(); |
23 ~SessionRestoreTestHelper(); | 23 ~SessionRestoreTestHelper(); |
24 | 24 |
25 // Blocks until OnSessionRestore() is called. | 25 // Blocks until OnSessionRestore() is called. |
26 void Wait(); | 26 void Wait(); |
27 | 27 |
28 private: | 28 private: |
29 // Callback for session restore notifications. | 29 // Callback for session restore notifications. |
30 void OnSessionRestoreDone(); | 30 void OnSessionRestoreDone(int /* num_tabs_restored */); |
31 | 31 |
32 // Indicates whether a session restore notification has been received. | 32 // Indicates whether a session restore notification has been received. |
33 bool restore_notification_seen_; | 33 bool restore_notification_seen_; |
34 | 34 |
35 // Indicates whether |message_loop_runner_| is running. | 35 // Indicates whether |message_loop_runner_| is running. |
36 bool loop_is_running_; | 36 bool loop_is_running_; |
37 | 37 |
38 // Loop that runs while waiting for notification callback. | 38 // Loop that runs while waiting for notification callback. |
39 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; | 39 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; |
40 | 40 |
41 // For automatically unsubscribing from callback-based notifications. | 41 // For automatically unsubscribing from callback-based notifications. |
42 SessionRestore::CallbackSubscription callback_subscription_; | 42 SessionRestore::CallbackSubscription callback_subscription_; |
43 | 43 |
44 // For safely binding pointers to callbacks. | 44 // For safely binding pointers to callbacks. |
45 base::WeakPtrFactory<SessionRestoreTestHelper> weak_ptr_factory; | 45 base::WeakPtrFactory<SessionRestoreTestHelper> weak_ptr_factory; |
46 | 46 |
47 DISALLOW_COPY_AND_ASSIGN(SessionRestoreTestHelper); | 47 DISALLOW_COPY_AND_ASSIGN(SessionRestoreTestHelper); |
48 }; | 48 }; |
49 | 49 |
50 #endif // CHROME_BROWSER_SESSIONS_SESSION_RESTORE_TEST_HELPER_H_ | 50 #endif // CHROME_BROWSER_SESSIONS_SESSION_RESTORE_TEST_HELPER_H_ |
OLD | NEW |