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

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

Issue 2734873002: Fix ArcSessionManager state machine, part 2. (Closed)
Patch Set: Address comments. 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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 // enabled or disabled. Please see also TODO of 166 // enabled or disabled. Please see also TODO of
167 // SetArcPlayStoreEnabledForProfile(). 167 // SetArcPlayStoreEnabledForProfile().
168 void RequestEnable(); 168 void RequestEnable();
169 169
170 // Requests to disable ARC session. This stops ARC instance, or quits Terms 170 // Requests to disable ARC session. This stops ARC instance, or quits Terms
171 // Of Service negotiation if it is the middle of the process (e.g. closing 171 // Of Service negotiation if it is the middle of the process (e.g. closing
172 // UI for manual negotiation if it is shown). 172 // UI for manual negotiation if it is shown).
173 // If it is already requested to disable, no-op. 173 // If it is already requested to disable, no-op.
174 void RequestDisable(); 174 void RequestDisable();
175 175
176 // Requests to remove the ARC data.
177 // If ARC is stopped, triggers to remove the data. Otherwise, queues to
178 // remove the data after ARC stops.
179 // A log statement with the removal reason must be added prior to calling
180 // this.
181 void RequestArcDataRemoval();
182
176 // Called from the Chrome OS metrics provider to record Arc.State 183 // Called from the Chrome OS metrics provider to record Arc.State
177 // periodically. 184 // periodically.
178 void RecordArcState(); 185 void RecordArcState();
179 186
180 // ArcSupportHost::Observer: 187 // ArcSupportHost::Observer:
181 void OnWindowClosed() override; 188 void OnWindowClosed() override;
182 void OnTermsAgreed(bool is_metrics_enabled, 189 void OnTermsAgreed(bool is_metrics_enabled,
183 bool is_backup_and_restore_enabled, 190 bool is_backup_and_restore_enabled,
184 bool is_location_service_enabled) override; 191 bool is_location_service_enabled) override;
185 void OnRetryClicked() override; 192 void OnRetryClicked() override;
186 void OnSendFeedbackClicked() override; 193 void OnSendFeedbackClicked() override;
187 194
188 // StopArc(), then restart. Between them data clear may happens. 195 // StopArc(), then restart. Between them data clear may happens.
189 // This is a special method to support enterprise device lost case. 196 // This is a special method to support enterprise device lost case.
190 // This can be called only when ARC is running. 197 // This can be called only when ARC is running.
191 void StopAndEnableArc(); 198 void StopAndEnableArc();
192 199
193 // Removes the data if ARC is stopped. Otherwise, queue to remove the data
194 // on ARC is stopped. A log statement with the removal reason must be added
195 // prior to calling RemoveArcData().
196 void RemoveArcData();
197
198 ArcSupportHost* support_host() { return support_host_.get(); } 200 ArcSupportHost* support_host() { return support_host_.get(); }
199 201
200 // TODO(hidehiko): Get rid of the getter by migration between ArcAuthContext 202 // TODO(hidehiko): Get rid of the getter by migration between ArcAuthContext
201 // and ArcAuthInfoFetcher. 203 // and ArcAuthInfoFetcher.
202 ArcAuthContext* auth_context() { return context_.get(); } 204 ArcAuthContext* auth_context() { return context_.get(); }
203 205
204 // On provisioning completion (regardless of whether successfully done or 206 // On provisioning completion (regardless of whether successfully done or
205 // not), this is called with its status. On success, called with 207 // not), this is called with its status. On success, called with
206 // ProvisioningResult::SUCCESS, otherwise |result| is the error reason. 208 // ProvisioningResult::SUCCESS, otherwise |result| is the error reason.
207 void OnProvisioningFinished(ProvisioningResult result); 209 void OnProvisioningFinished(ProvisioningResult result);
(...skipping 17 matching lines...) Expand all
225 227
226 // Invoking StartArc() only for testing, e.g., to emulate accepting Terms of 228 // Invoking StartArc() only for testing, e.g., to emulate accepting Terms of
227 // Service then passing Android management check successfully. 229 // Service then passing Android management check successfully.
228 void StartArcForTesting() { StartArc(); } 230 void StartArcForTesting() { StartArc(); }
229 231
230 private: 232 private:
231 // RequestEnable() has a check in order not to trigger starting procedure 233 // RequestEnable() has a check in order not to trigger starting procedure
232 // twice. This method can be called to bypass that check when restarting. 234 // twice. This method can be called to bypass that check when restarting.
233 void RequestEnableImpl(); 235 void RequestEnableImpl();
234 236
235 // Negotiates the terms of service to user. 237 // Negotiates the terms of service to user, if necessary.
236 void StartTermsOfServiceNegotiation(); 238 // Otherwise, move to StartAndroidManagementCheck().
239 void MaybeStartTermsOfServiceNegotiation();
237 void OnTermsOfServiceNegotiated(bool accepted); 240 void OnTermsOfServiceNegotiated(bool accepted);
238 241
239 // Returns true if Terms of Service negotiation is needed. Otherwise false. 242 // Returns true if Terms of Service negotiation is needed. Otherwise false.
240 // TODO(crbug.com/698418): Write unittest for this utility after extracting 243 // TODO(crbug.com/698418): Write unittest for this utility after extracting
241 // ToS related code from ArcSessionManager into a dedicated class. 244 // ToS related code from ArcSessionManager into a dedicated class.
242 bool IsArcTermsOfServiceNegotiationNeeded() const; 245 bool IsArcTermsOfServiceNegotiationNeeded() const;
243 246
244 void SetState(State state); 247 void SetState(State state);
245 void ShutdownSession(); 248 void ShutdownSession();
246 void OnArcDataRemoved(bool success);
247 void OnArcSignInTimeout(); 249 void OnArcSignInTimeout();
248 250
249 // Starts Android management check. This is for first boot case (= Opt-in 251 // Starts Android management check. This is for first boot case (= Opt-in
250 // or OOBE flow case). In secondary or later ARC enabling, the check should 252 // or OOBE flow case). In secondary or later ARC enabling, the check should
251 // run in background. 253 // run in background.
252 void StartAndroidManagementCheck(); 254 void StartAndroidManagementCheck();
253 255
254 // Called when the Android management check is done in opt-in flow or 256 // Called when the Android management check is done in opt-in flow or
255 // OOBE flow. 257 // OOBE flow.
256 void OnAndroidManagementChecked( 258 void OnAndroidManagementChecked(
(...skipping 20 matching lines...) Expand all
277 // Requests to stop ARC instnace. This resets two persistent flags: 279 // Requests to stop ARC instnace. This resets two persistent flags:
278 // kArcSignedIn and kArcTermsAccepted, so that, in next enabling, 280 // kArcSignedIn and kArcTermsAccepted, so that, in next enabling,
279 // it is started from Terms of Service negotiation. 281 // it is started from Terms of Service negotiation.
280 // TODO(hidehiko): Introduce STOPPING state, and this function should 282 // TODO(hidehiko): Introduce STOPPING state, and this function should
281 // transition to it. 283 // transition to it.
282 void StopArc(); 284 void StopArc();
283 285
284 // ArcSessionRunner::Observer: 286 // ArcSessionRunner::Observer:
285 void OnSessionStopped(ArcStopReason reason, bool restarting) override; 287 void OnSessionStopped(ArcStopReason reason, bool restarting) override;
286 288
289 // Starts to remove ARC data, if it is requested via RequestArcDataRemoval().
290 // On completion, OnArcDataRemoved() is called.
291 // If not requested, just skipping the data removal, and moves to
292 // MaybeReenableArc() directly.
293 void MaybeStartArcDataRemoval();
294 void OnArcDataRemoved(bool success);
295
287 // On ARC session stopped and/or data removal completion, this is called 296 // On ARC session stopped and/or data removal completion, this is called
288 // so that, if necessary, ARC session is restarted. 297 // so that, if necessary, ARC session is restarted.
289 // TODO(hidehiko): This can be removed after the racy state machine 298 // TODO(hidehiko): This can be removed after the racy state machine
290 // is fixed. 299 // is fixed.
291 void MaybeReenableArc(); 300 void MaybeReenableArc();
292 301
293 std::unique_ptr<ArcSessionRunner> arc_session_runner_; 302 std::unique_ptr<ArcSessionRunner> arc_session_runner_;
294 303
295 // Unowned pointer. Keeps current profile. 304 // Unowned pointer. Keeps current profile.
296 Profile* profile_ = nullptr; 305 Profile* profile_ = nullptr;
(...skipping 29 matching lines...) Expand all
326 DISALLOW_COPY_AND_ASSIGN(ArcSessionManager); 335 DISALLOW_COPY_AND_ASSIGN(ArcSessionManager);
327 }; 336 };
328 337
329 // Outputs the stringified |state| to |os|. This is only for logging purposes. 338 // Outputs the stringified |state| to |os|. This is only for logging purposes.
330 std::ostream& operator<<(std::ostream& os, 339 std::ostream& operator<<(std::ostream& os,
331 const ArcSessionManager::State& state); 340 const ArcSessionManager::State& state);
332 341
333 } // namespace arc 342 } // namespace arc
334 343
335 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_SESSION_MANAGER_H_ 344 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_SESSION_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698