Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2011 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 REMOTING_PROTOCOL_CHANNEL_DISPATCHER_BASE_H_ | |
| 6 #define REMOTING_PROTOCOL_CHANNEL_DISPATCHER_BASE_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/callback.h" | |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 | |
| 14 namespace net { | |
| 15 class StreamSocket; | |
| 16 } // namespace net | |
| 17 | |
| 18 namespace remoting { | |
| 19 namespace protocol { | |
| 20 | |
| 21 class Session; | |
| 22 | |
| 23 // Base class for channel dispatchers. It is responsible for creation | |
|
Wez
2011/11/21 02:39:04
nit: What kind of dispatchers? I/O dispatchers, p
Sergey Ulanov
2011/11/21 22:14:22
Done.
| |
| 24 // of channel with the name specified in the constructor. | |
|
Wez
2011/11/21 02:39:04
nit: It's responsible for creating the named chann
Sergey Ulanov
2011/11/21 22:14:22
Done.
| |
| 25 class ChannelDispatcherBase { | |
| 26 public: | |
| 27 // The callback is called when initialization is finished. The | |
| 28 // parameter is set to true on success. | |
| 29 typedef base::Callback<void(bool)> InitializedCallback; | |
| 30 | |
| 31 explicit ChannelDispatcherBase(const char* channel_name); | |
|
Wez
2011/11/21 02:39:04
Should this be protected?
Sergey Ulanov
2011/11/21 22:14:22
Done.
| |
| 32 virtual ~ChannelDispatcherBase(); | |
| 33 | |
| 34 // Creates and connects channel in the specified |session|. Called | |
|
Wez
2011/11/21 02:39:04
typo: Called -> caller.
Wez
2011/11/21 02:39:04
nit: connects _the_ channel.
Wez
2011/11/21 02:39:04
nit: |session| -> Session. (|session| isn't the t
Sergey Ulanov
2011/11/21 22:14:22
Done.
Sergey Ulanov
2011/11/21 22:14:22
Done.
Sergey Ulanov
2011/11/21 22:14:22
Done.
| |
| 35 // retains ownership of |session|. | |
| 36 void Init(Session* session, const InitializedCallback& callback); | |
| 37 | |
| 38 // Returns true if the channel is currently connected. | |
| 39 bool is_connected() { return channel_.get() != NULL; } | |
|
Wez
2011/11/21 02:39:04
nit: This could be { return channel() != NULL; }
Sergey Ulanov
2011/11/21 22:14:22
Done.
| |
| 40 | |
| 41 protected: | |
| 42 net::StreamSocket* channel() { return channel_.get(); } | |
| 43 | |
| 44 // Called when channel is initialized. Must be overriden in the | |
| 45 // child classes. Should not delete the dispatcher. | |
| 46 virtual void OnInitialized() = 0; | |
| 47 | |
| 48 private: | |
| 49 void OnChannelReady(net::StreamSocket* socket); | |
| 50 | |
| 51 std::string channel_name_; | |
| 52 Session* session_; | |
| 53 InitializedCallback initialized_callback_; | |
| 54 scoped_ptr<net::StreamSocket> channel_; | |
| 55 | |
| 56 DISALLOW_COPY_AND_ASSIGN(ChannelDispatcherBase); | |
| 57 }; | |
| 58 | |
| 59 } // namespace protocol | |
| 60 } // namespace remoting | |
| 61 | |
| 62 #endif // REMOTING_PROTOCOL_CHANNEL_DISPATCHER_BASE_H_ | |
| OLD | NEW |