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

Side by Side Diff: chrome/browser/sync/weak_handle.cc

Issue 7583053: Add MessageLoopProxy::current (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: No need for MessageLoopProxy destruction observer. Created 9 years, 4 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 "chrome/browser/sync/weak_handle.h" 5 #include "chrome/browser/sync/weak_handle.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 8
9 #include "base/message_loop_proxy.h" 9 #include "base/message_loop_proxy.h"
10 #include "base/tracked.h" 10 #include "base/tracked.h"
11 11
12 namespace browser_sync { 12 namespace browser_sync {
13 13
14 namespace internal { 14 namespace internal {
15 15
16 WeakHandleCoreBase::WeakHandleCoreBase() 16 WeakHandleCoreBase::WeakHandleCoreBase()
17 : owner_loop_(MessageLoop::current()), 17 : owner_loop_(MessageLoop::current()),
18 owner_loop_proxy_(base::MessageLoopProxy::CreateForCurrentThread()), 18 owner_loop_proxy_(base::MessageLoopProxy::current()),
19 destroyed_on_owner_thread_(false) { 19 destroyed_on_owner_thread_(false) {
20 owner_loop_->AddDestructionObserver(this); 20 owner_loop_->AddDestructionObserver(this);
21 } 21 }
22 22
23 bool WeakHandleCoreBase::IsOnOwnerThread() const { 23 bool WeakHandleCoreBase::IsOnOwnerThread() const {
24 // We can't use |owner_loop_proxy_->BelongsToCurrentThread()| as 24 // We can't use |owner_loop_proxy_->BelongsToCurrentThread()| as
25 // it may not work from within a MessageLoop::DestructionObserver 25 // it may not work from within a MessageLoop::DestructionObserver
26 // callback. 26 // callback.
27 return MessageLoop::current() == owner_loop_; 27 return MessageLoop::current() == owner_loop_;
28 } 28 }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 delete this; 96 delete this;
97 } 97 }
98 98
99 void WeakHandleCoreBaseTraits::Destruct(const WeakHandleCoreBase* core_base) { 99 void WeakHandleCoreBaseTraits::Destruct(const WeakHandleCoreBase* core_base) {
100 const_cast<WeakHandleCoreBase*>(core_base)->Destroy(); 100 const_cast<WeakHandleCoreBase*>(core_base)->Destroy();
101 } 101 }
102 102
103 } // namespace internal 103 } // namespace internal
104 104
105 } // namespace base 105 } // namespace base
OLDNEW
« no previous file with comments | « chrome/browser/sync/notifier/p2p_notifier.cc ('k') | chrome/common/important_file_writer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698