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
3// found in the LICENSE file.
4
5#include "chrome/browser/sync/profile_sync_test_util.h"
6
7#include "base/bind.h"
8#include "base/threading/thread.h"
9
10using content::BrowserThread;
11
12ProfileSyncServiceObserverMock::ProfileSyncServiceObserverMock() {}
13
14ProfileSyncServiceObserverMock::~ProfileSyncServiceObserverMock() {}
15
16ThreadNotifier::ThreadNotifier(base::Thread* notify_thread)
17    : done_event_(false, false),
18      notify_thread_(notify_thread) {}
19
20void ThreadNotifier::Notify(int type,
21                            const content::NotificationDetails& details) {
22  Notify(type, content::NotificationService::AllSources(), details);
23}
24
25void ThreadNotifier::Notify(int type,
26                            const content::NotificationSource& source,
27                            const content::NotificationDetails& details) {
28  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
29  notify_thread_->message_loop()->PostTask(
30      FROM_HERE,
31      base::Bind(&ThreadNotifier::NotifyTask, this, type, source, details));
32  done_event_.Wait();
33}
34
35ThreadNotifier::~ThreadNotifier() {}
36
37void ThreadNotifier::NotifyTask(int type,
38                                const content::NotificationSource& source,
39                                const content::NotificationDetails& details) {
40  content::NotificationService::current()->Notify(type, source, details);
41  done_event_.Signal();
42}
43