| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2010 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_STREAM_WRITER_H_ | |
| 6 #define REMOTING_PROTOCOL_STREAM_WRITER_H_ | |
| 7 | |
| 8 #include "base/ref_counted.h" | |
| 9 #include "remoting/proto/internal.pb.h" | |
| 10 | |
| 11 namespace net { | |
| 12 class Socket; | |
| 13 } // namespace net | |
| 14 | |
| 15 namespace remoting { | |
| 16 namespace protocol { | |
| 17 | |
| 18 class BufferedSocketWriter; | |
| 19 | |
| 20 class StreamWriterBase { | |
| 21 public: | |
| 22 StreamWriterBase(); | |
| 23 virtual ~StreamWriterBase(); | |
| 24 | |
| 25 // Initializes the writer. Must be called on the thread the |socket| belongs | |
| 26 // to. | |
| 27 void Init(net::Socket* socket); | |
| 28 | |
| 29 // Return current buffer state. Can be called from any thread. | |
| 30 int GetBufferSize(); | |
| 31 int GetPendingMessages(); | |
| 32 | |
| 33 // Stop writing and drop pending data. Must be called from the same thread as | |
| 34 // Init(). | |
| 35 void Close(); | |
| 36 | |
| 37 protected: | |
| 38 net::Socket* socket_; | |
| 39 scoped_refptr<BufferedSocketWriter> buffered_writer_; | |
| 40 }; | |
| 41 | |
| 42 class EventStreamWriter : public StreamWriterBase { | |
| 43 public: | |
| 44 // Sends the |message| or returns false if called before Init(). | |
| 45 // Can be called on any thread. | |
| 46 bool SendMessage(const EventMessage& message); | |
| 47 }; | |
| 48 | |
| 49 class ControlStreamWriter : public StreamWriterBase { | |
| 50 public: | |
| 51 // Sends the |message| or returns false if called before Init(). | |
| 52 // Can be called on any thread. | |
| 53 bool SendMessage(const ControlMessage& message); | |
| 54 }; | |
| 55 | |
| 56 } // namespace protocol | |
| 57 } // namespace remoting | |
| 58 | |
| 59 #endif // REMOTING_PROTOCOL_STREAM_WRITER_H_ | |
| OLD | NEW |