| OLD | NEW |
| 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 #include "remoting/protocol/fake_session.h" | 5 #include "remoting/protocol/fake_session.h" |
| 6 | 6 |
| 7 #include "base/location.h" | 7 #include "base/location.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 | 70 |
| 71 void FakeSession::SetTransport(Transport* transport) { | 71 void FakeSession::SetTransport(Transport* transport) { |
| 72 transport_ = transport; | 72 transport_ = transport; |
| 73 } | 73 } |
| 74 | 74 |
| 75 void FakeSession::Close(ErrorCode error) { | 75 void FakeSession::Close(ErrorCode error) { |
| 76 closed_ = true; | 76 closed_ = true; |
| 77 error_ = error; | 77 error_ = error; |
| 78 event_handler_->OnSessionStateChange(CLOSED); | 78 event_handler_->OnSessionStateChange(CLOSED); |
| 79 | 79 |
| 80 FakeSession* peer = peer_.get(); | 80 base::WeakPtr<FakeSession> peer = peer_; |
| 81 if (peer) { | 81 if (peer) { |
| 82 peer->peer_.reset(); | 82 peer->peer_.reset(); |
| 83 peer_.reset(); | 83 peer_.reset(); |
| 84 peer->Close(error); | 84 |
| 85 if (signaling_delay_.is_zero()) { |
| 86 peer->Close(error); |
| 87 } else { |
| 88 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 89 FROM_HERE, base::Bind(&FakeSession::Close, peer, error), |
| 90 signaling_delay_); |
| 91 } |
| 85 } | 92 } |
| 86 } | 93 } |
| 87 | 94 |
| 88 void FakeSession::SendTransportInfo( | 95 void FakeSession::SendTransportInfo( |
| 89 std::unique_ptr<buzz::XmlElement> transport_info) { | 96 std::unique_ptr<buzz::XmlElement> transport_info) { |
| 90 if (!peer_) | 97 if (!peer_) |
| 91 return; | 98 return; |
| 92 | 99 |
| 93 if (signaling_delay_.is_zero()) { | 100 if (signaling_delay_.is_zero()) { |
| 94 peer_->ProcessTransportInfo(std::move(transport_info)); | 101 peer_->ProcessTransportInfo(std::move(transport_info)); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 120 void FakeSession::SetAttachment(size_t round, | 127 void FakeSession::SetAttachment(size_t round, |
| 121 std::unique_ptr<buzz::XmlElement> attachment) { | 128 std::unique_ptr<buzz::XmlElement> attachment) { |
| 122 while (attachments_.size() <= round) { | 129 while (attachments_.size() <= round) { |
| 123 attachments_.emplace_back(); | 130 attachments_.emplace_back(); |
| 124 } | 131 } |
| 125 attachments_[round] = std::move(attachment); | 132 attachments_[round] = std::move(attachment); |
| 126 } | 133 } |
| 127 | 134 |
| 128 } // namespace protocol | 135 } // namespace protocol |
| 129 } // namespace remoting | 136 } // namespace remoting |
| OLD | NEW |