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

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

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.h
diff --git a/ios/chrome/browser/ui/settings/personal_data_manager_data_changed_observer.h b/ios/chrome/browser/ui/settings/personal_data_manager_data_changed_observer.h
new file mode 100644
index 0000000000000000000000000000000000000000..5b4ae402d2434c0cbba003841ef4117e25e647be
--- /dev/null
+++ b/ios/chrome/browser/ui/settings/personal_data_manager_data_changed_observer.h
@@ -0,0 +1,45 @@
+// 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 IOS_CHROME_BROWSER_UI_SETTINGS_PERSONAL_DATA_MANAGER_DATA_CHANGED_OBSERVER_H_
+#define IOS_CHROME_BROWSER_UI_SETTINGS_PERSONAL_DATA_MANAGER_DATA_CHANGED_OBSERVER_H_
+
+#include "base/macros.h"
+#include "base/run_loop.h"
+#include "components/autofill/core/browser/personal_data_manager_observer.h"
+
+namespace autofill {
+class PersonalDataManager;
+}
+
+// Helper class to allow waiting until the asynchronous operation on the
+// autofill::PersonalDataManager completed. Need to be used like this:
+//
+// autofill::PersonalDataManager* personal_data_manager = ...;
+// PersonalDataManagerDataChangedObserver observer(personal_data_manager);
+// personal_data_manager->...(); // Starts some asynchronous operation.
+// observer.Wait();
+//
+class PersonalDataManagerDataChangedObserver
+ : public autofill::PersonalDataManagerObserver {
+ public:
+ PersonalDataManagerDataChangedObserver(
+ autofill::PersonalDataManager* personal_data_manager);
+ ~PersonalDataManagerDataChangedObserver() override;
+
+ // Blocks until |OnPersonalDataChanged| is invoked at the end of the
+ // asynchronous modification on the PersonalDataManager.
+ void Wait();
+
+ // autofill::PersonalDataManagerObserver implementation.
+ void OnPersonalDataChanged() override;
+
+ private:
+ autofill::PersonalDataManager* personal_data_manager_;
+ base::RunLoop run_loop_;
+
+ DISALLOW_COPY_AND_ASSIGN(PersonalDataManagerDataChangedObserver);
+};
+
+#endif // IOS_CHROME_BROWSER_UI_SETTINGS_PERSONAL_DATA_MANAGER_DATA_CHANGED_OBSERVER_H_

Powered by Google App Engine
This is Rietveld 408576698