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 #ifndef REMOTING_PROTOCOL_CHANNEL_DISPATCHER_BASE_H_ | 5 #ifndef REMOTING_PROTOCOL_CHANNEL_DISPATCHER_BASE_H_ |
6 #define REMOTING_PROTOCOL_CHANNEL_DISPATCHER_BASE_H_ | 6 #define REMOTING_PROTOCOL_CHANNEL_DISPATCHER_BASE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 | 13 |
14 namespace net { | 14 namespace net { |
15 class StreamSocket; | 15 class StreamSocket; |
16 } // namespace net | 16 } // namespace net |
17 | 17 |
18 namespace remoting { | 18 namespace remoting { |
19 namespace protocol { | 19 namespace protocol { |
20 | 20 |
| 21 class ChannelFactory; |
21 class Session; | 22 class Session; |
22 | 23 |
23 // Base class for channel message dispatchers. It's responsible for | 24 // Base class for channel message dispatchers. It's responsible for |
24 // creating the named channel. Derived dispatchers then dispatch | 25 // creating the named channel. Derived dispatchers then dispatch |
25 // incoming messages on this channel as well as send outgoing | 26 // incoming messages on this channel as well as send outgoing |
26 // messages. | 27 // messages. |
27 class ChannelDispatcherBase { | 28 class ChannelDispatcherBase { |
28 public: | 29 public: |
29 // The callback is called when initialization is finished. The | 30 // The callback is called when initialization is finished. The |
30 // parameter is set to true on success. | 31 // parameter is set to true on success. |
(...skipping 14 matching lines...) Expand all Loading... |
45 net::StreamSocket* channel() { return channel_.get(); } | 46 net::StreamSocket* channel() { return channel_.get(); } |
46 | 47 |
47 // Called when channel is initialized. Must be overriden in the | 48 // Called when channel is initialized. Must be overriden in the |
48 // child classes. Should not delete the dispatcher. | 49 // child classes. Should not delete the dispatcher. |
49 virtual void OnInitialized() = 0; | 50 virtual void OnInitialized() = 0; |
50 | 51 |
51 private: | 52 private: |
52 void OnChannelReady(scoped_ptr<net::StreamSocket> socket); | 53 void OnChannelReady(scoped_ptr<net::StreamSocket> socket); |
53 | 54 |
54 std::string channel_name_; | 55 std::string channel_name_; |
55 Session* session_; | 56 ChannelFactory* channel_factory_; |
56 InitializedCallback initialized_callback_; | 57 InitializedCallback initialized_callback_; |
57 scoped_ptr<net::StreamSocket> channel_; | 58 scoped_ptr<net::StreamSocket> channel_; |
58 | 59 |
59 DISALLOW_COPY_AND_ASSIGN(ChannelDispatcherBase); | 60 DISALLOW_COPY_AND_ASSIGN(ChannelDispatcherBase); |
60 }; | 61 }; |
61 | 62 |
62 } // namespace protocol | 63 } // namespace protocol |
63 } // namespace remoting | 64 } // namespace remoting |
64 | 65 |
65 #endif // REMOTING_PROTOCOL_CHANNEL_DISPATCHER_BASE_H_ | 66 #endif // REMOTING_PROTOCOL_CHANNEL_DISPATCHER_BASE_H_ |
OLD | NEW |