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

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

Issue 1902873002: Convert //extensions/browser/api from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 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>
8
7 #include "base/logging.h" 9 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h"
9 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
10 #include "base/values.h" 11 #include "base/values.h"
11 #include "extensions/common/api/cast_channel.h" 12 #include "extensions/common/api/cast_channel.h"
12 #include "extensions/common/api/cast_channel/cast_channel.pb.h" 13 #include "extensions/common/api/cast_channel/cast_channel.pb.h"
13 14
14 namespace { 15 namespace {
15 static const char kAuthNamespace[] = 16 static const char kAuthNamespace[] =
16 "urn:x-cast:com.google.cast.tp.deviceauth"; 17 "urn:x-cast:com.google.cast.tp.deviceauth";
17 // Sender and receiver IDs to use for platform messages. 18 // Sender and receiver IDs to use for platform messages.
18 static const char kPlatformSenderId[] = "sender-0"; 19 static const char kPlatformSenderId[] = "sender-0";
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 message_proto.has_payload_binary()); 74 message_proto.has_payload_binary());
74 } 75 }
75 76
76 bool CastMessageToMessageInfo(const CastMessage& message_proto, 77 bool CastMessageToMessageInfo(const CastMessage& message_proto,
77 MessageInfo* message) { 78 MessageInfo* message) {
78 DCHECK(message); 79 DCHECK(message);
79 message->source_id = message_proto.source_id(); 80 message->source_id = message_proto.source_id();
80 message->destination_id = message_proto.destination_id(); 81 message->destination_id = message_proto.destination_id();
81 message->namespace_ = message_proto.namespace_(); 82 message->namespace_ = message_proto.namespace_();
82 // Determine the type of the payload and fill base::Value appropriately. 83 // Determine the type of the payload and fill base::Value appropriately.
83 scoped_ptr<base::Value> value; 84 std::unique_ptr<base::Value> value;
84 switch (message_proto.payload_type()) { 85 switch (message_proto.payload_type()) {
85 case CastMessage_PayloadType_STRING: 86 case CastMessage_PayloadType_STRING:
86 if (message_proto.has_payload_utf8()) 87 if (message_proto.has_payload_utf8())
87 value.reset(new base::StringValue(message_proto.payload_utf8())); 88 value.reset(new base::StringValue(message_proto.payload_utf8()));
88 break; 89 break;
89 case CastMessage_PayloadType_BINARY: 90 case CastMessage_PayloadType_BINARY:
90 if (message_proto.has_payload_binary()) 91 if (message_proto.has_payload_binary())
91 value.reset(base::BinaryValue::CreateWithCopiedBuffer( 92 value.reset(base::BinaryValue::CreateWithCopiedBuffer(
92 message_proto.payload_binary().data(), 93 message_proto.payload_binary().data(),
93 message_proto.payload_binary().size())); 94 message_proto.payload_binary().size()));
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 message_proto->set_payload_binary(auth_message_string); 153 message_proto->set_payload_binary(auth_message_string);
153 } 154 }
154 155
155 bool IsAuthMessage(const CastMessage& message) { 156 bool IsAuthMessage(const CastMessage& message) {
156 return message.namespace_() == kAuthNamespace; 157 return message.namespace_() == kAuthNamespace;
157 } 158 }
158 159
159 } // namespace cast_channel 160 } // namespace cast_channel
160 } // namespace api 161 } // namespace api
161 } // namespace extensions 162 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/api/cast_channel/cast_framer_unittest.cc ('k') | extensions/browser/api/cast_channel/cast_socket.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698