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

Side by Side Diff: jingle/glue/thread_wrapper.h

Issue 14307021: jingle: Use base::MessageLoop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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
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 #ifndef JINGLE_GLUE_THREAD_WRAPPER_H_ 5 #ifndef JINGLE_GLUE_THREAD_WRAPPER_H_
6 #define JINGLE_GLUE_THREAD_WRAPPER_H_ 6 #define JINGLE_GLUE_THREAD_WRAPPER_H_
7 7
8 #include <list> 8 #include <list>
9 #include <map> 9 #include <map>
10 10
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/message_loop.h" 12 #include "base/message_loop.h"
13 #include "base/synchronization/lock.h" 13 #include "base/synchronization/lock.h"
14 #include "base/synchronization/waitable_event.h" 14 #include "base/synchronization/waitable_event.h"
15 #include "third_party/libjingle/source/talk/base/thread.h" 15 #include "third_party/libjingle/source/talk/base/thread.h"
16 16
17 namespace jingle_glue { 17 namespace jingle_glue {
18 18
19 // JingleThreadWrapper implements talk_base::Thread interface on top of 19 // JingleThreadWrapper implements talk_base::Thread interface on top of
20 // Chromium's SingleThreadTaskRunner interface. Currently only the bare minimum 20 // Chromium's SingleThreadTaskRunner interface. Currently only the bare minimum
21 // that is used by P2P part of libjingle is implemented. There are two ways to 21 // that is used by P2P part of libjingle is implemented. There are two ways to
22 // create this object: 22 // create this object:
23 // 23 //
24 // - Call EnsureForCurrentMessageLoop(). This approach works only on threads 24 // - Call EnsureForCurrentMessageLoop(). This approach works only on threads
25 // that have MessageLoop In this case JingleThreadWrapper deletes itself 25 // that have MessageLoop In this case JingleThreadWrapper deletes itself
26 // automatically when MessageLoop is destroyed. 26 // automatically when MessageLoop is destroyed.
27 // - Using JingleThreadWrapper() constructor. In this case the creating code 27 // - Using JingleThreadWrapper() constructor. In this case the creating code
28 // must pass a valid task runner for the current thread and also delete the 28 // must pass a valid task runner for the current thread and also delete the
29 // wrapper later. 29 // wrapper later.
30 class JingleThreadWrapper 30 class JingleThreadWrapper : public base::MessageLoop::DestructionObserver,
31 : public MessageLoop::DestructionObserver, 31 public talk_base::Thread {
32 public talk_base::Thread {
33 public: 32 public:
34 // Create JingleThreadWrapper for the current thread if it hasn't been created 33 // Create JingleThreadWrapper for the current thread if it hasn't been created
35 // yet. The thread wrapper is destroyed automatically when the current 34 // yet. The thread wrapper is destroyed automatically when the current
36 // MessageLoop is destroyed. 35 // MessageLoop is destroyed.
37 static void EnsureForCurrentMessageLoop(); 36 static void EnsureForCurrentMessageLoop();
38 37
39 // Returns thread wrapper for the current thread. NULL is returned 38 // Returns thread wrapper for the current thread. NULL is returned
40 // if EnsureForCurrentMessageLoop() has never been called for this 39 // if EnsureForCurrentMessageLoop() has never been called for this
41 // thread. 40 // thread.
42 static JingleThreadWrapper* current(); 41 static JingleThreadWrapper* current();
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 118
120 base::WeakPtrFactory<JingleThreadWrapper> weak_ptr_factory_; 119 base::WeakPtrFactory<JingleThreadWrapper> weak_ptr_factory_;
121 base::WeakPtr<JingleThreadWrapper> weak_ptr_; 120 base::WeakPtr<JingleThreadWrapper> weak_ptr_;
122 121
123 DISALLOW_COPY_AND_ASSIGN(JingleThreadWrapper); 122 DISALLOW_COPY_AND_ASSIGN(JingleThreadWrapper);
124 }; 123 };
125 124
126 } // namespace jingle_glue 125 } // namespace jingle_glue
127 126
128 #endif // JINGLE_GLUE_THREAD_WRAPPER_H_ 127 #endif // JINGLE_GLUE_THREAD_WRAPPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698