| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/common/presentation/presentation_struct_traits.h" |
| 6 |
| 7 #include "url/mojo/url_gurl_struct_traits.h" |
| 8 |
| 9 namespace mojo { |
| 10 |
| 11 bool StructTraits<blink::mojom::PresentationSessionInfoDataView, |
| 12 content::PresentationSessionInfo>:: |
| 13 Read(blink::mojom::PresentationSessionInfoDataView data, |
| 14 content::PresentationSessionInfo* out) { |
| 15 if (!data.ReadUrl(&(out->presentation_url)) || |
| 16 !data.ReadId(&(out->presentation_id))) { |
| 17 return false; |
| 18 } |
| 19 |
| 20 if (out->presentation_id.empty() || |
| 21 !base::IsStringASCII(out->presentation_id) || |
| 22 out->presentation_id.length() > |
| 23 content::PresentationSessionInfo::kMaxIdLength) { |
| 24 return false; |
| 25 } |
| 26 return true; |
| 27 } |
| 28 |
| 29 bool StructTraits<blink::mojom::PresentationErrorDataView, |
| 30 content::PresentationError>:: |
| 31 Read(blink::mojom::PresentationErrorDataView data, |
| 32 content::PresentationError* out) { |
| 33 if (!data.ReadErrorType(&(out->error_type)) || |
| 34 !data.ReadMessage(&(out->message))) { |
| 35 return false; |
| 36 } |
| 37 |
| 38 if (!base::IsStringUTF8(out->message) || |
| 39 out->message.length() > content::PresentationError::kMaxMessageLength) { |
| 40 return false; |
| 41 } |
| 42 |
| 43 return true; |
| 44 } |
| 45 |
| 46 bool UnionTraits<blink::mojom::PresentationConnectionMessageDataView, |
| 47 content::PresentationConnectionMessage>:: |
| 48 Read(blink::mojom::PresentationConnectionMessageDataView data, |
| 49 content::PresentationConnectionMessage* out) { |
| 50 if (data.is_message()) { |
| 51 if (!data.ReadMessage(&(out->message)) || |
| 52 out->message->length() > |
| 53 content::kMaxPresentationConnectionMessageSize) { |
| 54 return false; |
| 55 } |
| 56 } else { |
| 57 if (!data.ReadData(&(out->data)) || |
| 58 out->data->size() > content::kMaxPresentationConnectionMessageSize) { |
| 59 return false; |
| 60 } |
| 61 } |
| 62 return true; |
| 63 } |
| 64 } |
| OLD | NEW |