OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 GOOGLE_APIS_GCM_ENGINE_CONNECTION_HANDLER_H_ | 5 #ifndef GOOGLE_APIS_GCM_ENGINE_CONNECTION_HANDLER_H_ |
6 #define GOOGLE_APIS_GCM_ENGINE_CONNECTION_HANDLER_H_ | 6 #define GOOGLE_APIS_GCM_ENGINE_CONNECTION_HANDLER_H_ |
7 | 7 |
| 8 #include <memory> |
| 9 |
8 #include "base/callback.h" | 10 #include "base/callback.h" |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "google_apis/gcm/base/gcm_export.h" | 11 #include "google_apis/gcm/base/gcm_export.h" |
11 | 12 |
12 namespace net{ | 13 namespace net{ |
13 class StreamSocket; | 14 class StreamSocket; |
14 } // namespace net | 15 } // namespace net |
15 | 16 |
16 namespace google { | 17 namespace google { |
17 namespace protobuf { | 18 namespace protobuf { |
18 class MessageLite; | 19 class MessageLite; |
19 } // namespace protobuf | 20 } // namespace protobuf |
20 } // namepsace google | 21 } // namepsace google |
21 | 22 |
22 namespace mcs_proto { | 23 namespace mcs_proto { |
23 class LoginRequest; | 24 class LoginRequest; |
24 } | 25 } |
25 | 26 |
26 namespace gcm { | 27 namespace gcm { |
27 | 28 |
28 class SocketInputStream; | 29 class SocketInputStream; |
29 class SocketOutputStream; | 30 class SocketOutputStream; |
30 | 31 |
31 // Handles performing the protocol handshake and sending/receiving protobuf | 32 // Handles performing the protocol handshake and sending/receiving protobuf |
32 // messages. Note that no retrying or queueing is enforced at this layer. | 33 // messages. Note that no retrying or queueing is enforced at this layer. |
33 // Once a connection error is encountered, the ConnectionHandler will disconnect | 34 // Once a connection error is encountered, the ConnectionHandler will disconnect |
34 // the socket and must be reinitialized with a new StreamSocket before | 35 // the socket and must be reinitialized with a new StreamSocket before |
35 // messages can be sent/received again. | 36 // messages can be sent/received again. |
36 class GCM_EXPORT ConnectionHandler { | 37 class GCM_EXPORT ConnectionHandler { |
37 public: | 38 public: |
38 typedef base::Callback<void(scoped_ptr<google::protobuf::MessageLite>)> | 39 typedef base::Callback<void(std::unique_ptr<google::protobuf::MessageLite>)> |
39 ProtoReceivedCallback; | 40 ProtoReceivedCallback; |
40 typedef base::Closure ProtoSentCallback; | 41 typedef base::Closure ProtoSentCallback; |
41 typedef base::Callback<void(int)> ConnectionChangedCallback; | 42 typedef base::Callback<void(int)> ConnectionChangedCallback; |
42 | 43 |
43 ConnectionHandler(); | 44 ConnectionHandler(); |
44 virtual ~ConnectionHandler(); | 45 virtual ~ConnectionHandler(); |
45 | 46 |
46 // Starts a new MCS connection handshake (using |login_request|) and, upon | 47 // Starts a new MCS connection handshake (using |login_request|) and, upon |
47 // success, begins listening for incoming/outgoing messages. | 48 // success, begins listening for incoming/outgoing messages. |
48 // | 49 // |
(...skipping 10 matching lines...) Expand all Loading... |
59 // in flight. | 60 // in flight. |
60 virtual bool CanSendMessage() const = 0; | 61 virtual bool CanSendMessage() const = 0; |
61 | 62 |
62 // Send an MCS protobuf message. CanSendMessage() must be true. | 63 // Send an MCS protobuf message. CanSendMessage() must be true. |
63 virtual void SendMessage(const google::protobuf::MessageLite& message) = 0; | 64 virtual void SendMessage(const google::protobuf::MessageLite& message) = 0; |
64 }; | 65 }; |
65 | 66 |
66 } // namespace gcm | 67 } // namespace gcm |
67 | 68 |
68 #endif // GOOGLE_APIS_GCM_ENGINE_CONNECTION_HANDLER_H_ | 69 #endif // GOOGLE_APIS_GCM_ENGINE_CONNECTION_HANDLER_H_ |
OLD | NEW |