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

Side by Side Diff: ios/chrome/app/application_state.h

Issue 2580363002: Upstream Chrome on iOS source code [1/11]. (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « ios/chrome/app/application_phase.h ('k') | ios/chrome/app/application_state.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 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 // ====== New Architecture =====
6 // = This code is only used in the new iOS Chrome architecture. =
7 // ============================================================================
8
9 #ifndef IOS_CHROME_APP_APPLICATION_STATE_H_
10 #define IOS_CHROME_APP_APPLICATION_STATE_H_
11
12 #import <UIKit/UIKit.h>
13
14 #import "ios/chrome/app/application_phase.h"
15
16 namespace base {
17 class SupportsUserData;
18 }
19
20 namespace ios {
21 class ChromeBrowserState;
22 }
23
24 @protocol ApplicationStep;
25 @protocol URLOpening;
26
27 typedef NSMutableArray<id<ApplicationStep>> ApplicationStepArray;
28
29 // An ApplicationState object stores information about Chrome's status in the
30 // iOS application lifecycle and owns root-level global objects needed
31 // throughout the app (specifically, |browserState| and |window|).
32 // Additionally, an ApplicationState object keeps arrays of steps to perform
33 // in response to various changes in the overall application states.
34 // These steps are grouped into launch (used when the app is cold starting),
35 // termination (used when the app is shutting down), background (used when the
36 // app is backgrounding but staying resident), and foreground (used when the app
37 // is warm starting). Each group of steps is an ordered array of objects
38 // implementing the ApplicationStep protocol.
39 // Some methods (indicated below) will cause the ApplicationState to run one of
40 // these lists of steps; this consists of:
41 // (1) Calling -canRunInState: on the first item in the list, passing in the
42 // running ApplicationState object. If this returns NO, stop. Otherwise:
43 // (2) Removing the first item from the list and then calling -runInState:,
44 // again passing in the current state object. State objects can assume
45 // that they are no longer in the step array once -runInState: is called.
46 // (3) When runInState: completes, going back to (1). Since the list of steps
47 // had ownership of the application step that just ran, that step will
48 // then no longer be strongly held, and will thus be deallocated unless
49 // it is being strongly held elsewhere.
50 // Steps cannot themselves store state, since they don't persist after running
51 // by default. Steps can write to the ApplicationState's |state| object to
52 // store state.
53 @interface ApplicationState : NSObject
54
55 // The UIApplication instance this object is storing state for.
56 @property(nonatomic, weak) UIApplication* application;
57
58 // The launch options dictionary for this application, set via
59 // -launchWithOptions:
60 @property(nonatomic, readonly) NSDictionary* launchOptions;
61
62 // The browser state this object stores; many launch steps are expected to
63 // make use of this. At least one launch step must assign to this property at
64 // some point in the launch sequence.
65 @property(nonatomic, assign) ios::ChromeBrowserState* browserState;
66
67 // The current phase the application is in. Changing this doesn't trigger
68 // any launch steps; one of the phase change methods must be called to do that.
69 // Steps invoked during the phase change methods must update this property.
70 @property(nonatomic, assign) ApplicationPhase phase;
71
72 // Persistant storage for application steps that need to have objects live
73 // beyond the execution of the step. This should be used sparingly for objects
74 // that actually need to persist for the lifetime of the app.
75 @property(nonatomic, readonly) base::SupportsUserData* persistentState;
76
77 // The window for this application. Launch steps must create this, make it key
78 // and make it visible, although those three actions may be spread across
79 // more than one step.
80 @property(nonatomic, strong) UIWindow* window;
81
82 // An object that can open URLs when the application is asked to do so by the
83 // operating system.
84 @property(nonatomic, weak) id<URLOpening> URLOpener;
85
86 // Steps for each phase. Steps may add more steps to these arrays, and steps
87 // added in this way become strongly held by this object.
88 @property(nonatomic, readonly) ApplicationStepArray* launchSteps;
89 @property(nonatomic, readonly) ApplicationStepArray* terminationSteps;
90 @property(nonatomic, readonly) ApplicationStepArray* backgroundSteps;
91 @property(nonatomic, readonly) ApplicationStepArray* foregroundSteps;
92
93 // Phase change methods.
94
95 // Sets the launchOptions property to |launchOptions| and then runs the launch
96 // steps.
97 - (void)launchWithOptions:(NSDictionary*)launchOptions;
98
99 // Runs the launch steps.
100 - (void)continueLaunch;
101
102 // Runs the termination steps.
103 - (void)terminate;
104
105 // Runs the background steps.
106 - (void)background;
107
108 // Runs the foreground steps.
109 - (void)foreground;
110
111 @end
112
113 #endif // IOS_CHROME_APP_APPLICATION_STATE_H_
OLDNEW
« no previous file with comments | « ios/chrome/app/application_phase.h ('k') | ios/chrome/app/application_state.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698