| 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/bind.h" |
| 8 #include "base/location.h" |
| 9 #include "base/single_thread_task_runner.h" |
| 8 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
| 9 | 11 |
| 10 using content::BrowserThread; | 12 using content::BrowserThread; |
| 11 | 13 |
| 12 SyncServiceObserverMock::SyncServiceObserverMock() { | 14 SyncServiceObserverMock::SyncServiceObserverMock() { |
| 13 } | 15 } |
| 14 | 16 |
| 15 SyncServiceObserverMock::~SyncServiceObserverMock() { | 17 SyncServiceObserverMock::~SyncServiceObserverMock() { |
| 16 } | 18 } |
| 17 | 19 |
| 18 ThreadNotifier::ThreadNotifier(base::Thread* notify_thread) | 20 ThreadNotifier::ThreadNotifier(base::Thread* notify_thread) |
| 19 : done_event_(false, false), | 21 : done_event_(false, false), |
| 20 notify_thread_(notify_thread) {} | 22 notify_thread_(notify_thread) {} |
| 21 | 23 |
| 22 void ThreadNotifier::Notify(int type, | 24 void ThreadNotifier::Notify(int type, |
| 23 const content::NotificationDetails& details) { | 25 const content::NotificationDetails& details) { |
| 24 Notify(type, content::NotificationService::AllSources(), details); | 26 Notify(type, content::NotificationService::AllSources(), details); |
| 25 } | 27 } |
| 26 | 28 |
| 27 void ThreadNotifier::Notify(int type, | 29 void ThreadNotifier::Notify(int type, |
| 28 const content::NotificationSource& source, | 30 const content::NotificationSource& source, |
| 29 const content::NotificationDetails& details) { | 31 const content::NotificationDetails& details) { |
| 30 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 32 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 31 notify_thread_->message_loop()->PostTask( | 33 notify_thread_->task_runner()->PostTask( |
| 32 FROM_HERE, | 34 FROM_HERE, |
| 33 base::Bind(&ThreadNotifier::NotifyTask, this, type, source, details)); | 35 base::Bind(&ThreadNotifier::NotifyTask, this, type, source, details)); |
| 34 done_event_.Wait(); | 36 done_event_.Wait(); |
| 35 } | 37 } |
| 36 | 38 |
| 37 ThreadNotifier::~ThreadNotifier() {} | 39 ThreadNotifier::~ThreadNotifier() {} |
| 38 | 40 |
| 39 void ThreadNotifier::NotifyTask(int type, | 41 void ThreadNotifier::NotifyTask(int type, |
| 40 const content::NotificationSource& source, | 42 const content::NotificationSource& source, |
| 41 const content::NotificationDetails& details) { | 43 const content::NotificationDetails& details) { |
| 42 content::NotificationService::current()->Notify(type, source, details); | 44 content::NotificationService::current()->Notify(type, source, details); |
| 43 done_event_.Signal(); | 45 done_event_.Signal(); |
| 44 } | 46 } |
| OLD | NEW |