| 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_IMPL_H_ | 5 #ifndef GOOGLE_APIS_GCM_ENGINE_CONNECTION_HANDLER_IMPL_H_ |
| 6 #define GOOGLE_APIS_GCM_ENGINE_CONNECTION_HANDLER_IMPL_H_ | 6 #define GOOGLE_APIS_GCM_ENGINE_CONNECTION_HANDLER_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "base/timer/timer.h" | 10 #include "base/timer/timer.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 // |write_callback| will be invoked anytime a message has been successfully | 23 // |write_callback| will be invoked anytime a message has been successfully |
| 24 // sent. Note: this just means the data was sent to the wire, not that the | 24 // sent. Note: this just means the data was sent to the wire, not that the |
| 25 // other end received it. | 25 // other end received it. |
| 26 // |connection_callback| will be invoked with any fatal read/write errors | 26 // |connection_callback| will be invoked with any fatal read/write errors |
| 27 // encountered. | 27 // encountered. |
| 28 ConnectionHandlerImpl( | 28 ConnectionHandlerImpl( |
| 29 base::TimeDelta read_timeout, | 29 base::TimeDelta read_timeout, |
| 30 const ProtoReceivedCallback& read_callback, | 30 const ProtoReceivedCallback& read_callback, |
| 31 const ProtoSentCallback& write_callback, | 31 const ProtoSentCallback& write_callback, |
| 32 const ConnectionChangedCallback& connection_callback); | 32 const ConnectionChangedCallback& connection_callback); |
| 33 virtual ~ConnectionHandlerImpl(); | 33 ~ConnectionHandlerImpl() override; |
| 34 | 34 |
| 35 // ConnectionHandler implementation. | 35 // ConnectionHandler implementation. |
| 36 virtual void Init(const mcs_proto::LoginRequest& login_request, | 36 void Init(const mcs_proto::LoginRequest& login_request, |
| 37 net::StreamSocket* socket) override; | 37 net::StreamSocket* socket) override; |
| 38 virtual void Reset() override; | 38 void Reset() override; |
| 39 virtual bool CanSendMessage() const override; | 39 bool CanSendMessage() const override; |
| 40 virtual void SendMessage(const google::protobuf::MessageLite& message) | 40 void SendMessage(const google::protobuf::MessageLite& message) override; |
| 41 override; | |
| 42 | 41 |
| 43 private: | 42 private: |
| 44 // State machine for handling incoming data. See WaitForData(..) for usage. | 43 // State machine for handling incoming data. See WaitForData(..) for usage. |
| 45 enum ProcessingState { | 44 enum ProcessingState { |
| 46 // Processing the version, tag, and size packets (assuming minimum length | 45 // Processing the version, tag, and size packets (assuming minimum length |
| 47 // size packet). Only used during the login handshake. | 46 // size packet). Only used during the login handshake. |
| 48 MCS_VERSION_TAG_AND_SIZE = 0, | 47 MCS_VERSION_TAG_AND_SIZE = 0, |
| 49 // Processing the tag and size packets (assuming minimum length size | 48 // Processing the tag and size packets (assuming minimum length size |
| 50 // packet). Used for normal messages. | 49 // packet). Used for normal messages. |
| 51 MCS_TAG_AND_SIZE, | 50 MCS_TAG_AND_SIZE, |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 ConnectionChangedCallback connection_callback_; | 113 ConnectionChangedCallback connection_callback_; |
| 115 | 114 |
| 116 base::WeakPtrFactory<ConnectionHandlerImpl> weak_ptr_factory_; | 115 base::WeakPtrFactory<ConnectionHandlerImpl> weak_ptr_factory_; |
| 117 | 116 |
| 118 DISALLOW_COPY_AND_ASSIGN(ConnectionHandlerImpl); | 117 DISALLOW_COPY_AND_ASSIGN(ConnectionHandlerImpl); |
| 119 }; | 118 }; |
| 120 | 119 |
| 121 } // namespace gcm | 120 } // namespace gcm |
| 122 | 121 |
| 123 #endif // GOOGLE_APIS_GCM_ENGINE_CONNECTION_HANDLER_IMPL_H_ | 122 #endif // GOOGLE_APIS_GCM_ENGINE_CONNECTION_HANDLER_IMPL_H_ |
| OLD | NEW |