Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(807)

Side by Side Diff: chrome/test/base/thread_observer_helper.h

Issue 8520032: base::Bind fix (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
10 #include "base/synchronization/waitable_event.h" 11 #include "base/synchronization/waitable_event.h"
11 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
12 #include "content/public/browser/notification_registrar.h" 13 #include "content/public/browser/notification_registrar.h"
13 #include "content/test/notification_observer_mock.h" 14 #include "content/test/notification_observer_mock.h"
14 15
15 // Helper class to add and remove observers on a non-UI thread from 16 // Helper class to add and remove observers on a non-UI thread from
16 // the UI thread. 17 // the UI thread.
17 template <class T, typename Traits> 18 template <class T, typename Traits>
18 class ThreadObserverHelper : public base::RefCountedThreadSafe<T, Traits> { 19 class ThreadObserverHelper : public base::RefCountedThreadSafe<T, Traits> {
19 public: 20 public:
20 explicit ThreadObserverHelper(content::BrowserThread::ID id) 21 explicit ThreadObserverHelper(content::BrowserThread::ID id)
21 : id_(id), done_event_(false, false) {} 22 : id_(id), done_event_(false, false) {}
22 23
23 void Init() { 24 void Init() {
24 using content::BrowserThread; 25 using content::BrowserThread;
25 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 26 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
26 BrowserThread::PostTask( 27 BrowserThread::PostTask(
27 id_, 28 id_,
28 FROM_HERE, 29 FROM_HERE,
29 NewRunnableMethod(this, &ThreadObserverHelper::RegisterObserversTask)); 30 base::Bind(&ThreadObserverHelper::RegisterObserversTask, this));
30 done_event_.Wait(); 31 done_event_.Wait();
31 } 32 }
32 33
33 virtual ~ThreadObserverHelper() { 34 virtual ~ThreadObserverHelper() {
34 DCHECK(content::BrowserThread::CurrentlyOn(id_)); 35 DCHECK(content::BrowserThread::CurrentlyOn(id_));
35 registrar_.RemoveAll(); 36 registrar_.RemoveAll();
36 } 37 }
37 38
38 content::NotificationObserverMock* observer() { 39 content::NotificationObserverMock* observer() {
39 return &observer_; 40 return &observer_;
(...skipping 23 matching lines...) Expand all
63 DBThreadObserverHelper, 64 DBThreadObserverHelper,
64 content::BrowserThread::DeleteOnDBThread> DBThreadObserverHelperBase; 65 content::BrowserThread::DeleteOnDBThread> DBThreadObserverHelperBase;
65 66
66 class DBThreadObserverHelper : public DBThreadObserverHelperBase { 67 class DBThreadObserverHelper : public DBThreadObserverHelperBase {
67 public: 68 public:
68 DBThreadObserverHelper() : 69 DBThreadObserverHelper() :
69 DBThreadObserverHelperBase(content::BrowserThread::DB) {} 70 DBThreadObserverHelperBase(content::BrowserThread::DB) {}
70 }; 71 };
71 72
72 #endif // CHROME_TEST_BASE_THREAD_OBSERVER_HELPER_H_ 73 #endif // CHROME_TEST_BASE_THREAD_OBSERVER_HELPER_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698