OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // This object runs on a thread and knows how to interpret messages sent by the | 5 // This object runs on a thread and knows how to interpret messages sent by the |
6 // talk mediator. The mediator posts messages to a queue which the thread polls | 6 // talk mediator. The mediator posts messages to a queue which the thread polls |
7 // (in a super class). | 7 // (in a super class). |
8 // | 8 // |
9 // Example usage: | 9 // Example usage: |
10 // | 10 // |
11 // MediatorThread m = new MediatorThreadImpl(pass in stuff); | 11 // MediatorThread m = new MediatorThreadImpl(pass in stuff); |
12 // m.start(); // Start the thread | 12 // m.start(); // Start the thread |
13 // // Once the thread is started, you can do server stuff. | 13 // // Once the thread is started, you can do server stuff. |
14 // m.Login(loginInformation); | 14 // m.Login(loginInformation); |
15 // // Events happen, the mediator finds out through its pump more messages | 15 // // Events happen, the mediator finds out through its pump more messages |
16 // // are dispatched to the thread eventually we want to log out. | 16 // // are dispatched to the thread eventually we want to log out. |
17 // m.Logout(); | 17 // m.Logout(); |
18 // delete m; // Also stops the thread. | 18 // delete m; // Also stops the thread. |
19 | 19 |
20 #ifndef JINGLE_NOTIFIER_LISTENER_MEDIATOR_THREAD_IMPL_H_ | 20 #ifndef JINGLE_NOTIFIER_LISTENER_MEDIATOR_THREAD_IMPL_H_ |
21 #define JINGLE_NOTIFIER_LISTENER_MEDIATOR_THREAD_IMPL_H_ | 21 #define JINGLE_NOTIFIER_LISTENER_MEDIATOR_THREAD_IMPL_H_ |
22 | 22 |
23 #include <string> | 23 #include <string> |
24 #include <vector> | 24 #include <vector> |
25 | 25 |
26 #include "base/basictypes.h" | 26 #include "base/basictypes.h" |
27 #include "base/observer_list_threadsafe.h" | 27 #include "base/observer_list_threadsafe.h" |
28 #include "base/ref_counted.h" | 28 #include "base/ref_counted.h" |
29 #include "base/scoped_ptr.h" | 29 #include "base/scoped_ptr.h" |
| 30 #include "base/task.h" |
30 #include "base/thread.h" | 31 #include "base/thread.h" |
31 #include "base/weak_ptr.h" | 32 #include "base/weak_ptr.h" |
32 #include "jingle/notifier/base/notifier_options.h" | 33 #include "jingle/notifier/base/notifier_options.h" |
33 #include "jingle/notifier/communicator/login.h" | 34 #include "jingle/notifier/communicator/login.h" |
34 #include "jingle/notifier/listener/mediator_thread.h" | 35 #include "jingle/notifier/listener/mediator_thread.h" |
35 #include "talk/base/sigslot.h" | 36 #include "talk/base/sigslot.h" |
36 | 37 |
37 class MessageLoop; | 38 class MessageLoop; |
38 | 39 |
39 namespace buzz { | 40 namespace buzz { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 base::Thread worker_thread_; | 106 base::Thread worker_thread_; |
106 scoped_ptr<net::HostResolver> host_resolver_; | 107 scoped_ptr<net::HostResolver> host_resolver_; |
107 | 108 |
108 scoped_ptr<notifier::Login> login_; | 109 scoped_ptr<notifier::Login> login_; |
109 | 110 |
110 DISALLOW_COPY_AND_ASSIGN(MediatorThreadImpl); | 111 DISALLOW_COPY_AND_ASSIGN(MediatorThreadImpl); |
111 }; | 112 }; |
112 | 113 |
113 } // namespace notifier | 114 } // namespace notifier |
114 | 115 |
| 116 // We manage the lifetime of notifier::MediatorThreadImpl ourselves. |
| 117 DISABLE_RUNNABLE_METHOD_REFCOUNT(notifier::MediatorThreadImpl); |
| 118 |
115 #endif // JINGLE_NOTIFIER_LISTENER_MEDIATOR_THREAD_IMPL_H_ | 119 #endif // JINGLE_NOTIFIER_LISTENER_MEDIATOR_THREAD_IMPL_H_ |
OLD | NEW |