| OLD | NEW |
| (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 #ifndef IOS_CHROME_BROWSER_UI_SETTINGS_PERSONAL_DATA_MANAGER_DATA_CHANGED_OBSERV
ER_H_ |
| 6 #define IOS_CHROME_BROWSER_UI_SETTINGS_PERSONAL_DATA_MANAGER_DATA_CHANGED_OBSERV
ER_H_ |
| 7 |
| 8 #include "base/macros.h" |
| 9 #include "base/run_loop.h" |
| 10 #include "components/autofill/core/browser/personal_data_manager_observer.h" |
| 11 |
| 12 namespace autofill { |
| 13 class PersonalDataManager; |
| 14 } |
| 15 |
| 16 // Helper class to allow waiting until the asynchronous operation on the |
| 17 // autofill::PersonalDataManager completed. Need to be used like this: |
| 18 // |
| 19 // autofill::PersonalDataManager* personal_data_manager = ...; |
| 20 // PersonalDataManagerDataChangedObserver observer(personal_data_manager); |
| 21 // personal_data_manager->...(); // Starts some asynchronous operation. |
| 22 // observer.Wait(); |
| 23 // |
| 24 class PersonalDataManagerDataChangedObserver |
| 25 : public autofill::PersonalDataManagerObserver { |
| 26 public: |
| 27 PersonalDataManagerDataChangedObserver( |
| 28 autofill::PersonalDataManager* personal_data_manager); |
| 29 ~PersonalDataManagerDataChangedObserver() override; |
| 30 |
| 31 // Blocks until |OnPersonalDataChanged| is invoked at the end of the |
| 32 // asynchronous modification on the PersonalDataManager. |
| 33 void Wait(); |
| 34 |
| 35 // autofill::PersonalDataManagerObserver implementation. |
| 36 void OnPersonalDataChanged() override; |
| 37 |
| 38 private: |
| 39 autofill::PersonalDataManager* personal_data_manager_; |
| 40 base::RunLoop run_loop_; |
| 41 |
| 42 DISALLOW_COPY_AND_ASSIGN(PersonalDataManagerDataChangedObserver); |
| 43 }; |
| 44 |
| 45 #endif // IOS_CHROME_BROWSER_UI_SETTINGS_PERSONAL_DATA_MANAGER_DATA_CHANGED_OBS
ERVER_H_ |
| OLD | NEW |