| 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..0bb52e70847d66471f572fef134bf156d0464e8e
|
| --- /dev/null
|
| +++ b/remoting/protocol/data_channel_manager.h
|
| @@ -0,0 +1,54 @@
|
| +// 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 <map>
|
| +#include <memory>
|
| +#include <string>
|
| +#include <vector>
|
| +
|
| +#include "base/callback.h"
|
| +
|
| +namespace remoting {
|
| +namespace protocol {
|
| +
|
| +class DataChannelHandler;
|
| +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.
|
| +class DataChannelManager final {
|
| + public:
|
| + using HandlerFactory = base::Callback<void(
|
| + const std::string& name,
|
| + std::unique_ptr<MessagePipe> pipe)>;
|
| +
|
| + DataChannelManager();
|
| + ~DataChannelManager();
|
| +
|
| + // Registers a factory function to create a DataChannelHandler to handle a new
|
| + // incoming data channel with a name matching |regex|. Returns false if the
|
| + // registration fails, usually it happens when |regex| or |constructor| are
|
| + // empty.
|
| + bool RegisterHandlerFactory(const std::string& regex,
|
| + HandlerFactory constructor);
|
| +
|
| + // Creates a DataChannelHandler to handle the new incoming data channel.
|
| + // Returns true if a handler exists for the new data channel.
|
| + bool OnIncomingDataChannel(const std::string& name,
|
| + std::unique_ptr<MessagePipe> pipe);
|
| +
|
| + private:
|
| + std::vector<std::pair<std::string, HandlerFactory>> constructors_;
|
| +};
|
| +
|
| +} // namespace protocol
|
| +} // namespace remoting
|
| +
|
| +#endif // REMOTING_PROTOCOL_DATA_CHANNEL_MANAGER_H_
|
|
|