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

Unified Diff: remoting/protocol/data_channel_manager.h

Issue 2907073003: [Chromoting] Add DataChannelManager to manage optional incoming data channels (Closed)
Patch Set: Resolve review comments Created 3 years, 6 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
Index: remoting/protocol/data_channel_manager.h
diff --git a/remoting/protocol/data_channel_manager.h b/remoting/protocol/data_channel_manager.h
new file mode 100644
index 0000000000000000000000000000000000000000..0f65e6801b2bfd8cc51940773809e7058124034c
--- /dev/null
+++ b/remoting/protocol/data_channel_manager.h
@@ -0,0 +1,53 @@
+// Copyright 2017 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_PROTOCOL_DATA_CHANNEL_MANAGER_H_
+#define REMOTING_PROTOCOL_DATA_CHANNEL_MANAGER_H_
+
+#include <memory>
+#include <string>
+#include <vector>
+
+#include "base/callback.h"
+
+namespace remoting {
+namespace protocol {
+
+class DataChannelHandler;
joedow 2017/06/06 23:33:25 remove this fwd declare since it isn't used.
Hzj_jie 2017/06/07 17:31:25 Done.
+class MessagePipe;
+
+// DataChannelManager helps to manage optional data channels. Each
+// DataChannelHandler implementation registers a factory function to create an
+// instance of itself to handle data from a named data channel. All handles are
+// closed when the associated MessagePipe is closed. Clients can also close a
+// data channel manually by calling DataChannelHandler::Close() function.
joedow 2017/06/06 23:33:25 I don't think the DCM should include any impl deta
Hzj_jie 2017/06/07 17:31:25 The client means "the client of DataChannelHandler
+class DataChannelManager final {
+ public:
+ using CreateHandlerCallback = base::Callback<void(
+ const std::string& name,
+ std::unique_ptr<MessagePipe> pipe)>;
+
+ DataChannelManager();
+ ~DataChannelManager();
joedow 2017/06/06 23:33:25 Would it make sense to expose a static function an
Hzj_jie 2017/06/07 17:31:25 The lifetime of a DataChannelManager should be con
+
+ // Registers a factory function to create a DataChannelHandler to handle a new
joedow 2017/06/06 23:33:25 As discussed, it may not create a DataChannelHandl
Hzj_jie 2017/06/07 17:31:25 Done.
+ // incoming data channel with a name matching |prefix|. Returns false if the
+ // registration fails, usually it happens when |prefix| or |constructor| are
+ // empty.
+ bool RegisterCreateHandlerCallback(const std::string& prefix,
+ CreateHandlerCallback constructor);
+
+ // Creates a DataChannelHandler to handle the new incoming data channel.
+ // Returns true if a handler exists for the new data channel.
joedow 2017/06/06 23:33:25 nit: Doesn't the function return true if a handler
Hzj_jie 2017/06/07 17:31:25 Done.
+ bool OnIncomingDataChannel(const std::string& name,
+ std::unique_ptr<MessagePipe> pipe);
+
+ private:
+ std::vector<std::pair<std::string, CreateHandlerCallback>> constructors_;
+};
+
+} // namespace protocol
+} // namespace remoting
+
+#endif // REMOTING_PROTOCOL_DATA_CHANNEL_MANAGER_H_

Powered by Google App Engine
This is Rietveld 408576698