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

Unified Diff: ios/chrome/browser/ui/settings/personal_data_manager_data_changed_observer.cc

Issue 2592173002: Fix ios_chrome_unittests to crash on DCHECK failure. (Closed)
Patch Set: Address comments Created 4 years 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
Index: ios/chrome/browser/ui/settings/personal_data_manager_data_changed_observer.cc
diff --git a/ios/chrome/browser/ui/settings/personal_data_manager_data_changed_observer.cc b/ios/chrome/browser/ui/settings/personal_data_manager_data_changed_observer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..05253e236fb7fe521499686cbe7157a1207f5995
--- /dev/null
+++ b/ios/chrome/browser/ui/settings/personal_data_manager_data_changed_observer.cc
@@ -0,0 +1,33 @@
+// 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 "ios/chrome/browser/ui/settings/personal_data_manager_data_changed_observer.h"
+
+#include "components/autofill/core/browser/personal_data_manager.h"
+
+PersonalDataManagerDataChangedObserver::PersonalDataManagerDataChangedObserver(
+ autofill::PersonalDataManager* personal_data_manager)
+ : personal_data_manager_(personal_data_manager) {
+ personal_data_manager_->AddObserver(this);
+}
+
+PersonalDataManagerDataChangedObserver::
+ ~PersonalDataManagerDataChangedObserver() {
+ personal_data_manager_->RemoveObserver(this);
+}
+
+void PersonalDataManagerDataChangedObserver::Wait() {
+ // If a test is blocked in that method, it means that OnPersonalDataChanged()
+ // was never called which indicates a bug in either the expectation of the
+ // test (no asynchronous operation is executed on the PersonalDataManager
+ // passed in the constructor) or in the utilisation of the
+ // PersonalDataManagerDataChangedObserver (there is a race-condition between
+ // sending the asynchronous operation and the creation of the observer, it can
+ // be fixed by creating the observer before sending the operation).
+ run_loop_.Run();
+}
+
+void PersonalDataManagerDataChangedObserver::OnPersonalDataChanged() {
+ run_loop_.QuitWhenIdle();
+}

Powered by Google App Engine
This is Rietveld 408576698