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

Side by Side Diff: chrome/browser/chromeos/arc/arc_session_manager.h

Issue 2737453003: Fix ArcSessionManager state machine, part 1. (Closed)
Patch Set: Rebase Created 3 years, 9 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 2016 The Chromium Authors. All rights reserved. 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 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_CHROMEOS_ARC_ARC_SESSION_MANAGER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_ARC_ARC_SESSION_MANAGER_H_
6 #define CHROME_BROWSER_CHROMEOS_ARC_ARC_SESSION_MANAGER_H_ 6 #define CHROME_BROWSER_CHROMEOS_ARC_ARC_SESSION_MANAGER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <ostream> 9 #include <ostream>
10 #include <string> 10 #include <string>
(...skipping 24 matching lines...) Expand all
35 // This class proxies the request from the client to fetch an auth code from 35 // This class proxies the request from the client to fetch an auth code from
36 // LSO. It lives on the UI thread. 36 // LSO. It lives on the UI thread.
37 class ArcSessionManager : public ArcSessionRunner::Observer, 37 class ArcSessionManager : public ArcSessionRunner::Observer,
38 public ArcSupportHost::Observer { 38 public ArcSupportHost::Observer {
39 public: 39 public:
40 // Represents each State of ARC session. 40 // Represents each State of ARC session.
41 // NOT_INITIALIZED: represents the state that the Profile is not yet ready 41 // NOT_INITIALIZED: represents the state that the Profile is not yet ready
42 // so that this service is not yet initialized, or Chrome is being shut 42 // so that this service is not yet initialized, or Chrome is being shut
43 // down so that this is destroyed. 43 // down so that this is destroyed.
44 // STOPPED: ARC session is not running, or being terminated. 44 // STOPPED: ARC session is not running, or being terminated.
45 // SHOWING_TERMS_OF_SERVICE: "Terms Of Service" page is shown on ARC support 45 // NEGOTIATING_TERMS_OF_SERVICE: Negotiating Google Play Store "Terms of
46 // Chrome app. 46 // Service" with a user. There are several ways for the negotiation,
47 // including opt-in flow, which shows "Terms of Service" page on ARC
48 // support app, and OOBE flow, which shows "Terms of Service" page as a
49 // part of Chrome OOBE flow.
50 // If user does not accept the Terms of Service, disables Google Play
51 // Store, which triggers RequestDisable() and the state will be set to
52 // STOPPED, then.
47 // CHECKING_ANDROID_MANAGEMENT: Checking Android management status. Note that 53 // CHECKING_ANDROID_MANAGEMENT: Checking Android management status. Note that
48 // the status is checked for each ARC session starting, but this is the 54 // the status is checked for each ARC session starting, but this is the
49 // state only for the first boot case (= opt-in case). The second time and 55 // state only for the first boot case (= opt-in case). The second time and
50 // later the management check is running in parallel with ARC session 56 // later the management check is running in parallel with ARC session
51 // starting, and in such a case, State is ACTIVE, instead. 57 // starting, and in such a case, State is ACTIVE, instead.
52 // REMOVING_DATA_DIR: When ARC is disabled, the data directory is removed. 58 // REMOVING_DATA_DIR: When ARC is disabled, the data directory is removed.
53 // While removing is processed, ARC cannot be started. This is the state. 59 // While removing is processed, ARC cannot be started. This is the state.
54 // ACTIVE: ARC is running. 60 // ACTIVE: ARC is running.
55 // 61 //
56 // State transition should be as follows: 62 // State transition should be as follows:
57 // 63 //
58 // NOT_INITIALIZED -> STOPPED: when the primary Profile gets ready. 64 // NOT_INITIALIZED -> STOPPED: when the primary Profile gets ready.
59 // ...(any)... -> NOT_INITIALIZED: when the Chrome is being shutdown. 65 // ...(any)... -> NOT_INITIALIZED: when the Chrome is being shutdown.
60 // ...(any)... -> STOPPED: on error. 66 // ...(any)... -> STOPPED: on error.
61 // 67 //
62 // In the first boot case: 68 // In the first boot case:
63 // STOPPED -> SHOWING_TERMS_OF_SERVICE: when arc.enabled preference is set. 69 // STOPPED -> NEGOTIATING_TERMS_OF_SERVICE: On request to enable.
64 // SHOWING_TERMS_OF_SERVICE -> CHECKING_ANDROID_MANAGEMENT: when a user 70 // NEGOTIATING_TERMS_OF_SERVICE -> CHECKING_ANDROID_MANAGEMENT: when a user
65 // agree with "Terms Of Service" 71 // accepts "Terms Of Service"
66 // CHECKING_ANDROID_MANAGEMENT -> ACTIVE: when the auth token is 72 // CHECKING_ANDROID_MANAGEMENT -> ACTIVE: when the auth token is
67 // successfully fetched. 73 // successfully fetched.
68 // 74 //
69 // In the second (or later) boot case: 75 // In the second (or later) boot case:
70 // STOPPED -> ACTIVE: when arc.enabled preference is checked that it is 76 // STOPPED -> ACTIVE: when arc.enabled preference is checked that it is
71 // true. Practically, this is when the primary Profile gets ready. 77 // true. Practically, this is when the primary Profile gets ready.
72 // 78 //
73 // TODO(hidehiko): Fix the state machine, and update the comment including 79 // TODO(hidehiko): Fix the state machine, and update the comment including
74 // relationship with |enable_requested_|. 80 // relationship with |enable_requested_|.
75 enum class State { 81 enum class State {
76 NOT_INITIALIZED, 82 NOT_INITIALIZED,
77 STOPPED, 83 STOPPED,
78 SHOWING_TERMS_OF_SERVICE, 84 NEGOTIATING_TERMS_OF_SERVICE,
79 CHECKING_ANDROID_MANAGEMENT, 85 CHECKING_ANDROID_MANAGEMENT,
80 REMOVING_DATA_DIR, 86 REMOVING_DATA_DIR,
81 ACTIVE, 87 ACTIVE,
82 }; 88 };
83 89
84 // Observer for those services outside of ARC which want to know ARC events. 90 // Observer for those services outside of ARC which want to know ARC events.
85 class Observer { 91 class Observer {
86 public: 92 public:
87 // Called to notify that whether Google Play Store is enabled or not, which 93 // Called to notify that whether Google Play Store is enabled or not, which
88 // is represented by "arc.enabled" preference, is updated. 94 // is represented by "arc.enabled" preference, is updated.
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 229
224 private: 230 private:
225 // RequestEnable() has a check in order not to trigger starting procedure 231 // RequestEnable() has a check in order not to trigger starting procedure
226 // twice. This method can be called to bypass that check when restarting. 232 // twice. This method can be called to bypass that check when restarting.
227 void RequestEnableImpl(); 233 void RequestEnableImpl();
228 234
229 // Negotiates the terms of service to user. 235 // Negotiates the terms of service to user.
230 void StartTermsOfServiceNegotiation(); 236 void StartTermsOfServiceNegotiation();
231 void OnTermsOfServiceNegotiated(bool accepted); 237 void OnTermsOfServiceNegotiated(bool accepted);
232 238
239 // Returns true if Terms of Service negotiation is needed. Otherwise false.
240 // TODO(crbug.com/698418): Write unittest for this utility after extracting
241 // ToS related code from ArcSessionManager into a dedicated class.
242 bool IsArcTermsOfServiceNegotiationNeeded() const;
243
233 void SetState(State state); 244 void SetState(State state);
234 void ShutdownSession(); 245 void ShutdownSession();
235 void OnArcDataRemoved(bool success); 246 void OnArcDataRemoved(bool success);
236 void OnArcSignInTimeout(); 247 void OnArcSignInTimeout();
237 248
238 // Starts Android management check. This is for first boot case (= Opt-in 249 // Starts Android management check. This is for first boot case (= Opt-in
239 // or OOBE flow case). In secondary or later ARC enabling, the check should 250 // or OOBE flow case). In secondary or later ARC enabling, the check should
240 // run in background. 251 // run in background.
241 void StartAndroidManagementCheck(); 252 void StartAndroidManagementCheck();
242 253
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 DISALLOW_COPY_AND_ASSIGN(ArcSessionManager); 326 DISALLOW_COPY_AND_ASSIGN(ArcSessionManager);
316 }; 327 };
317 328
318 // Outputs the stringified |state| to |os|. This is only for logging purposes. 329 // Outputs the stringified |state| to |os|. This is only for logging purposes.
319 std::ostream& operator<<(std::ostream& os, 330 std::ostream& operator<<(std::ostream& os,
320 const ArcSessionManager::State& state); 331 const ArcSessionManager::State& state);
321 332
322 } // namespace arc 333 } // namespace arc
323 334
324 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_SESSION_MANAGER_H_ 335 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_SESSION_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698