blob: bd6087915609c6dcbdf9539e1b2d329f4fd39b15 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef REMOTING_JINGLE_GLUE_JINGLE_THREAD_H_
#define REMOTING_JINGLE_GLUE_JINGLE_THREAD_H_
#include "base/message_loop.h"
#include "base/tracked_objects.h"
#include "base/waitable_event.h"
#include "third_party/libjingle/source/talk/base/messagequeue.h"
#include "third_party/libjingle/source/talk/base/taskrunner.h"
#include "third_party/libjingle/source/talk/base/thread.h"
namespace buzz {
class XmppClient;
}
namespace remoting {
class TaskPump : public talk_base::MessageHandler,
public talk_base::TaskRunner {
public:
TaskPump();
// TaskRunner methods.
virtual void WakeTasks();
virtual int64 CurrentTime();
// MessageHandler methods.
virtual void OnMessage(talk_base::Message* pmsg);
};
// TODO(sergeyu): This class should be changed to inherit from Chromiums
// base::Thread instead of libjingle's thread.
class JingleThread : public talk_base::Thread,
public talk_base::MessageHandler {
public:
JingleThread();
virtual ~JingleThread();
void Start();
// Main function for the thread. Should not be called directly.
virtual void Run();
// Stop the thread.
virtual void Stop();
// Returns Chromiums message loop for this thread.
// TODO(sergeyu): remove this method when we use base::Thread instead of
// talk_base::Thread
MessageLoop* message_loop();
// Returns task pump if the thread is running, otherwise NULL is returned.
TaskPump* task_pump();
private:
class JingleMessageLoop;
class JingleMessagePump;
friend class HeartbeatSenderTest;
virtual void OnMessage(talk_base::Message* msg);
TaskPump* task_pump_;
base::WaitableEvent started_event_;
base::WaitableEvent stopped_event_;
MessageLoop* message_loop_;
DISALLOW_COPY_AND_ASSIGN(JingleThread);
};
} // namespace remoting
#endif // REMOTING_JINGLE_GLUE_JINGLE_THREAD_H_
|