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

Side by Side Diff: components/arc/user_data/arc_user_data_service.cc

Issue 1966133002: Run RemoveArcData after a user has opted out (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: clean up boolean logic Created 4 years, 7 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
(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 #include "components/arc/user_data/arc_user_data_service.h"
6
7 #include "chromeos/dbus/dbus_thread_manager.h"
8 #include "chromeos/dbus/session_manager_client.h"
9 #include "components/arc/arc_service_manager.h"
10 #include "components/signin/core/account_id/account_id.h"
11 #include "components/user_manager/user_manager.h"
12
13 namespace arc {
14
15 ArcUserDataService::ArcUserDataService(ArcServiceManager* arc_service_manager) {
16 ArcBridgeService::Get()->AddObserver(this);
17 arc_service_manager_ = arc_service_manager;
Daniel Erat 2016/05/20 17:41:06 assign this in an initialization list instead
dspaid 2016/05/23 01:22:37 Done.
18 }
19
20 ArcUserDataService::~ArcUserDataService() {
21 DCHECK(thread_checker_.CalledOnValidThread());
22 ArcBridgeService::Get()->RemoveObserver(this);
23 }
24
25 void ArcUserDataService::OnBridgeStopped() {
Daniel Erat 2016/05/20 17:41:06 method order in .cc should match .h
dspaid 2016/05/23 01:22:37 Done.
26 DCHECK(thread_checker_.CalledOnValidThread());
27 const AccountId& account_id =
28 user_manager::UserManager::Get()->GetPrimaryUser()->GetAccountId();
29 if (account_id != user_prefs_account_id_) {
Daniel Erat 2016/05/20 17:41:05 how does this happen? would it be cleaner to check
dspaid 2016/05/23 01:22:37 As far as I know it shouldn't happen. But if for
Daniel Erat 2016/05/24 14:51:22 mind making this a LOG(ERROR), then?
dspaid 2016/05/25 00:06:48 Done.
30 LOG(WARNING) << "User preferences not loaded for primary user";
Daniel Erat 2016/05/20 17:41:06 nit: include both ids in the warning message to ma
dspaid 2016/05/23 01:22:37 Done.
31 user_prefs_account_id_ = EmptyAccountId();
32 return;
33 }
34 ClearIfDisabled(account_id);
35 }
36
37 void ArcUserDataService::ClearIfDisabled(const AccountId& account_id) {
38 DCHECK(thread_checker_.CalledOnValidThread());
39 user_prefs_account_id_ = account_id;
Daniel Erat 2016/05/20 17:41:06 i'm confused about how this works. it looks like t
dspaid 2016/05/23 01:22:37 Yes, ClearIfDisabled is called explicitly from OnP
40 if (ArcBridgeService::Get()->state() != ArcBridgeService::State::STOPPED) {
41 LOG(ERROR) << "ARC instance not stopped, user data can't be cleared";
42 return;
43 }
44 if (arc_service_manager_->IsArcEnabled()) {
45 return;
46 }
47 chromeos::SessionManagerClient* session_manager_client =
48 chromeos::DBusThreadManager::Get()->GetSessionManagerClient();
49 session_manager_client->RemoveArcData();
50 }
51
52 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698