Upstreaming browser/ui/uikit_ui_util from iOS.
[chromium-blink-merge.git] / ios / chrome / browser / metrics / previous_session_info.h
blob0f5a4447e61659a49d9c4702f75e5ab8f6382b8a
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 IOS_CHROME_BROWSER_METRICS_PREVIOUS_SESSION_INFO_H_
6 #define IOS_CHROME_BROWSER_METRICS_PREVIOUS_SESSION_INFO_H_
8 #import <Foundation/Foundation.h>
10 // PreviousSessionInfo has two jobs:
11 // - Holding information about the last session, persisted across restart.
12 // These informations are accessible via the properties on the shared
13 // instance.
14 // - Persist information about the current session, for use in a next session.
15 @interface PreviousSessionInfo : NSObject
17 // Whether the app received a memory warning seconds before being terminated.
18 @property(nonatomic, assign, readonly)
19 BOOL didSeeMemoryWarningShortlyBeforeTerminating;
21 // Whether the app was updated between the previous and the current session.
22 @property(nonatomic, assign, readonly) BOOL isFirstSessionAfterUpgrade;
24 // Singleton PreviousSessionInfo. During the lifetime of the app, the returned
25 // object is the same, and describes the previous session, even after a new
26 // session has started (by calling beginRecordingCurrentSession).
27 + (instancetype)sharedInstance;
29 // Clears the persisted information about the previous session and starts
30 // persisting information about the current session, for use in a next session.
31 - (void)beginRecordingCurrentSession;
33 // When a session has begun, records that a memory warning was received.
34 - (void)setMemoryWarningFlag;
36 // When a session has begun, records that any memory warning flagged can be
37 // ignored.
38 - (void)resetMemoryWarningFlag;
40 @end
42 @interface PreviousSessionInfo (TestingOnly)
43 @property(nonatomic, assign) BOOL didSeeMemoryWarningShortlyBeforeTerminating;
44 + (void)resetSharedInstanceForTesting;
45 @end
47 #endif // IOS_CHROME_BROWSER_METRICS_PREVIOUS_SESSION_INFO_H_