summaryrefslogtreecommitdiffstats
path: root/remoting/protocol/session_manager_pair.h
blob: f3e4f37f03bd4b9907ab335c1971ca59c528182b (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
// 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.

// SessionManagerPair class is used by unittests to create a pair of session
// managers connected to each other. These session managers are then can be
// passed to a pair of JingleChromotocolConnection objects, so that it is
// possible to simulate connection between host and client.

#ifndef REMOTING_PROTOCOL_MOCK_SESSION_MANAGER_H_
#define REMOTING_PROTOCOL_MOCK_SESSION_MANAGER_H_

#include <base/ref_counted.h>
#include <base/scoped_ptr.h>

#include "third_party/libjingle/source/talk/base/sigslot.h"

class MessageLoop;

namespace buzz {
class XmlElement;
}  // namespace buzz

namespace cricket {
class BasicPortAllocator;
class SessionManager;
}  // namespace cricket

namespace talk_base {
class NetworkManager;
}  // namespace talk_base

namespace remoting {

class JingleThread;

class SessionManagerPair
    : public sigslot::has_slots<>,
      public base::RefCountedThreadSafe<SessionManagerPair>{
 public:
  static const char kHostJid[];
  static const char kClientJid[];

  SessionManagerPair(JingleThread* thread);
  virtual ~SessionManagerPair();

  void Init();

  // The session managers are named 'host' and 'client' just for convenience.
  // Both can be used for client or host.
  cricket::SessionManager* host_session_manager();
  cricket::SessionManager* client_session_manager();

 private:
  void ProcessMessage(cricket::SessionManager* manager,
                      const buzz::XmlElement* stanza);
  void DoProcessMessage(cricket::SessionManager* manager,
                       buzz::XmlElement* stanza);
  void DeliverMessage(cricket::SessionManager* to,
                      buzz::XmlElement* stanza);

  MessageLoop* message_loop_;
  scoped_ptr<talk_base::NetworkManager> network_manager_;
  scoped_ptr<cricket::BasicPortAllocator> port_allocator_;
  scoped_ptr<cricket::SessionManager> host_session_manager_;
  scoped_ptr<cricket::SessionManager> client_session_manager_;
};

}  // namespace remoting

#endif  // REMOTING_PROTOCOL_MOCK_SESSION_MANAGER_H_