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

Side by Side Diff: chrome/browser/chrome_thread.h

Issue 1837003: Created a stock implementation of the MessageLoopProxy interface than can be ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Rearranged header files Created 10 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/chrome_plugin_unittest.cc ('k') | chrome/browser/chrome_thread.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_CHROME_THREAD_H_ 5 #ifndef CHROME_BROWSER_CHROME_THREAD_H_
6 #define CHROME_BROWSER_CHROME_THREAD_H_ 6 #define CHROME_BROWSER_CHROME_THREAD_H_
7 7
8 #include "base/lock.h" 8 #include "base/lock.h"
9 #include "base/task.h" 9 #include "base/task.h"
10 #include "base/thread.h" 10 #include "base/thread.h"
11 11
12 namespace base {
12 class MessageLoopProxy; 13 class MessageLoopProxy;
14 }
13 15
14 /////////////////////////////////////////////////////////////////////////////// 16 ///////////////////////////////////////////////////////////////////////////////
15 // ChromeThread 17 // ChromeThread
16 // 18 //
17 // This class represents a thread that is known by a browser-wide name. For 19 // This class represents a thread that is known by a browser-wide name. For
18 // example, there is one IO thread for the entire browser process, and various 20 // example, there is one IO thread for the entire browser process, and various
19 // pieces of code find it useful to retrieve a pointer to the IO thread's 21 // pieces of code find it useful to retrieve a pointer to the IO thread's
20 // Invoke a task by thread ID: 22 // Invoke a task by thread ID:
21 // 23 //
22 // ChromeThread::PostTask(ChromeThread::IO, FROM_HERE, task); 24 // ChromeThread::PostTask(ChromeThread::IO, FROM_HERE, task);
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 // Callable on any thread. Returns whether you're currently on a particular 125 // Callable on any thread. Returns whether you're currently on a particular
124 // thread. 126 // thread.
125 static bool CurrentlyOn(ID identifier); 127 static bool CurrentlyOn(ID identifier);
126 128
127 // If the current message loop is one of the known threads, returns true and 129 // If the current message loop is one of the known threads, returns true and
128 // sets identifier to its ID. Otherwise returns false. 130 // sets identifier to its ID. Otherwise returns false.
129 static bool GetCurrentThreadIdentifier(ID* identifier); 131 static bool GetCurrentThreadIdentifier(ID* identifier);
130 132
131 // Callers can hold on to a refcounted MessageLoopProxy beyond the lifetime 133 // Callers can hold on to a refcounted MessageLoopProxy beyond the lifetime
132 // of the thread. 134 // of the thread.
133 static scoped_refptr<MessageLoopProxy> GetMessageLoopProxyForThread( 135 static scoped_refptr<base::MessageLoopProxy> GetMessageLoopProxyForThread(
134 ID identifier); 136 ID identifier);
135 137
136 // Use these templates in conjuction with RefCountedThreadSafe when you want 138 // Use these templates in conjuction with RefCountedThreadSafe when you want
137 // to ensure that an object is deleted on a specific thread. This is needed 139 // to ensure that an object is deleted on a specific thread. This is needed
138 // when an object can hop between threads (i.e. IO -> FILE -> IO), and thread 140 // when an object can hop between threads (i.e. IO -> FILE -> IO), and thread
139 // switching delays can mean that the final IO tasks executes before the FILE 141 // switching delays can mean that the final IO tasks executes before the FILE
140 // task's stack unwinds. This would lead to the object destructing on the 142 // task's stack unwinds. This would lead to the object destructing on the
141 // FILE thread, which often is not what you want (i.e. to unregister from 143 // FILE thread, which often is not what you want (i.e. to unregister from
142 // NotificationService, to notify other objects on the creating thread etc). 144 // NotificationService, to notify other objects on the creating thread etc).
143 template<ID thread> 145 template<ID thread>
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 static Lock lock_; 191 static Lock lock_;
190 192
191 // An array of the ChromeThread objects. This array is protected by |lock_|. 193 // An array of the ChromeThread objects. This array is protected by |lock_|.
192 // The threads are not owned by this array. Typically, the threads are owned 194 // The threads are not owned by this array. Typically, the threads are owned
193 // on the UI thread by the g_browser_process object. ChromeThreads remove 195 // on the UI thread by the g_browser_process object. ChromeThreads remove
194 // themselves from this array upon destruction. 196 // themselves from this array upon destruction.
195 static ChromeThread* chrome_threads_[ID_COUNT]; 197 static ChromeThread* chrome_threads_[ID_COUNT];
196 }; 198 };
197 199
198 #endif // CHROME_BROWSER_CHROME_THREAD_H_ 200 #endif // CHROME_BROWSER_CHROME_THREAD_H_
OLDNEW
« no previous file with comments | « chrome/browser/chrome_plugin_unittest.cc ('k') | chrome/browser/chrome_thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698