| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 #include <google/protobuf/message_lite.h> | 5 #include <google/protobuf/message_lite.h> |
| 6 #include <memory> | 6 #include <memory> |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "chromeos/components/tether/proto/tether.pb.h" | 9 #include "chromeos/components/tether/proto/tether.pb.h" |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 public: | 24 public: |
| 25 // Creates a MessageWrapper from a raw string received from a remote device. | 25 // Creates a MessageWrapper from a raw string received from a remote device. |
| 26 // Returns |nullptr| if the received message is not a valid tethering message. | 26 // Returns |nullptr| if the received message is not a valid tethering message. |
| 27 static std::unique_ptr<MessageWrapper> FromRawMessage( | 27 static std::unique_ptr<MessageWrapper> FromRawMessage( |
| 28 const std::string& message); | 28 const std::string& message); |
| 29 | 29 |
| 30 MessageWrapper(const ConnectTetheringRequest& request); | 30 MessageWrapper(const ConnectTetheringRequest& request); |
| 31 MessageWrapper(const ConnectTetheringResponse& response); | 31 MessageWrapper(const ConnectTetheringResponse& response); |
| 32 MessageWrapper(const DisconnectTetheringRequest& request); | 32 MessageWrapper(const DisconnectTetheringRequest& request); |
| 33 MessageWrapper(const KeepAliveTickle& tickle); | 33 MessageWrapper(const KeepAliveTickle& tickle); |
| 34 MessageWrapper(const KeepAliveTickleResponse& response); |
| 34 MessageWrapper(const TetherAvailabilityRequest& request); | 35 MessageWrapper(const TetherAvailabilityRequest& request); |
| 35 MessageWrapper(const TetherAvailabilityResponse& response); | 36 MessageWrapper(const TetherAvailabilityResponse& response); |
| 36 | 37 |
| 37 ~MessageWrapper(); | 38 ~MessageWrapper(); |
| 38 | 39 |
| 39 std::shared_ptr<google::protobuf::MessageLite> GetProto() const; | 40 std::shared_ptr<google::protobuf::MessageLite> GetProto() const; |
| 40 MessageType GetMessageType() const; | 41 MessageType GetMessageType() const; |
| 41 | 42 |
| 42 // To send a message to a remote device, use ToRawMessage() and send the | 43 // To send a message to a remote device, use ToRawMessage() and send the |
| 43 // result over the wire. | 44 // result over the wire. |
| 44 std::string ToRawMessage() const; | 45 std::string ToRawMessage() const; |
| 45 | 46 |
| 46 protected: | 47 protected: |
| 47 MessageWrapper(const MessageType& type, | 48 MessageWrapper(const MessageType& type, |
| 48 std::shared_ptr<google::protobuf::MessageLite> proto); | 49 std::shared_ptr<google::protobuf::MessageLite> proto); |
| 49 | 50 |
| 50 private: | 51 private: |
| 51 MessageType type_; | 52 MessageType type_; |
| 52 std::shared_ptr<google::protobuf::MessageLite> proto_; | 53 std::shared_ptr<google::protobuf::MessageLite> proto_; |
| 53 | 54 |
| 54 DISALLOW_COPY_AND_ASSIGN(MessageWrapper); | 55 DISALLOW_COPY_AND_ASSIGN(MessageWrapper); |
| 55 }; | 56 }; |
| 56 | 57 |
| 57 } // namespace tether | 58 } // namespace tether |
| 58 | 59 |
| 59 } // namespace chromeos | 60 } // namespace chromeos |
| OLD | NEW |