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

Side by Side Diff: content/common/presentation/presentation_struct_traits.cc

Issue 2706463002: [Presentation API] Mojo typemap for content::PresentationConnectionMessage (Closed)
Patch Set: Fix compile error after rebase Created 3 years, 9 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
(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 }
OLDNEW
« no previous file with comments | « content/common/presentation/presentation_struct_traits.h ('k') | content/public/browser/presentation_service_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698