| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Contains code shared by all browsing data browsertests. | 5 // Contains code shared by all browsing data browsertests. |
| 6 | 6 |
| 7 #ifndef CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_HELPER_BROWSERTEST_H_ | 7 #ifndef CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_HELPER_BROWSERTEST_H_ |
| 8 #define CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_HELPER_BROWSERTEST_H_ | 8 #define CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_HELPER_BROWSERTEST_H_ |
| 9 | 9 |
| 10 #include <list> | 10 #include <list> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
| 15 | 15 |
| 16 // This template can be used for the StartFetching methods of the browsing data | 16 // This template can be used for the StartFetching methods of the browsing data |
| 17 // helper classes. It is supposed to be instantiated with the respective | 17 // helper classes. It is supposed to be instantiated with the respective |
| 18 // browsing data info type. | 18 // browsing data info type. |
| 19 template <typename T> | 19 template <typename T> |
| 20 class BrowsingDataHelperCallback { | 20 class BrowsingDataHelperCallback { |
| 21 public: | 21 public: |
| 22 BrowsingDataHelperCallback() | 22 BrowsingDataHelperCallback() |
| 23 : has_result_(false) { | 23 : has_result_(false) { |
| 24 } | 24 } |
| 25 | 25 |
| 26 const std::list<T>& result() { | 26 const std::list<T>& result() { |
| 27 MessageLoop::current()->Run(); | 27 base::MessageLoop::current()->Run(); |
| 28 DCHECK(has_result_); | 28 DCHECK(has_result_); |
| 29 return result_; | 29 return result_; |
| 30 } | 30 } |
| 31 | 31 |
| 32 void callback(const std::list<T>& info) { | 32 void callback(const std::list<T>& info) { |
| 33 result_ = info; | 33 result_ = info; |
| 34 has_result_ = true; | 34 has_result_ = true; |
| 35 MessageLoop::current()->Quit(); | 35 base::MessageLoop::current()->Quit(); |
| 36 } | 36 } |
| 37 | 37 |
| 38 private: | 38 private: |
| 39 bool has_result_; | 39 bool has_result_; |
| 40 std::list<T> result_; | 40 std::list<T> result_; |
| 41 | 41 |
| 42 DISALLOW_COPY_AND_ASSIGN(BrowsingDataHelperCallback); | 42 DISALLOW_COPY_AND_ASSIGN(BrowsingDataHelperCallback); |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_HELPER_BROWSERTEST_H_ | 45 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_HELPER_BROWSERTEST_H_ |
| OLD | NEW |