Commit b8467997 authored by hidehiko's avatar hidehiko Committed by Commit bot

Remove unused ArcUserDataService.

It used to be used for data/ dir removal, but it is now
integrated into ArcSessionManager.
Remove the unused class now.

BUG=657687
BUG=b/31079732
TEST=Ran bots.

Review-Url: https://codereview.chromium.org/2573463002
Cr-Commit-Position: refs/heads/master@{#437983}
parent b7a4d89f
......@@ -36,7 +36,6 @@
#include "components/arc/obb_mounter/arc_obb_mounter_bridge.h"
#include "components/arc/power/arc_power_bridge.h"
#include "components/arc/storage_manager/arc_storage_manager.h"
#include "components/arc/user_data/arc_user_data_service.h"
#include "components/prefs/pref_member.h"
#include "content/public/browser/browser_thread.h"
#include "ui/arc/notification/arc_notification_manager.h"
......
......@@ -11,7 +11,6 @@
#include "chrome/browser/chromeos/arc/arc_session_manager.h"
#include "components/arc/arc_bridge_service.h"
#include "components/arc/arc_service_manager.h"
#include "components/arc/user_data/arc_user_data_service.h"
namespace arc {
......
......@@ -64,8 +64,6 @@ static_library("arc") {
"power/arc_power_bridge.h",
"storage_manager/arc_storage_manager.cc",
"storage_manager/arc_storage_manager.h",
"user_data/arc_user_data_service.cc",
"user_data/arc_user_data_service.h",
]
public_deps = [
......
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/arc/user_data/arc_user_data_service.h"
#include <utility>
#include "base/command_line.h"
#include "chromeos/chromeos_switches.h"
#include "chromeos/cryptohome/cryptohome_parameters.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "components/prefs/pref_member.h"
#include "components/signin/core/account_id/account_id.h"
#include "components/user_manager/user_manager.h"
namespace arc {
ArcUserDataService::ArcUserDataService(
ArcBridgeService* bridge_service,
std::unique_ptr<BooleanPrefMember> arc_enabled_pref,
const AccountId& account_id)
: ArcService(bridge_service),
arc_enabled_pref_(std::move(arc_enabled_pref)),
primary_user_account_id_(account_id),
weak_ptr_factory_(this) {
arc_bridge_service()->AddObserver(this);
pref_change_registrar_.Init(arc_enabled_pref_->prefs());
pref_change_registrar_.Add(
arc_enabled_pref_->GetPrefName(),
base::Bind(&ArcUserDataService::OnOptInPreferenceChanged,
weak_ptr_factory_.GetWeakPtr()));
WipeIfRequired();
}
ArcUserDataService::~ArcUserDataService() {
DCHECK(thread_checker_.CalledOnValidThread());
arc_bridge_service()->RemoveObserver(this);
}
void ArcUserDataService::OnBridgeStopped(ArcBridgeService::StopReason reason) {
DCHECK(thread_checker_.CalledOnValidThread());
const AccountId& account_id =
user_manager::UserManager::Get()->GetPrimaryUser()->GetAccountId();
if (account_id != primary_user_account_id_) {
LOG(ERROR) << "User preferences not loaded for "
<< primary_user_account_id_.GetUserEmail()
<< ", but current primary user is " << account_id.GetUserEmail();
primary_user_account_id_ = EmptyAccountId();
return;
}
WipeIfRequired();
}
void ArcUserDataService::RequireUserDataWiped(const ArcDataCallback& callback) {
VLOG(1) << "Require ARC user data to be wiped.";
arc_user_data_wipe_required_ = true;
callback_ = callback;
}
void ArcUserDataService::WipeIfRequired() {
DCHECK(thread_checker_.CalledOnValidThread());
if (!arc_bridge_service()->stopped()) {
LOG(ERROR) << "ARC instance not stopped, user data can't be wiped";
return;
}
if ((arc_enabled_pref_->GetValue() && !arc_user_data_wipe_required_) ||
base::CommandLine::ForCurrentProcess()->HasSwitch(
chromeos::switches::kDisableArcDataWipe)) {
return;
}
VLOG(1) << "Wipe ARC user data.";
arc_user_data_wipe_required_ = false;
const cryptohome::Identification cryptohome_id(primary_user_account_id_);
chromeos::SessionManagerClient* session_manager_client =
chromeos::DBusThreadManager::Get()->GetSessionManagerClient();
session_manager_client->RemoveArcData(cryptohome_id, callback_);
callback_.Reset();
}
void ArcUserDataService::OnOptInPreferenceChanged() {
if (!arc_enabled_pref_->GetValue())
arc_user_data_wipe_required_ = true;
}
} // namespace arc
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_ARC_USER_DATA_ARC_USER_DATA_SERVICE_H_
#define COMPONENTS_ARC_USER_DATA_ARC_USER_DATA_SERVICE_H_
#include <memory>
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/threading/thread_checker.h"
#include "chromeos/dbus/session_manager_client.h"
#include "components/arc/arc_bridge_service.h"
#include "components/arc/arc_service.h"
#include "components/prefs/pref_change_registrar.h"
#include "components/prefs/pref_member.h"
#include "components/signin/core/account_id/account_id.h"
namespace arc {
class ArcBridgeService;
// This class controls the lifecycle of ARC user data, removing it when
// necessary.
class ArcUserDataService : public ArcService,
public ArcBridgeService::Observer {
public:
explicit ArcUserDataService(
ArcBridgeService* arc_bridge_service,
std::unique_ptr<BooleanPrefMember> arc_enabled_pref,
const AccountId& account_id);
~ArcUserDataService() override;
using ArcDataCallback = chromeos::SessionManagerClient::ArcCallback;
// ArcBridgeService::Observer:
// Called whenever the arc bridge is stopped to potentially wipe data if
// the user has not opted in or it is required.
void OnBridgeStopped(ArcBridgeService::StopReason reason) override;
// Requires to wipe ARC user data after the next ARC bridge shutdown and call
// |callback| with an operation result.
void RequireUserDataWiped(const ArcDataCallback& callback);
private:
base::ThreadChecker thread_checker_;
// Checks if ARC is both stopped and disabled (not opt-in) or data wipe is
// required and triggers removal of user data.
void WipeIfRequired();
// Callback when the kArcEnabled preference changes. It watches for instances
// where the preference is disabled and remembers this so that it can wipe
// user data once the bridge has stopped.
void OnOptInPreferenceChanged();
const std::unique_ptr<BooleanPrefMember> arc_enabled_pref_;
// Account ID for the account for which we currently have opt-in information.
AccountId primary_user_account_id_;
// Registrar used to monitor ARC enabled state.
PrefChangeRegistrar pref_change_registrar_;
// Set to true when kArcEnabled goes from true to false or user data wipe is
// required and set to false again after user data has been wiped.
// This ensures data is wiped even if the user tries to enable ARC before the
// bridge has shut down.
bool arc_user_data_wipe_required_ = false;
// Callback object that is passed to RemoveArcData to be invoked with a
// result of ARC user data wipe.
// Set when ARC user data wipe is required by RequireUserDataWiped.
ArcDataCallback callback_;
base::WeakPtrFactory<ArcUserDataService> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(ArcUserDataService);
};
} // namespace arc
#endif // COMPONENTS_ARC_USER_DATA_ARC_USER_DATA_SERVICE_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment