15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2011 The Chromium Authors. All rights reserved. 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file. 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/sync/profile_sync_test_util.h" 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/bind.h" 85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/threading/thread.h" 95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)using content::BrowserThread; 115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)ProfileSyncServiceObserverMock::ProfileSyncServiceObserverMock() {} 135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)ProfileSyncServiceObserverMock::~ProfileSyncServiceObserverMock() {} 155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)ThreadNotifier::ThreadNotifier(base::Thread* notify_thread) 175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) : done_event_(false, false), 185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) notify_thread_(notify_thread) {} 195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void ThreadNotifier::Notify(int type, 215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const content::NotificationDetails& details) { 225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Notify(type, content::NotificationService::AllSources(), details); 235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void ThreadNotifier::Notify(int type, 265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const content::NotificationSource& source, 275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const content::NotificationDetails& details) { 285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) notify_thread_->message_loop()->PostTask( 305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) FROM_HERE, 315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) base::Bind(&ThreadNotifier::NotifyTask, this, type, source, details)); 325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) done_event_.Wait(); 335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)ThreadNotifier::~ThreadNotifier() {} 365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void ThreadNotifier::NotifyTask(int type, 385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const content::NotificationSource& source, 395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const content::NotificationDetails& details) { 405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) content::NotificationService::current()->Notify(type, source, details); 415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) done_event_.Signal(); 425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 43