Introduce ProfilerMetricsProvider
[chromium-blink-merge.git] / chrome / browser / browser_shutdown.h
blobf53de37963a6aadec5e8fa1ad66cbbc6ca985d07
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_BROWSER_SHUTDOWN_H__
6 #define CHROME_BROWSER_BROWSER_SHUTDOWN_H__
8 class PrefRegistrySimple;
10 namespace browser_shutdown {
12 enum ShutdownType {
13 // an uninitialized value
14 NOT_VALID = 0,
15 // the last browser window was closed
16 WINDOW_CLOSE,
17 // user clicked on the Exit menu item
18 BROWSER_EXIT,
19 // windows is logging off or shutting down
20 END_SESSION
23 void RegisterPrefs(PrefRegistrySimple* registry);
25 // Called when the browser starts shutting down so that we can measure shutdown
26 // time.
27 void OnShutdownStarting(ShutdownType type);
29 // Get the current shutdown type.
30 ShutdownType GetShutdownType();
32 // Performs the shutdown tasks that need to be done before
33 // BrowserProcess and the various threads go away.
35 // Returns true if the session should be restarted.
36 bool ShutdownPreThreadsStop();
38 // Performs the remaining shutdown tasks after all threads but the
39 // main thread have been stopped. This includes deleting g_browser_process.
41 // The provided parameter indicates whether a preference to restart
42 // the session was present.
43 void ShutdownPostThreadsStop(bool restart_last_session);
45 // Called at startup to create a histogram from our previous shutdown time.
46 void ReadLastShutdownInfo();
48 // There are various situations where the browser process should continue to
49 // run after the last browser window has closed - the Mac always continues
50 // running until the user explicitly quits, and on Windows/Linux the application
51 // should not shutdown when the last browser window closes if there are any
52 // BackgroundContents running.
53 // When the user explicitly chooses to shutdown the app (via the "Exit" or
54 // "Quit" menu items) BrowserList will call SetTryingToQuit() to tell itself to
55 // initiate a shutdown when the last window closes.
56 // If the quit is aborted, then the flag should be reset.
58 // This is a low-level mutator; in general, don't call SetTryingToQuit(true),
59 // except from appropriate places in BrowserList. To quit, use usual means,
60 // e.g., using |chrome_browser_application_mac::Terminate()| on the Mac, or
61 // |BrowserList::CloseAllWindowsAndExit()| on other platforms. To stop quitting,
62 // use |chrome_browser_application_mac::CancelTerminate()| on the Mac; other
63 // platforms can call SetTryingToQuit(false) directly.
64 void SetTryingToQuit(bool quitting);
66 // General accessor.
67 bool IsTryingToQuit();
69 } // namespace browser_shutdown
71 #endif // CHROME_BROWSER_BROWSER_SHUTDOWN_H__