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

Side by Side Diff: base/thread_main_task_runner.cc

Issue 10210008: Make MessageLoopProxy::current() usable on threads that don't have MessageLoop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/thread_main_task_runner.h"
6
7 #include "base/lazy_instance.h"
8 #include "base/threading/thread_local.h"
9
10 namespace base {
11
12 namespace {
13
14 base::LazyInstance<base::ThreadLocalPointer<ThreadMainTaskRunner> >
15 lazy_tls_ptr = LAZY_INSTANCE_INITIALIZER;
16
17 } // namespace
18
19 // static
20 scoped_refptr<ThreadMainTaskRunner> ThreadMainTaskRunner::current() {
21 ThreadMainTaskRunner* result = lazy_tls_ptr.Pointer()->Get();
22 DCHECK(result);
23 return result;
24 }
25
26 // static
27 void ThreadMainTaskRunner::SetCurrent(ThreadMainTaskRunner* new_current) {
28 DCHECK(!current() || !new_current);
Ami GONE FROM CHROMIUM 2012/04/30 23:34:05 I'm surprised this doesn't DCHECK-fail the first t
Ami GONE FROM CHROMIUM 2012/04/30 23:34:05 (assuming you s/current()/lazy_tls_ptr.Pointer()->
Sergey Ulanov 2012/05/01 00:34:54 Oops, I didn't test this code after adding DCHECK
Sergey Ulanov 2012/05/01 00:34:54 No. Ok, I changed this code to check this case too
29 lazy_tls_ptr.Pointer()->Set(new_current);
30 }
31
32 } // namespace base
OLDNEW
« base/thread_main_task_runner.h ('K') | « base/thread_main_task_runner.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698