| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef BLIMP_NET_THREAD_PIPE_MANAGER_H_ | |
| 6 #define BLIMP_NET_THREAD_PIPE_MANAGER_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/macros.h" | |
| 12 #include "base/memory/ref_counted.h" | |
| 13 #include "base/sequence_checker.h" | |
| 14 #include "blimp/common/proto/blimp_message.pb.h" | |
| 15 #include "blimp/net/blimp_net_export.h" | |
| 16 #include "blimp/net/pipe_manager.h" | |
| 17 | |
| 18 namespace base { | |
| 19 class SequencedTaskRunner; | |
| 20 } // namespace base | |
| 21 | |
| 22 namespace blimp { | |
| 23 | |
| 24 class BlimpMessageThreadPipe; | |
| 25 class BrowserConnectionHandler; | |
| 26 class ConnectionThreadPipeManager; | |
| 27 | |
| 28 // Manages routing of messages between a |connection_manager| operating on one | |
| 29 // SequencedTaskRunner, and per-feature message processors running on the same | |
| 30 // TaskRunner as the caller. This is used to allow Blimp feature implementations | |
| 31 // to operate on the UI thread, with network I/O delegated to an IO thread. | |
| 32 class BLIMP_NET_EXPORT ThreadPipeManager : public PipeManager { | |
| 33 public: | |
| 34 // Caller is responsible for ensuring that |connection_handler| outlives | |
| 35 // |this|. | |
| 36 explicit ThreadPipeManager( | |
| 37 const scoped_refptr<base::SequencedTaskRunner>& connection_task_runner, | |
| 38 BrowserConnectionHandler* connection_handler); | |
| 39 | |
| 40 ~ThreadPipeManager() override; | |
| 41 | |
| 42 std::unique_ptr<BlimpMessageProcessor> RegisterFeature( | |
| 43 BlimpMessage::FeatureCase feature_case, | |
| 44 BlimpMessageProcessor* incoming_processor) override; | |
| 45 | |
| 46 private: | |
| 47 scoped_refptr<base::SequencedTaskRunner> connection_task_runner_; | |
| 48 | |
| 49 // Container for BlimpMessageThreadPipes that are destroyed on IO thread. | |
| 50 std::unique_ptr<ConnectionThreadPipeManager> connection_pipe_manager_; | |
| 51 | |
| 52 // Pipes for routing incoming messages from the connection's task runner | |
| 53 // to handlers on the caller's task runner. | |
| 54 std::vector<std::unique_ptr<BlimpMessageThreadPipe>> incoming_pipes_; | |
| 55 | |
| 56 base::SequenceChecker sequence_checker_; | |
| 57 | |
| 58 DISALLOW_COPY_AND_ASSIGN(ThreadPipeManager); | |
| 59 }; | |
| 60 | |
| 61 } // namespace blimp | |
| 62 | |
| 63 #endif // BLIMP_NET_THREAD_PIPE_MANAGER_H_ | |
| OLD | NEW |