| OLD | NEW |
| 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 "content/common/presentation/presentation_struct_traits.h" | 5 #include "content/common/presentation/presentation_struct_traits.h" |
| 6 | 6 |
| 7 #include "url/mojo/url_gurl_struct_traits.h" | 7 #include "url/mojo/url_gurl_struct_traits.h" |
| 8 | 8 |
| 9 namespace mojo { | 9 namespace mojo { |
| 10 | 10 |
| 11 bool StructTraits<blink::mojom::PresentationSessionInfoDataView, | 11 bool StructTraits<blink::mojom::PresentationInfoDataView, |
| 12 content::PresentationSessionInfo>:: | 12 content::PresentationInfo>:: |
| 13 Read(blink::mojom::PresentationSessionInfoDataView data, | 13 Read(blink::mojom::PresentationInfoDataView data, |
| 14 content::PresentationSessionInfo* out) { | 14 content::PresentationInfo* out) { |
| 15 if (!data.ReadUrl(&(out->presentation_url)) || | 15 if (!data.ReadUrl(&(out->presentation_url)) || |
| 16 !data.ReadId(&(out->presentation_id))) { | 16 !data.ReadId(&(out->presentation_id))) { |
| 17 return false; | 17 return false; |
| 18 } | 18 } |
| 19 | 19 |
| 20 if (out->presentation_id.empty() || | 20 if (out->presentation_id.empty() || |
| 21 !base::IsStringASCII(out->presentation_id) || | 21 !base::IsStringASCII(out->presentation_id) || |
| 22 out->presentation_id.length() > | 22 out->presentation_id.length() > content::PresentationInfo::kMaxIdLength) { |
| 23 content::PresentationSessionInfo::kMaxIdLength) { | |
| 24 return false; | 23 return false; |
| 25 } | 24 } |
| 26 return true; | 25 return true; |
| 27 } | 26 } |
| 28 | 27 |
| 29 bool StructTraits<blink::mojom::PresentationErrorDataView, | 28 bool StructTraits<blink::mojom::PresentationErrorDataView, |
| 30 content::PresentationError>:: | 29 content::PresentationError>:: |
| 31 Read(blink::mojom::PresentationErrorDataView data, | 30 Read(blink::mojom::PresentationErrorDataView data, |
| 32 content::PresentationError* out) { | 31 content::PresentationError* out) { |
| 33 if (!data.ReadErrorType(&(out->error_type)) || | 32 if (!data.ReadErrorType(&(out->error_type)) || |
| (...skipping 21 matching lines...) Expand all Loading... |
| 55 } | 54 } |
| 56 } else { | 55 } else { |
| 57 if (!data.ReadData(&(out->data)) || | 56 if (!data.ReadData(&(out->data)) || |
| 58 out->data->size() > content::kMaxPresentationConnectionMessageSize) { | 57 out->data->size() > content::kMaxPresentationConnectionMessageSize) { |
| 59 return false; | 58 return false; |
| 60 } | 59 } |
| 61 } | 60 } |
| 62 return true; | 61 return true; |
| 63 } | 62 } |
| 64 } | 63 } |
| OLD | NEW |