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

Side by Side Diff: content/browser/browser_thread.cc

Issue 8274012: Wait for URLBlacklist update tasks on automation tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added BrowserThread::WaitForPendingTasksOn, removed SignalingTask Created 9 years, 2 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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 #include "content/browser/browser_thread.h" 5 #include "content/browser/browser_thread.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/message_loop_proxy.h" 9 #include "base/message_loop_proxy.h"
10 #include "base/synchronization/waitable_event.h"
10 #include "base/threading/thread_restrictions.h" 11 #include "base/threading/thread_restrictions.h"
11 12
12 // Friendly names for the well-known threads. 13 // Friendly names for the well-known threads.
13 static const char* browser_thread_names[BrowserThread::ID_COUNT] = { 14 static const char* browser_thread_names[BrowserThread::ID_COUNT] = {
14 "", // UI (name assembled in browser_main.cc). 15 "", // UI (name assembled in browser_main.cc).
15 "Chrome_DBThread", // DB 16 "Chrome_DBThread", // DB
16 "Chrome_WebKitThread", // WEBKIT 17 "Chrome_WebKitThread", // WEBKIT
17 "Chrome_FileThread", // FILE 18 "Chrome_FileThread", // FILE
18 "Chrome_ProcessLauncherThread", // PROCESS_LAUNCHER 19 "Chrome_ProcessLauncherThread", // PROCESS_LAUNCHER
19 "Chrome_CacheThread", // CACHE 20 "Chrome_CacheThread", // CACHE
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 browser_threads_[i]->message_loop() == cur_message_loop) { 246 browser_threads_[i]->message_loop() == cur_message_loop) {
246 *identifier = browser_threads_[i]->identifier_; 247 *identifier = browser_threads_[i]->identifier_;
247 return true; 248 return true;
248 } 249 }
249 } 250 }
250 251
251 return false; 252 return false;
252 } 253 }
253 254
254 // static 255 // static
256 bool BrowserThread::WaitForPendingTasksOn(ID identifier) {
257 // Avoid deadlocking self.
258 if (CurrentlyOn(identifier))
259 return false;
260 base::WaitableEvent event(true /* manual reset */,
261 false /* not initially signaled */);
262 if (!PostTask(identifier,
263 FROM_HERE,
264 base::Bind(&base::WaitableEvent::Signal,
265 base::Unretained(&event))))
266 return false;
267 event.Wait();
268 return true;
269 }
270
271 // static
255 scoped_refptr<base::MessageLoopProxy> 272 scoped_refptr<base::MessageLoopProxy>
256 BrowserThread::GetMessageLoopProxyForThread( 273 BrowserThread::GetMessageLoopProxyForThread(
257 ID identifier) { 274 ID identifier) {
258 scoped_refptr<base::MessageLoopProxy> proxy( 275 scoped_refptr<base::MessageLoopProxy> proxy(
259 new BrowserThreadMessageLoopProxy(identifier)); 276 new BrowserThreadMessageLoopProxy(identifier));
260 return proxy; 277 return proxy;
261 } 278 }
262 279
263 // static 280 // static
264 bool BrowserThread::PostTaskHelper( 281 bool BrowserThread::PostTaskHelper(
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 } else { 348 } else {
332 message_loop->PostNonNestableDelayedTask(from_here, task, delay_ms); 349 message_loop->PostNonNestableDelayedTask(from_here, task, delay_ms);
333 } 350 }
334 } 351 }
335 352
336 if (!guaranteed_to_outlive_target_thread) 353 if (!guaranteed_to_outlive_target_thread)
337 lock_.Release(); 354 lock_.Release();
338 355
339 return !!message_loop; 356 return !!message_loop;
340 } 357 }
OLDNEW
« content/browser/browser_thread.h ('K') | « content/browser/browser_thread.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698