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