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 #include "chrome/browser/sync/profile_sync_test_util.h" | 5 #include "chrome/browser/sync/profile_sync_test_util.h" |
6 | 6 |
| 7 #include "base/bind.h" |
7 #include "base/task.h" | 8 #include "base/task.h" |
8 #include "base/threading/thread.h" | 9 #include "base/threading/thread.h" |
9 | 10 |
10 ProfileSyncServiceObserverMock::ProfileSyncServiceObserverMock() {} | 11 ProfileSyncServiceObserverMock::ProfileSyncServiceObserverMock() {} |
11 | 12 |
12 ProfileSyncServiceObserverMock::~ProfileSyncServiceObserverMock() {} | 13 ProfileSyncServiceObserverMock::~ProfileSyncServiceObserverMock() {} |
13 | 14 |
14 ThreadNotificationService::ThreadNotificationService( | 15 ThreadNotificationService::ThreadNotificationService( |
15 base::Thread* notification_thread) | 16 base::Thread* notification_thread) |
16 : done_event_(false, false), | 17 : done_event_(false, false), |
17 notification_thread_(notification_thread) {} | 18 notification_thread_(notification_thread) {} |
18 | 19 |
19 void ThreadNotificationService::Init() { | 20 void ThreadNotificationService::Init() { |
20 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 21 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
21 notification_thread_->message_loop()->PostTask( | 22 notification_thread_->message_loop()->PostTask( |
22 FROM_HERE, | 23 FROM_HERE, |
23 NewRunnableMethod(this, &ThreadNotificationService::InitTask)); | 24 base::Bind(&ThreadNotificationService::InitTask, this)); |
24 done_event_.Wait(); | 25 done_event_.Wait(); |
25 } | 26 } |
26 | 27 |
27 void ThreadNotificationService::TearDown() { | 28 void ThreadNotificationService::TearDown() { |
28 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 29 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
29 notification_thread_->message_loop()->PostTask( | 30 notification_thread_->message_loop()->PostTask( |
30 FROM_HERE, | 31 FROM_HERE, |
31 NewRunnableMethod(this, | 32 base::Bind(&ThreadNotificationService::TearDownTask, this)); |
32 &ThreadNotificationService::TearDownTask)); | |
33 done_event_.Wait(); | 33 done_event_.Wait(); |
34 } | 34 } |
35 | 35 |
36 ThreadNotificationService::~ThreadNotificationService() {} | 36 ThreadNotificationService::~ThreadNotificationService() {} |
37 | 37 |
38 void ThreadNotificationService::InitTask() { | 38 void ThreadNotificationService::InitTask() { |
39 service_.reset(new NotificationServiceImpl()); | 39 service_.reset(new NotificationServiceImpl()); |
40 done_event_.Signal(); | 40 done_event_.Signal(); |
41 } | 41 } |
42 | 42 |
(...skipping 10 matching lines...) Expand all Loading... |
53 const content::NotificationDetails& details) { | 53 const content::NotificationDetails& details) { |
54 Notify(type, content::NotificationService::AllSources(), details); | 54 Notify(type, content::NotificationService::AllSources(), details); |
55 } | 55 } |
56 | 56 |
57 void ThreadNotifier::Notify(int type, | 57 void ThreadNotifier::Notify(int type, |
58 const content::NotificationSource& source, | 58 const content::NotificationSource& source, |
59 const content::NotificationDetails& details) { | 59 const content::NotificationDetails& details) { |
60 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 60 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
61 notify_thread_->message_loop()->PostTask( | 61 notify_thread_->message_loop()->PostTask( |
62 FROM_HERE, | 62 FROM_HERE, |
63 NewRunnableMethod(this, | 63 base::Bind(&ThreadNotifier::NotifyTask, this, type, source, details)); |
64 &ThreadNotifier::NotifyTask, | |
65 type, | |
66 source, | |
67 details)); | |
68 done_event_.Wait(); | 64 done_event_.Wait(); |
69 } | 65 } |
70 | 66 |
71 ThreadNotifier::~ThreadNotifier() {} | 67 ThreadNotifier::~ThreadNotifier() {} |
72 | 68 |
73 void ThreadNotifier::NotifyTask(int type, | 69 void ThreadNotifier::NotifyTask(int type, |
74 const content::NotificationSource& source, | 70 const content::NotificationSource& source, |
75 const content::NotificationDetails& details) { | 71 const content::NotificationDetails& details) { |
76 content::NotificationService::current()->Notify(type, source, details); | 72 content::NotificationService::current()->Notify(type, source, details); |
77 done_event_.Signal(); | 73 done_event_.Signal(); |
78 } | 74 } |
OLD | NEW |