OLD | NEW |
(Empty) | |
| 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 #ifndef CONTENT_BROWSER_BROWSER_THREAD_IMPL_H_ |
| 6 #define CONTENT_BROWSER_BROWSER_THREAD_IMPL_H_ |
| 7 #pragma once |
| 8 |
| 9 #include "content/public/browser/browser_thread.h" |
| 10 |
| 11 namespace content { |
| 12 |
| 13 class BrowserThreadImpl : public BrowserThread { |
| 14 public: |
| 15 explicit BrowserThreadImpl(BrowserThread::ID identifier); |
| 16 BrowserThreadImpl(BrowserThread::ID identifier, MessageLoop* message_loop); |
| 17 virtual ~BrowserThreadImpl(); |
| 18 |
| 19 private: |
| 20 // We implement most functionality on the public set of |
| 21 // BrowserThread functions, but state is stored in the |
| 22 // BrowserThreadImpl to keep the public API cleaner. Therefore make |
| 23 // BrowserThread a friend class. |
| 24 friend class BrowserThread; |
| 25 |
| 26 // TODO(brettw) remove this variant when Task->Closure migration is complete. |
| 27 static bool PostTaskHelper( |
| 28 BrowserThread::ID identifier, |
| 29 const tracked_objects::Location& from_here, |
| 30 Task* task, |
| 31 int64 delay_ms, |
| 32 bool nestable); |
| 33 static bool PostTaskHelper( |
| 34 BrowserThread::ID identifier, |
| 35 const tracked_objects::Location& from_here, |
| 36 const base::Closure& task, |
| 37 int64 delay_ms, |
| 38 bool nestable); |
| 39 |
| 40 // This lock protects |browser_threads_|. Do not read or modify that array |
| 41 // without holding this lock. Do not block while holding this lock. |
| 42 static base::Lock lock_; |
| 43 |
| 44 // An array of the BrowserThread objects. This array is protected by |lock_|. |
| 45 // The threads are not owned by this array. Typically, the threads are owned |
| 46 // on the UI thread by the g_browser_process object. BrowserThreads remove |
| 47 // themselves from this array upon destruction. |
| 48 static BrowserThread* browser_threads_[ID_COUNT]; |
| 49 }; |
| 50 |
| 51 } // namespace content |
| 52 |
| 53 #endif // CONTENT_BROWSER_BROWSER_THREAD_IMPL_H_ |
OLD | NEW |