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

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

Issue 902613003: Record the number of tabs in a session restore in SampledProfile (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add more detailed description of meaning of num tabs, given by sky 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_H_ 5 #ifndef CHROME_BROWSER_SESSIONS_SESSION_RESTORE_H_
6 #define CHROME_BROWSER_SESSIONS_SESSION_RESTORE_H_ 6 #define CHROME_BROWSER_SESSIONS_SESSION_RESTORE_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 22 matching lines...) Expand all
33 // Indicates that if there is a problem restoring the last session then a 33 // Indicates that if there is a problem restoring the last session then a
34 // new tabbed browser should be created. 34 // new tabbed browser should be created.
35 ALWAYS_CREATE_TABBED_BROWSER = 1 << 1, 35 ALWAYS_CREATE_TABBED_BROWSER = 1 << 1,
36 36
37 // Restore blocks until complete. This is intended for use during startup 37 // Restore blocks until complete. This is intended for use during startup
38 // when we want to block until restore is complete. 38 // when we want to block until restore is complete.
39 SYNCHRONOUS = 1 << 2, 39 SYNCHRONOUS = 1 << 2,
40 }; 40 };
41 41
42 // Notification callback list. 42 // Notification callback list.
43 using CallbackList = base::CallbackList<void(void)>; 43 using CallbackList = base::CallbackList<void(int)>;
44 44
45 // Used by objects calling RegisterOnSessionRestoredCallback() to de-register 45 // Used by objects calling RegisterOnSessionRestoredCallback() to de-register
46 // themselves when they are destroyed. 46 // themselves when they are destroyed.
47 using CallbackSubscription = 47 using CallbackSubscription =
48 scoped_ptr<base::CallbackList<void(void)>::Subscription>; 48 scoped_ptr<base::CallbackList<void(int)>::Subscription>;
49 49
50 // Restores the last session. |behavior| is a bitmask of Behaviors, see it 50 // Restores the last session. |behavior| is a bitmask of Behaviors, see it
51 // for details. If |browser| is non-null the tabs for the first window are 51 // for details. If |browser| is non-null the tabs for the first window are
52 // added to it. Returns the last active browser. 52 // added to it. Returns the last active browser.
53 // Every additional browser created will be created on the desktop specified 53 // Every additional browser created will be created on the desktop specified
54 // by |host_desktop_type|, if |browser| is non-null it should have the same 54 // by |host_desktop_type|, if |browser| is non-null it should have the same
55 // desktop type. 55 // desktop type.
56 // 56 //
57 // If |urls_to_open| is non-empty, a tab is added for each of the URLs. 57 // If |urls_to_open| is non-empty, a tab is added for each of the URLs.
58 static Browser* RestoreSession(Profile* profile, 58 static Browser* RestoreSession(Profile* profile,
(...skipping 26 matching lines...) Expand all
85 const sessions::SessionTab& tab, 85 const sessions::SessionTab& tab,
86 WindowOpenDisposition disposition); 86 WindowOpenDisposition disposition);
87 87
88 // Returns true if we're in the process of restoring |profile|. 88 // Returns true if we're in the process of restoring |profile|.
89 static bool IsRestoring(const Profile* profile); 89 static bool IsRestoring(const Profile* profile);
90 90
91 // Returns true if synchronously restoring a session. 91 // Returns true if synchronously restoring a session.
92 static bool IsRestoringSynchronously(); 92 static bool IsRestoringSynchronously();
93 93
94 // Register callbacks for session restore events. These callbacks are stored 94 // Register callbacks for session restore events. These callbacks are stored
95 // in on_session_restored_callbacks_. 95 // in |on_session_restored_callbacks_|.
96 // The callback is supplied an integer arg representing a tab count. The exact
97 // meaning and timing depend upon the restore type:
98 // - SessionRestore::SYNCHRONOUS: the parameter is the number of tabs that
99 // were created. Additionally the callback is invoked immediately after the
100 // tabs have been created. That is, the tabs are not necessarily loading.
101 // - For all other restore types the parameter is the number of tabs that were
102 // restored and is sent after all tabs have started loading. Additionally if a
103 // request to restore tabs comes in while a previous request to restore tabs
104 // has not yet completed (loading tabs is throttled), then the callback is
105 // only notified once both sets of tabs have started loading and with the
106 // total number of tabs for both restores.
96 static CallbackSubscription RegisterOnSessionRestoredCallback( 107 static CallbackSubscription RegisterOnSessionRestoredCallback(
97 const base::Closure& callback); 108 const base::Callback<void(int)>& callback);
98 109
99 // The max number of non-selected tabs SessionRestore loads when restoring 110 // The max number of non-selected tabs SessionRestore loads when restoring
100 // a session. A value of 0 indicates all tabs are loaded at once. 111 // a session. A value of 0 indicates all tabs are loaded at once.
101 static size_t num_tabs_to_load_; 112 static size_t num_tabs_to_load_;
102 113
103 private: 114 private:
104 SessionRestore(); 115 SessionRestore();
105 116
106 // Accessor for |*on_session_restored_callbacks_|. Creates a new object the 117 // Accessor for |*on_session_restored_callbacks_|. Creates a new object the
107 // first time so that it always returns a valid object. 118 // first time so that it always returns a valid object.
108 static CallbackList* on_session_restored_callbacks() { 119 static CallbackList* on_session_restored_callbacks() {
109 if (!on_session_restored_callbacks_) 120 if (!on_session_restored_callbacks_)
110 on_session_restored_callbacks_ = new CallbackList(); 121 on_session_restored_callbacks_ = new CallbackList();
111 return on_session_restored_callbacks_; 122 return on_session_restored_callbacks_;
112 } 123 }
113 124
114 // Contains all registered callbacks for session restore notifications. 125 // Contains all registered callbacks for session restore notifications.
115 static CallbackList* on_session_restored_callbacks_; 126 static CallbackList* on_session_restored_callbacks_;
116 127
117 DISALLOW_COPY_AND_ASSIGN(SessionRestore); 128 DISALLOW_COPY_AND_ASSIGN(SessionRestore);
118 }; 129 };
119 130
120 #endif // CHROME_BROWSER_SESSIONS_SESSION_RESTORE_H_ 131 #endif // CHROME_BROWSER_SESSIONS_SESSION_RESTORE_H_
OLDNEW
« no previous file with comments | « chrome/browser/metrics/perf_provider_chromeos.cc ('k') | chrome/browser/sessions/session_restore.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698