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

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

Issue 949293002: Implement a poor man's PostAfterStartupTask() function. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_impl.h" 5 #include "content/browser/browser_thread_impl.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/atomicops.h" 9 #include "base/atomicops.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
13 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
14 #include "base/message_loop/message_loop_proxy.h" 14 #include "base/message_loop/message_loop_proxy.h"
15 #include "base/threading/sequenced_worker_pool.h" 15 #include "base/threading/sequenced_worker_pool.h"
16 #include "base/threading/thread_restrictions.h" 16 #include "base/threading/thread_restrictions.h"
17 #include "content/public/browser/browser_thread_delegate.h" 17 #include "content/public/browser/browser_thread_delegate.h"
18 #include "content/public/browser/content_browser_client.h"
19 #include "content/public/common/content_client.h"
jam 2015/03/10 23:04:34 nit: by convention we only include content_browser
michaeln 2015/03/20 00:21:28 Done.
18 #include "net/disk_cache/simple/simple_backend_impl.h" 20 #include "net/disk_cache/simple/simple_backend_impl.h"
19 21
20 #if defined(OS_ANDROID) 22 #if defined(OS_ANDROID)
21 #include "base/android/jni_android.h" 23 #include "base/android/jni_android.h"
22 #endif 24 #endif
23 25
24 namespace content { 26 namespace content {
25 27
26 namespace { 28 namespace {
27 29
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 // static 360 // static
359 bool BrowserThread::PostBlockingPoolSequencedTask( 361 bool BrowserThread::PostBlockingPoolSequencedTask(
360 const std::string& sequence_token_name, 362 const std::string& sequence_token_name,
361 const tracked_objects::Location& from_here, 363 const tracked_objects::Location& from_here,
362 const base::Closure& task) { 364 const base::Closure& task) {
363 return g_globals.Get().blocking_pool->PostNamedSequencedWorkerTask( 365 return g_globals.Get().blocking_pool->PostNamedSequencedWorkerTask(
364 sequence_token_name, from_here, task); 366 sequence_token_name, from_here, task);
365 } 367 }
366 368
367 // static 369 // static
370 void BrowserThread::PostAfterStartupTask(
371 const tracked_objects::Location& from_here,
372 const scoped_refptr<base::TaskRunner>& task_runner,
373 const base::Closure& task) {
374 GetContentClient()->browser()->PostAfterStartupTask(
375 from_here, task_runner, task);
376 }
377
378 // static
368 base::SequencedWorkerPool* BrowserThread::GetBlockingPool() { 379 base::SequencedWorkerPool* BrowserThread::GetBlockingPool() {
369 return g_globals.Get().blocking_pool.get(); 380 return g_globals.Get().blocking_pool.get();
370 } 381 }
371 382
372 // static 383 // static
373 bool BrowserThread::IsThreadInitialized(ID identifier) { 384 bool BrowserThread::IsThreadInitialized(ID identifier) {
374 if (g_globals == NULL) 385 if (g_globals == NULL)
375 return false; 386 return false;
376 387
377 BrowserThreadGlobals& globals = g_globals.Get(); 388 BrowserThreadGlobals& globals = g_globals.Get();
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 AtomicWord* storage = reinterpret_cast<AtomicWord*>( 541 AtomicWord* storage = reinterpret_cast<AtomicWord*>(
531 &globals.thread_delegates[identifier]); 542 &globals.thread_delegates[identifier]);
532 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange( 543 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange(
533 storage, reinterpret_cast<AtomicWord>(delegate)); 544 storage, reinterpret_cast<AtomicWord>(delegate));
534 545
535 // This catches registration when previously registered. 546 // This catches registration when previously registered.
536 DCHECK(!delegate || !old_pointer); 547 DCHECK(!delegate || !old_pointer);
537 } 548 }
538 549
539 } // namespace content 550 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698