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

Unified Diff: chrome/browser/ui/app_list/arc/arc_package_sync_data_type_controller.cc

Issue 2389763003: arc: Fix race when arc package sync service starts. (Closed)
Patch Set: Add Check in case ArcAppListPrefs gets deleted early. Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/app_list/arc/arc_package_sync_data_type_controller.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/app_list/arc/arc_package_sync_data_type_controller.cc
diff --git a/chrome/browser/ui/app_list/arc/arc_package_sync_data_type_controller.cc b/chrome/browser/ui/app_list/arc/arc_package_sync_data_type_controller.cc
index fe5472f102187f8be0d9c0545a41b3f718f47b38..d620e3db6accb25373be1e68adbc8c307c49b4f1 100644
--- a/chrome/browser/ui/app_list/arc/arc_package_sync_data_type_controller.cc
+++ b/chrome/browser/ui/app_list/arc/arc_package_sync_data_type_controller.cc
@@ -6,9 +6,7 @@
#include "chrome/browser/chromeos/arc/arc_auth_service.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h"
#include "chrome/common/pref_names.h"
-#include "components/arc/arc_bridge_service.h"
#include "components/prefs/pref_service.h"
#include "components/sync/driver/pref_names.h"
#include "components/sync/driver/sync_client.h"
@@ -40,16 +38,9 @@ ArcPackageSyncDataTypeController::ArcPackageSyncDataTypeController(
prefs::kArcEnabled,
base::Bind(&ArcPackageSyncDataTypeController::OnArcEnabledPrefChanged,
base::Unretained(this)));
-
- arc::ArcBridgeService* arc_bridge_service = arc::ArcBridgeService::Get();
- if (arc_bridge_service)
- arc_bridge_service->app()->AddObserver(this);
}
ArcPackageSyncDataTypeController::~ArcPackageSyncDataTypeController() {
- arc::ArcBridgeService* arc_bridge_service = arc::ArcBridgeService::Get();
- if (arc_bridge_service)
- arc_bridge_service->app()->RemoveObserver(this);
}
bool ArcPackageSyncDataTypeController::ReadyForStart() const {
@@ -57,13 +48,13 @@ bool ArcPackageSyncDataTypeController::ReadyForStart() const {
return IsArcEnabled(profile_) && ShouldSyncArc();
}
-void ArcPackageSyncDataTypeController::OnInstanceReady() {
+void ArcPackageSyncDataTypeController::OnPackageListInitialRefreshed() {
// model_normal_start_ is true by default. Normally,
- // ArcPackageSyncDataTypeController::StartModels() gets called before Arc is
- // ready. But in integration test, the order can be either way. If
- // OnInstanceReady comes before ArcPackageSyncDataTypeController
- // ::StartModels(), this function is no-op and waits for StartModels() to be
- // called.
+ // ArcPackageSyncDataTypeController::StartModels() gets called before Arc
+ // package list is refreshed. But in integration test, the order can be either
+ // way. If OnPackageListInitialRefreshed comes before
+ // ArcPackageSyncDataTypeController ::StartModels(), this function is no-op
+ // and waits for StartModels() to be called.
if (model_normal_start_)
return;
@@ -73,11 +64,19 @@ void ArcPackageSyncDataTypeController::OnInstanceReady() {
bool ArcPackageSyncDataTypeController::StartModels() {
DCHECK_EQ(state(), MODEL_STARTING);
- ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_);
- model_normal_start_ = prefs && prefs->app_instance_holder()->has_instance();
+ ArcAppListPrefs* arc_prefs = ArcAppListPrefs::Get(profile_);
+ DCHECK(arc_prefs);
+ model_normal_start_ = arc_prefs->package_list_initial_refreshed();
+ arc_prefs->AddObserver(this);
return model_normal_start_;
}
+void ArcPackageSyncDataTypeController::StopModels() {
+ ArcAppListPrefs* arc_prefs = ArcAppListPrefs::Get(profile_);
+ if (arc_prefs)
+ arc_prefs->RemoveObserver(this);
+}
+
void ArcPackageSyncDataTypeController::OnArcEnabledPrefChanged() {
DCHECK(CalledOnValidThread());
« no previous file with comments | « chrome/browser/ui/app_list/arc/arc_package_sync_data_type_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698