summaryrefslogtreecommitdiffstats
path: root/content/browser/browser_thread_impl.h
diff options
context:
space:
mode:
authorjoi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-28 12:44:49 +0000
committerjoi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-28 12:44:49 +0000
commitc38831a108f9f905ce9e68503ee67274939cc950 (patch)
tree7c93c8afd386fdc11a0f03855cee62c2d3449d63 /content/browser/browser_thread_impl.h
parent75c753a51b150912055d7a8305cf77134d24816a (diff)
downloadchromium_src-c38831a108f9f905ce9e68503ee67274939cc950.zip
chromium_src-c38831a108f9f905ce9e68503ee67274939cc950.tar.gz
chromium_src-c38831a108f9f905ce9e68503ee67274939cc950.tar.bz2
Split BrowserThread into public API and private implementation, step 1.
Only content/ now has the ability to create BrowserThread objects, with the exception that tests can create the content::TestBrowserThread subclass, and (temporarily) code in chrome/ can create the DeprecatedBrowserThread subclass. A follow-up change will make content/ take care of its own thread creation, remove DeprecatedBrowserThread, and move all state and non-trivial constructors from BrowserThread down to BrowserThreadImpl. Also moved BrowserProcessSubThread into content/ namespace. As part of follow-up cleanup, chrome/ will stop using this class. BUG=98716 TEST=existing Review URL: http://codereview.chromium.org/8392042 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@107718 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/browser_thread_impl.h')
-rw-r--r--content/browser/browser_thread_impl.h53
1 files changed, 53 insertions, 0 deletions
diff --git a/content/browser/browser_thread_impl.h b/content/browser/browser_thread_impl.h
new file mode 100644
index 0000000..5c19e92
--- /dev/null
+++ b/content/browser/browser_thread_impl.h
@@ -0,0 +1,53 @@
+// 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 CONTENT_BROWSER_BROWSER_THREAD_IMPL_H_
+#define CONTENT_BROWSER_BROWSER_THREAD_IMPL_H_
+#pragma once
+
+#include "content/public/browser/browser_thread.h"
+
+namespace content {
+
+class BrowserThreadImpl : public BrowserThread {
+ public:
+ explicit BrowserThreadImpl(BrowserThread::ID identifier);
+ BrowserThreadImpl(BrowserThread::ID identifier, MessageLoop* message_loop);
+ virtual ~BrowserThreadImpl();
+
+ private:
+ // We implement most functionality on the public set of
+ // BrowserThread functions, but state is stored in the
+ // BrowserThreadImpl to keep the public API cleaner. Therefore make
+ // BrowserThread a friend class.
+ friend class BrowserThread;
+
+ // TODO(brettw) remove this variant when Task->Closure migration is complete.
+ static bool PostTaskHelper(
+ BrowserThread::ID identifier,
+ const tracked_objects::Location& from_here,
+ Task* task,
+ int64 delay_ms,
+ bool nestable);
+ static bool PostTaskHelper(
+ BrowserThread::ID identifier,
+ const tracked_objects::Location& from_here,
+ const base::Closure& task,
+ int64 delay_ms,
+ bool nestable);
+
+ // This lock protects |browser_threads_|. Do not read or modify that array
+ // without holding this lock. Do not block while holding this lock.
+ static base::Lock lock_;
+
+ // An array of the BrowserThread objects. This array is protected by |lock_|.
+ // The threads are not owned by this array. Typically, the threads are owned
+ // on the UI thread by the g_browser_process object. BrowserThreads remove
+ // themselves from this array upon destruction.
+ static BrowserThread* browser_threads_[ID_COUNT];
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_BROWSER_THREAD_IMPL_H_