OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_THREAD_OBSERVER_HELPER_H__ | 5 #ifndef CHROME_TEST_THREAD_OBSERVER_HELPER_H__ |
6 #define CHROME_TEST_THREAD_OBSERVER_HELPER_H__ | 6 #define CHROME_TEST_THREAD_OBSERVER_HELPER_H__ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/ref_counted.h" | 9 #include "base/ref_counted.h" |
10 #include "base/waitable_event.h" | 10 #include "base/waitable_event.h" |
11 #include "chrome/browser/browser_thread.h" | 11 #include "chrome/browser/browser_thread.h" |
12 #include "chrome/common/notification_observer_mock.h" | 12 #include "chrome/common/notification_observer_mock.h" |
13 #include "chrome/common/notification_registrar.h" | 13 #include "chrome/common/notification_registrar.h" |
14 #include "chrome/common/notification_service.h" | |
15 | 14 |
16 // Helper class to add and remove observers on a non-UI thread from | 15 // Helper class to add and remove observers on a non-UI thread from |
17 // the UI thread. | 16 // the UI thread. |
18 template <class T, typename Traits> | 17 template <class T, typename Traits> |
19 class ThreadObserverHelper : public base::RefCountedThreadSafe<T, Traits> { | 18 class ThreadObserverHelper : public base::RefCountedThreadSafe<T, Traits> { |
20 public: | 19 public: |
21 explicit ThreadObserverHelper(BrowserThread::ID id) | 20 explicit ThreadObserverHelper(BrowserThread::ID id) |
22 : id_(id), done_event_(false, false) {} | 21 : id_(id), done_event_(false, false) {} |
23 | 22 |
24 void Init() { | 23 void Init() { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 typedef ThreadObserverHelper< | 61 typedef ThreadObserverHelper< |
63 DBThreadObserverHelper, | 62 DBThreadObserverHelper, |
64 BrowserThread::DeleteOnDBThread> DBThreadObserverHelperBase; | 63 BrowserThread::DeleteOnDBThread> DBThreadObserverHelperBase; |
65 | 64 |
66 class DBThreadObserverHelper : public DBThreadObserverHelperBase { | 65 class DBThreadObserverHelper : public DBThreadObserverHelperBase { |
67 public: | 66 public: |
68 DBThreadObserverHelper() : DBThreadObserverHelperBase(BrowserThread::DB) {} | 67 DBThreadObserverHelper() : DBThreadObserverHelperBase(BrowserThread::DB) {} |
69 }; | 68 }; |
70 | 69 |
71 #endif // CHROME_TEST_THREAD_OBSERVER_HELPER_H__ | 70 #endif // CHROME_TEST_THREAD_OBSERVER_HELPER_H__ |
OLD | NEW |