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

media / mojo / mojom / status_mojom_traits.cc [blame]

// Copyright 2020 The Chromium Authors
// 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/mojo/mojom/media_types.mojom.h"
#include "mojo/public/cpp/base/values_mojom_traits.h"

namespace mojo {

// static
bool StructTraits<
    media::mojom::StatusDataDataView,
    media::internal::StatusData>::Read(media::mojom::StatusDataDataView data,
                                       media::internal::StatusData* output) {
  output->code = data.code();
  output->packed_root_cause = data.packed_root_cause();

  if (!data.ReadGroup(&output->group))
    return false;

  if (!data.ReadMessage(&output->message))
    return false;

  if (!data.ReadFrames(&output->frames))
    return false;

  if (!data.ReadData(&output->data))
    return false;

  std::optional<media::internal::StatusData> cause;
  if (!data.ReadCause(&cause))
    return false;

  if (cause.has_value()) {
    output->cause =
        std::make_unique<media::internal::StatusData>(std::move(*cause));
  }

  return true;
}

}  // namespace mojo