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