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 #ifndef CHROME_TEST_BASE_THREAD_OBSERVER_HELPER_H_ | 5 #ifndef CHROME_TEST_BASE_THREAD_OBSERVER_HELPER_H_ |
6 #define CHROME_TEST_BASE_THREAD_OBSERVER_HELPER_H_ | 6 #define CHROME_TEST_BASE_THREAD_OBSERVER_HELPER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/sequenced_task_runner_helpers.h" |
11 #include "base/synchronization/waitable_event.h" | 12 #include "base/synchronization/waitable_event.h" |
12 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
13 #include "content/public/browser/notification_registrar.h" | 14 #include "content/public/browser/notification_registrar.h" |
14 #include "content/test/notification_observer_mock.h" | 15 #include "content/test/notification_observer_mock.h" |
15 | 16 |
16 // Helper class to add and remove observers on a non-UI thread from | 17 // Helper class to add and remove observers on a non-UI thread from |
17 // the UI thread. | 18 // the UI thread. |
18 template <class T, typename Traits> | 19 template <class T, typename Traits> |
19 class ThreadObserverHelper : public base::RefCountedThreadSafe<T, Traits> { | 20 class ThreadObserverHelper : public base::RefCountedThreadSafe<T, Traits> { |
20 public: | 21 public: |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 | 62 |
62 class DBThreadObserverHelper; | 63 class DBThreadObserverHelper; |
63 typedef ThreadObserverHelper< | 64 typedef ThreadObserverHelper< |
64 DBThreadObserverHelper, | 65 DBThreadObserverHelper, |
65 content::BrowserThread::DeleteOnDBThread> DBThreadObserverHelperBase; | 66 content::BrowserThread::DeleteOnDBThread> DBThreadObserverHelperBase; |
66 | 67 |
67 class DBThreadObserverHelper : public DBThreadObserverHelperBase { | 68 class DBThreadObserverHelper : public DBThreadObserverHelperBase { |
68 public: | 69 public: |
69 DBThreadObserverHelper() : | 70 DBThreadObserverHelper() : |
70 DBThreadObserverHelperBase(content::BrowserThread::DB) {} | 71 DBThreadObserverHelperBase(content::BrowserThread::DB) {} |
| 72 |
| 73 protected: |
| 74 friend struct content::BrowserThread::DeleteOnThread< |
| 75 content::BrowserThread::DB>; |
| 76 friend class base::DeleteHelper<DBThreadObserverHelper>; |
| 77 |
| 78 virtual ~DBThreadObserverHelper() {} |
71 }; | 79 }; |
72 | 80 |
73 #endif // CHROME_TEST_BASE_THREAD_OBSERVER_HELPER_H_ | 81 #endif // CHROME_TEST_BASE_THREAD_OBSERVER_HELPER_H_ |
OLD | NEW |