| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_TEST_UTIL_H_ | 5 #ifndef CONTENT_PUBLIC_TEST_BROWSING_DATA_REMOVER_TEST_UTIL_H_ |
| 6 #define CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_TEST_UTIL_H_ | 6 #define CONTENT_PUBLIC_TEST_BROWSING_DATA_REMOVER_TEST_UTIL_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/scoped_observer.h" | 10 #include "base/scoped_observer.h" |
| 11 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 11 #include "content/public/browser/browsing_data_remover.h" |
| 12 #include "content/public/test/test_utils.h" | 12 #include "content/public/test/test_utils.h" |
| 13 | 13 |
| 14 namespace content { |
| 15 |
| 14 // This class can be used to wait for a BrowsingDataRemover to complete | 16 // This class can be used to wait for a BrowsingDataRemover to complete |
| 15 // operation. It is not suitable for repeated use. | 17 // operation. It is not suitable for repeated use. |
| 16 class BrowsingDataRemoverCompletionObserver | 18 class BrowsingDataRemoverCompletionObserver |
| 17 : public BrowsingDataRemover::Observer { | 19 : public BrowsingDataRemover::Observer { |
| 18 public: | 20 public: |
| 19 explicit BrowsingDataRemoverCompletionObserver(BrowsingDataRemover* remover); | 21 explicit BrowsingDataRemoverCompletionObserver(BrowsingDataRemover* remover); |
| 20 ~BrowsingDataRemoverCompletionObserver() override; | 22 ~BrowsingDataRemoverCompletionObserver() override; |
| 21 | 23 |
| 22 void BlockUntilCompletion(); | 24 void BlockUntilCompletion(); |
| 23 | 25 |
| 24 protected: | 26 protected: |
| 25 // BrowsingDataRemover::Observer: | 27 // BrowsingDataRemover::Observer: |
| 26 void OnBrowsingDataRemoverDone() override; | 28 void OnBrowsingDataRemoverDone() override; |
| 27 | 29 |
| 28 private: | 30 private: |
| 29 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; | 31 scoped_refptr<MessageLoopRunner> message_loop_runner_; |
| 30 ScopedObserver<BrowsingDataRemover, BrowsingDataRemover::Observer> observer_; | 32 ScopedObserver<BrowsingDataRemover, BrowsingDataRemover::Observer> observer_; |
| 31 | 33 |
| 32 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemoverCompletionObserver); | 34 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemoverCompletionObserver); |
| 33 }; | 35 }; |
| 34 | 36 |
| 35 // The completion inhibitor can artificially delay completion of the browsing | 37 // The completion inhibitor can artificially delay completion of the browsing |
| 36 // data removal process. It is used during testing to simulate scenarios in | 38 // data removal process. It is used during testing to simulate scenarios in |
| 37 // which the deletion stalls or takes a very long time. | 39 // which the deletion stalls or takes a very long time. |
| 38 // | 40 // |
| 39 // This class will detach itself from |remover| upon its destruction. | 41 // This class will detach itself from |remover| upon its destruction. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 57 // Not owned by this class. If the pointer becomes invalid, the owner of | 59 // Not owned by this class. If the pointer becomes invalid, the owner of |
| 58 // this class is responsible for calling Reset(). | 60 // this class is responsible for calling Reset(). |
| 59 BrowsingDataRemover* remover_; | 61 BrowsingDataRemover* remover_; |
| 60 | 62 |
| 61 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; | 63 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; |
| 62 base::Closure continue_to_completion_callback_; | 64 base::Closure continue_to_completion_callback_; |
| 63 | 65 |
| 64 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemoverCompletionInhibitor); | 66 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemoverCompletionInhibitor); |
| 65 }; | 67 }; |
| 66 | 68 |
| 67 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_TEST_UTIL_H_ | 69 } // namespace content |
| 70 |
| 71 #endif // CONTENT_PUBLIC_TEST_BROWSING_DATA_REMOVER_TEST_UTIL_H_ |
| OLD | NEW |