Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(323)

Side by Side Diff: chromeos/components/tether/message_wrapper.cc

Issue 2913363002: [CrOS Tether] Add KeepAliveTickleResponse messages to both the proto file and MessageWrapper. (Closed)
Patch Set: Rebased. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "chromeos/components/tether/message_wrapper.h" 5 #include "chromeos/components/tether/message_wrapper.h"
6 6
7 #include "base/base64url.h" 7 #include "base/base64url.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 29 matching lines...) Expand all
40 base::MakeUnique<DisconnectTetheringRequest>(); 40 base::MakeUnique<DisconnectTetheringRequest>();
41 disconnect_request->ParseFromString(decoded_message); 41 disconnect_request->ParseFromString(decoded_message);
42 return std::move(disconnect_request); 42 return std::move(disconnect_request);
43 } 43 }
44 case MessageType::KEEP_ALIVE_TICKLE: { 44 case MessageType::KEEP_ALIVE_TICKLE: {
45 std::unique_ptr<KeepAliveTickle> keep_alive_tickle = 45 std::unique_ptr<KeepAliveTickle> keep_alive_tickle =
46 base::MakeUnique<KeepAliveTickle>(); 46 base::MakeUnique<KeepAliveTickle>();
47 keep_alive_tickle->ParseFromString(decoded_message); 47 keep_alive_tickle->ParseFromString(decoded_message);
48 return std::move(keep_alive_tickle); 48 return std::move(keep_alive_tickle);
49 } 49 }
50 case MessageType::KEEP_ALIVE_TICKLE_RESPONSE: {
51 std::unique_ptr<KeepAliveTickleResponse> keep_alive_tickle_response =
52 base::MakeUnique<KeepAliveTickleResponse>();
53 keep_alive_tickle_response->ParseFromString(decoded_message);
54 return std::move(keep_alive_tickle_response);
55 }
50 case MessageType::TETHER_AVAILABILITY_REQUEST: { 56 case MessageType::TETHER_AVAILABILITY_REQUEST: {
51 std::unique_ptr<TetherAvailabilityRequest> tether_request = 57 std::unique_ptr<TetherAvailabilityRequest> tether_request =
52 base::MakeUnique<TetherAvailabilityRequest>(); 58 base::MakeUnique<TetherAvailabilityRequest>();
53 tether_request->ParseFromString(decoded_message); 59 tether_request->ParseFromString(decoded_message);
54 return std::move(tether_request); 60 return std::move(tether_request);
55 } 61 }
56 case MessageType::TETHER_AVAILABILITY_RESPONSE: { 62 case MessageType::TETHER_AVAILABILITY_RESPONSE: {
57 std::unique_ptr<TetherAvailabilityResponse> tether_response = 63 std::unique_ptr<TetherAvailabilityResponse> tether_response =
58 base::MakeUnique<TetherAvailabilityResponse>(); 64 base::MakeUnique<TetherAvailabilityResponse>();
59 tether_response->ParseFromString(decoded_message); 65 tether_response->ParseFromString(decoded_message);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 proto_(new ConnectTetheringResponse(response)) {} 122 proto_(new ConnectTetheringResponse(response)) {}
117 123
118 MessageWrapper::MessageWrapper(const DisconnectTetheringRequest& request) 124 MessageWrapper::MessageWrapper(const DisconnectTetheringRequest& request)
119 : type_(MessageType::DISCONNECT_TETHERING_REQUEST), 125 : type_(MessageType::DISCONNECT_TETHERING_REQUEST),
120 proto_(new DisconnectTetheringRequest(request)) {} 126 proto_(new DisconnectTetheringRequest(request)) {}
121 127
122 MessageWrapper::MessageWrapper(const KeepAliveTickle& tickle) 128 MessageWrapper::MessageWrapper(const KeepAliveTickle& tickle)
123 : type_(MessageType::KEEP_ALIVE_TICKLE), 129 : type_(MessageType::KEEP_ALIVE_TICKLE),
124 proto_(new KeepAliveTickle(tickle)) {} 130 proto_(new KeepAliveTickle(tickle)) {}
125 131
132 MessageWrapper::MessageWrapper(const KeepAliveTickleResponse& response)
133 : type_(MessageType::KEEP_ALIVE_TICKLE_RESPONSE),
134 proto_(new KeepAliveTickleResponse(response)) {}
135
126 MessageWrapper::MessageWrapper(const TetherAvailabilityRequest& request) 136 MessageWrapper::MessageWrapper(const TetherAvailabilityRequest& request)
127 : type_(MessageType::TETHER_AVAILABILITY_REQUEST), 137 : type_(MessageType::TETHER_AVAILABILITY_REQUEST),
128 proto_(new TetherAvailabilityRequest(request)) {} 138 proto_(new TetherAvailabilityRequest(request)) {}
129 139
130 MessageWrapper::MessageWrapper(const TetherAvailabilityResponse& response) 140 MessageWrapper::MessageWrapper(const TetherAvailabilityResponse& response)
131 : type_(MessageType::TETHER_AVAILABILITY_RESPONSE), 141 : type_(MessageType::TETHER_AVAILABILITY_RESPONSE),
132 proto_(new TetherAvailabilityResponse(response)) {} 142 proto_(new TetherAvailabilityResponse(response)) {}
133 143
134 MessageWrapper::MessageWrapper( 144 MessageWrapper::MessageWrapper(
135 const MessageType& type, 145 const MessageType& type,
(...skipping 22 matching lines...) Expand all
158 json_dictionary.SetString(kJsonDataKey, encoded_message); 168 json_dictionary.SetString(kJsonDataKey, encoded_message);
159 169
160 std::string raw_message; 170 std::string raw_message;
161 base::JSONWriter::Write(json_dictionary, &raw_message); 171 base::JSONWriter::Write(json_dictionary, &raw_message);
162 return raw_message; 172 return raw_message;
163 } 173 }
164 174
165 } // namespace tether 175 } // namespace tether
166 176
167 } // namespace chromeos 177 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/components/tether/message_wrapper.h ('k') | chromeos/components/tether/message_wrapper_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698