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

Side by Side Diff: content/public/common/presentation_connection_message.cc

Issue 2706463002: [Presentation API] Mojo typemap for content::PresentationConnectionMessage (Closed)
Patch Set: Fix compile error in presentation_connection_message Created 3 years, 10 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "content/public/common/presentation_connection_message.h" 5 #include "content/public/common/presentation_connection_message.h"
6 6
7 #include <utility>
8
7 namespace content { 9 namespace content {
8 10
11 // TODO(crbug.com/524128): This restriction comes from Cast. Raise this limit
12 // for non-Cast presentations.
13 const size_t kMaxPresentationConnectionMessageSize = 64 * 1024; // 64 KB.
14
15 PresentationConnectionMessage::PresentationConnectionMessage() = default;
16
9 PresentationConnectionMessage::PresentationConnectionMessage( 17 PresentationConnectionMessage::PresentationConnectionMessage(
10 PresentationMessageType type) 18 const std::string& message)
11 : type(type) {} 19 : message(std::move(message)) {}
imcheng 2017/02/25 01:08:40 I believe this is still making a copy of the input
mark a. foltz 2017/02/27 23:25:15 Done.
20
21 PresentationConnectionMessage::PresentationConnectionMessage(
22 const std::vector<uint8_t>& data)
23 : data(std::move(data)) {}
24
25 PresentationConnectionMessage::PresentationConnectionMessage(
26 PresentationConnectionMessage&& other) {
27 if (other.is_binary()) {
28 data = std::move(other.data);
dcheng 2017/02/25 07:17:27 It's legal to just write: data = std::move(other.
mark a. foltz 2017/02/27 23:25:14 Done.
29 } else {
30 message = std::move(other.message);
31 }
32 }
12 33
13 PresentationConnectionMessage::~PresentationConnectionMessage() {} 34 PresentationConnectionMessage::~PresentationConnectionMessage() {}
14 35
36 bool PresentationConnectionMessage::operator==(
37 const PresentationConnectionMessage& other) const {
38 if (this->is_binary()) {
39 return other.is_binary() && this->data == other.data;
40 } else {
41 return !this->is_binary() && this->message == other.message;
dcheng 2017/02/25 07:17:27 Or just write return this->data == other.data && t
mark a. foltz 2017/02/27 23:25:15 Done.
42 }
43 }
44
45 PresentationConnectionMessage& PresentationConnectionMessage::operator=(
46 PresentationConnectionMessage&& other) {
47 if (other.is_binary()) {
48 this->message.reset();
49 this->data = std::move(other.data);
dcheng 2017/02/25 07:17:27 Ditto to the move ctor comments: it's legal to jus
mark a. foltz 2017/02/27 23:25:15 Done.
50 } else {
51 this->data.reset();
52 this->message = std::move(other.message);
53 }
54 return *this;
55 }
56
15 bool PresentationConnectionMessage::is_binary() const { 57 bool PresentationConnectionMessage::is_binary() const {
16 return data != nullptr; 58 return data.has_value();
17 } 59 }
18 60
19 } // namespace content 61 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698