Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(456)

Unified Diff: remoting/protocol/stream_message_pipe_adapter.cc

Issue 1662673002: Add MessageChanneFactory interface and use it in ChannelDispatcherBase. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@framing
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/protocol/stream_message_pipe_adapter.h ('k') | remoting/protocol/webrtc_connection_to_client.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/protocol/stream_message_pipe_adapter.cc
diff --git a/remoting/protocol/stream_message_pipe_adapter.cc b/remoting/protocol/stream_message_pipe_adapter.cc
index 826630476244093d5a18821710a3ddbc23984055..ff8597aa740ff66faa8b8a56abbe583fdf898e6b 100644
--- a/remoting/protocol/stream_message_pipe_adapter.cc
+++ b/remoting/protocol/stream_message_pipe_adapter.cc
@@ -8,10 +8,12 @@
#include "base/bind.h"
#include "base/callback_helpers.h"
+#include "net/base/net_errors.h"
#include "remoting/base/buffered_socket_writer.h"
#include "remoting/base/compound_buffer.h"
#include "remoting/protocol/message_serialization.h"
#include "remoting/protocol/p2p_stream_socket.h"
+#include "remoting/protocol/stream_channel_factory.h"
namespace remoting {
namespace protocol {
@@ -54,5 +56,37 @@ void StreamMessagePipeAdapter::CloseOnError(int error) {
base::ResetAndReturn(&error_callback_).Run(error);
}
+StreamMessageChannelFactoryAdapter::StreamMessageChannelFactoryAdapter(
+ StreamChannelFactory* stream_channel_factory,
+ const ErrorCallback& error_callback)
+ : stream_channel_factory_(stream_channel_factory),
+ error_callback_(error_callback) {}
+
+StreamMessageChannelFactoryAdapter::~StreamMessageChannelFactoryAdapter() {}
+
+void StreamMessageChannelFactoryAdapter::CreateChannel(
+ const std::string& name,
+ const ChannelCreatedCallback& callback) {
+ stream_channel_factory_->CreateChannel(
+ name, base::Bind(&StreamMessageChannelFactoryAdapter::OnChannelCreated,
+ base::Unretained(this), callback));
+}
+
+void StreamMessageChannelFactoryAdapter::CancelChannelCreation(
+ const std::string& name) {
+ stream_channel_factory_->CancelChannelCreation(name);
+}
+
+void StreamMessageChannelFactoryAdapter::OnChannelCreated(
+ const ChannelCreatedCallback& callback,
+ scoped_ptr<P2PStreamSocket> socket) {
+ if (!socket) {
+ error_callback_.Run(net::ERR_FAILED);
+ return;
+ }
+ callback.Run(make_scoped_ptr(
+ new StreamMessagePipeAdapter(std::move(socket), error_callback_)));
+}
+
} // namespace protocol
} // namespace remoting
« no previous file with comments | « remoting/protocol/stream_message_pipe_adapter.h ('k') | remoting/protocol/webrtc_connection_to_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698