summaryrefslogtreecommitdiffstats
path: root/remoting/jingle_glue/fake_signal_strategy.cc
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-03 21:02:39 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-03 21:02:39 +0000
commit08128a313552198dce04295ad7e12071f4860161 (patch)
tree34d0682f03badf0e0b6c27ff2b78da4289dca650 /remoting/jingle_glue/fake_signal_strategy.cc
parent1e42174b401dbf8105ec4e5d864bad1c906c5717 (diff)
downloadchromium_src-08128a313552198dce04295ad7e12071f4860161.zip
chromium_src-08128a313552198dce04295ad7e12071f4860161.tar.gz
chromium_src-08128a313552198dce04295ad7e12071f4860161.tar.bz2
Refactor SignalStrategy so that it can be reused for multiple connections.
Also updated SessionManager implementation so that session managers can be created before signaling is connected. BUG=107276 Review URL: http://codereview.chromium.org/9005034 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@116192 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/jingle_glue/fake_signal_strategy.cc')
-rw-r--r--remoting/jingle_glue/fake_signal_strategy.cc39
1 files changed, 22 insertions, 17 deletions
diff --git a/remoting/jingle_glue/fake_signal_strategy.cc b/remoting/jingle_glue/fake_signal_strategy.cc
index 4cbfd23..657b0ad 100644
--- a/remoting/jingle_glue/fake_signal_strategy.cc
+++ b/remoting/jingle_glue/fake_signal_strategy.cc
@@ -34,33 +34,37 @@ FakeSignalStrategy::~FakeSignalStrategy() {
delete pending_messages_.front();
pending_messages_.pop();
}
- DCHECK(listeners_.empty());
}
-void FakeSignalStrategy::Init(StatusObserver* observer) {
- observer->OnStateChange(StatusObserver::START);
- observer->OnStateChange(StatusObserver::CONNECTING);
- observer->OnJidChange(jid_);
- observer->OnStateChange(StatusObserver::CONNECTED);
+void FakeSignalStrategy::Connect() {
+ DCHECK(CalledOnValidThread());
+ FOR_EACH_OBSERVER(Listener, listeners_,
+ OnSignalStrategyStateChange(CONNECTED));
+}
+
+void FakeSignalStrategy::Disconnect() {
+ DCHECK(CalledOnValidThread());
+ FOR_EACH_OBSERVER(Listener, listeners_,
+ OnSignalStrategyStateChange(DISCONNECTED));
+}
+
+SignalStrategy::State FakeSignalStrategy::GetState() const {
+ return CONNECTED;
}
-void FakeSignalStrategy::Close() {
+std::string FakeSignalStrategy::GetLocalJid() const {
DCHECK(CalledOnValidThread());
+ return jid_;
}
void FakeSignalStrategy::AddListener(Listener* listener) {
DCHECK(CalledOnValidThread());
- DCHECK(std::find(listeners_.begin(), listeners_.end(), listener) ==
- listeners_.end());
- listeners_.push_back(listener);
+ listeners_.AddObserver(listener);
}
void FakeSignalStrategy::RemoveListener(Listener* listener) {
DCHECK(CalledOnValidThread());
- std::vector<Listener*>::iterator it =
- std::find(listeners_.begin(), listeners_.end(), listener);
- CHECK(it != listeners_.end());
- listeners_.erase(it);
+ listeners_.RemoveObserver(listener);
}
bool FakeSignalStrategy::SendStanza(buzz::XmlElement* stanza) {
@@ -100,9 +104,10 @@ void FakeSignalStrategy::DeliverIncomingMessages() {
return;
}
- for (std::vector<Listener*>::iterator it = listeners_.begin();
- it != listeners_.end(); ++it) {
- if ((*it)->OnIncomingStanza(stanza))
+ ObserverListBase<Listener>::Iterator it(listeners_);
+ Listener* listener;
+ while ((listener = it.GetNext()) != NULL) {
+ if (listener->OnSignalStrategyIncomingStanza(stanza))
break;
}