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

Side by Side Diff: extensions/browser/api/cast_channel/cast_message_util.cc

Issue 2539363004: Make base::Value::TYPE a scoped enum. (Closed)
Patch Set: Rebase Created 4 years 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/browser/api/cast_channel/cast_message_util.h" 5 #include "extensions/browser/api/cast_channel/cast_message_util.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 22 matching lines...) Expand all
33 message_proto->set_protocol_version(CastMessage_ProtocolVersion_CASTV2_1_0); 33 message_proto->set_protocol_version(CastMessage_ProtocolVersion_CASTV2_1_0);
34 message_proto->set_source_id(message.source_id); 34 message_proto->set_source_id(message.source_id);
35 message_proto->set_destination_id(message.destination_id); 35 message_proto->set_destination_id(message.destination_id);
36 message_proto->set_namespace_(message.namespace_); 36 message_proto->set_namespace_(message.namespace_);
37 // Determine the type of the base::Value and set the message payload 37 // Determine the type of the base::Value and set the message payload
38 // appropriately. 38 // appropriately.
39 std::string data; 39 std::string data;
40 base::BinaryValue* real_value; 40 base::BinaryValue* real_value;
41 switch (message.data->GetType()) { 41 switch (message.data->GetType()) {
42 // JS string 42 // JS string
43 case base::Value::TYPE_STRING: 43 case base::Value::Type::STRING:
44 if (message.data->GetAsString(&data)) { 44 if (message.data->GetAsString(&data)) {
45 message_proto->set_payload_type(CastMessage_PayloadType_STRING); 45 message_proto->set_payload_type(CastMessage_PayloadType_STRING);
46 message_proto->set_payload_utf8(data); 46 message_proto->set_payload_utf8(data);
47 } 47 }
48 break; 48 break;
49 // JS ArrayBuffer 49 // JS ArrayBuffer
50 case base::Value::TYPE_BINARY: 50 case base::Value::Type::BINARY:
51 real_value = static_cast<base::BinaryValue*>(message.data.get()); 51 real_value = static_cast<base::BinaryValue*>(message.data.get());
52 if (real_value->GetBuffer()) { 52 if (real_value->GetBuffer()) {
53 message_proto->set_payload_type(CastMessage_PayloadType_BINARY); 53 message_proto->set_payload_type(CastMessage_PayloadType_BINARY);
54 message_proto->set_payload_binary(real_value->GetBuffer(), 54 message_proto->set_payload_binary(real_value->GetBuffer(),
55 real_value->GetSize()); 55 real_value->GetSize());
56 } 56 }
57 break; 57 break;
58 default: 58 default:
59 // Unknown value type. message_proto will remain uninitialized because 59 // Unknown value type. message_proto will remain uninitialized because
60 // payload_type is unset. 60 // payload_type is unset.
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 message_proto->set_payload_binary(auth_message_string); 153 message_proto->set_payload_binary(auth_message_string);
154 } 154 }
155 155
156 bool IsAuthMessage(const CastMessage& message) { 156 bool IsAuthMessage(const CastMessage& message) {
157 return message.namespace_() == kAuthNamespace; 157 return message.namespace_() == kAuthNamespace;
158 } 158 }
159 159
160 } // namespace cast_channel 160 } // namespace cast_channel
161 } // namespace api 161 } // namespace api
162 } // namespace extensions 162 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/api/cast_channel/cast_channel_api.cc ('k') | extensions/browser/api/declarative/declarative_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698