blob: 639e84626432adad35c6c0b370f9ff4e1a73ffd2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "media/mojo/mojom/status_mojom_traits.h"
#include "media/base/status_codes.h"
#include "media/mojo/mojom/media_types.mojom.h"
#include "mojo/public/cpp/base/values_mojom_traits.h"
namespace mojo {
// static
bool StructTraits<media::mojom::StatusDataView, media::Status>::Read(
media::mojom::StatusDataView data,
media::Status* output) {
DCHECK(!output->data_);
media::StatusCode code;
std::string message;
if (!data.ReadCode(&code))
return false;
if (media::StatusCode::kOk == code)
return true;
absl::optional<std::string> optional_message;
if (!data.ReadMessage(&optional_message))
return false;
message = std::move(optional_message).value_or(std::string());
output->data_ =
std::make_unique<media::Status::StatusInternal>(code, std::move(message));
if (!data.ReadFrames(&output->data_->frames))
return false;
if (!data.ReadCauses(&output->data_->causes))
return false;
absl::optional<base::Value> optional_data;
if (!data.ReadData(&optional_data))
return false;
output->data_->data = std::move(optional_data).value_or(base::Value());
return true;
}
} // namespace mojo
|