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

Unified Diff: chrome/test/thread_observer_helper.h

Issue 7474025: Move more files from chrome/test to chrome/test/base, part #2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/testing_profile.cc ('k') | content/browser/appcache/appcache_ui_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/thread_observer_helper.h
===================================================================
--- chrome/test/thread_observer_helper.h (revision 94748)
+++ chrome/test/thread_observer_helper.h (working copy)
@@ -1,70 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_TEST_THREAD_OBSERVER_HELPER_H__
-#define CHROME_TEST_THREAD_OBSERVER_HELPER_H__
-#pragma once
-
-#include "base/memory/ref_counted.h"
-#include "base/synchronization/waitable_event.h"
-#include "content/browser/browser_thread.h"
-#include "content/common/notification_observer_mock.h"
-#include "content/common/notification_registrar.h"
-
-// Helper class to add and remove observers on a non-UI thread from
-// the UI thread.
-template <class T, typename Traits>
-class ThreadObserverHelper : public base::RefCountedThreadSafe<T, Traits> {
- public:
- explicit ThreadObserverHelper(BrowserThread::ID id)
- : id_(id), done_event_(false, false) {}
-
- void Init() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- BrowserThread::PostTask(
- id_,
- FROM_HERE,
- NewRunnableMethod(this, &ThreadObserverHelper::RegisterObserversTask));
- done_event_.Wait();
- }
-
- virtual ~ThreadObserverHelper() {
- DCHECK(BrowserThread::CurrentlyOn(id_));
- registrar_.RemoveAll();
- }
-
- NotificationObserverMock* observer() {
- return &observer_;
- }
-
- protected:
- friend class base::RefCountedThreadSafe<T>;
-
- virtual void RegisterObservers() = 0;
-
- NotificationRegistrar registrar_;
- NotificationObserverMock observer_;
-
- private:
- void RegisterObserversTask() {
- DCHECK(BrowserThread::CurrentlyOn(id_));
- RegisterObservers();
- done_event_.Signal();
- }
-
- BrowserThread::ID id_;
- base::WaitableEvent done_event_;
-};
-
-class DBThreadObserverHelper;
-typedef ThreadObserverHelper<
- DBThreadObserverHelper,
- BrowserThread::DeleteOnDBThread> DBThreadObserverHelperBase;
-
-class DBThreadObserverHelper : public DBThreadObserverHelperBase {
- public:
- DBThreadObserverHelper() : DBThreadObserverHelperBase(BrowserThread::DB) {}
-};
-
-#endif // CHROME_TEST_THREAD_OBSERVER_HELPER_H__
« no previous file with comments | « chrome/test/testing_profile.cc ('k') | content/browser/appcache/appcache_ui_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698