// services/network/public/mojom/request_priority.mojom-shared.cc is auto generated by mojom_bindings_generator.py, do not edit

// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "services/network/public/mojom/request_priority.mojom-shared.h"
#include <ostream>
#include <utility>
#include "base/strings/stringprintf.h"
#include "mojo/public/cpp/bindings/lib/validate_params.h"
#include "mojo/public/cpp/bindings/lib/validation_errors.h"
#include "mojo/public/cpp/bindings/lib/validation_util.h"
#include "third_party/perfetto/include/perfetto/tracing/traced_value.h"

#include "services/network/public/mojom/request_priority.mojom-params-data.h"
namespace network {
namespace mojom {

NOINLINE static const char* RequestPriorityToStringHelper(RequestPriority value) {
  // Defined in a helper function to ensure that Clang generates a lookup table.
  switch(value) {
    case RequestPriority::kThrottled:
      return "kThrottled";
    case RequestPriority::kIdle:
      return "kIdle";
    case RequestPriority::kLowest:
      return "kLowest";
    case RequestPriority::kLow:
      return "kLow";
    case RequestPriority::kMedium:
      return "kMedium";
    case RequestPriority::kHighest:
      return "kHighest";
    default:
      return nullptr;
  }
}

std::string RequestPriorityToString(RequestPriority value) {
  const char *str = RequestPriorityToStringHelper(value);
  if (!str) {
    return base::StringPrintf("Unknown RequestPriority value: %i", static_cast<int32_t>(value));
  }
  return str;
}

std::ostream& operator<<(std::ostream& os, RequestPriority value) {
  return os << RequestPriorityToString(value);
}

NOINLINE static const char* FetchPriorityAttributeToStringHelper(FetchPriorityAttribute value) {
  // Defined in a helper function to ensure that Clang generates a lookup table.
  switch(value) {
    case FetchPriorityAttribute::kLow:
      return "kLow";
    case FetchPriorityAttribute::kAuto:
      return "kAuto";
    case FetchPriorityAttribute::kHigh:
      return "kHigh";
    default:
      return nullptr;
  }
}

std::string FetchPriorityAttributeToString(FetchPriorityAttribute value) {
  const char *str = FetchPriorityAttributeToStringHelper(value);
  if (!str) {
    return base::StringPrintf("Unknown FetchPriorityAttribute value: %i", static_cast<int32_t>(value));
  }
  return str;
}

std::ostream& operator<<(std::ostream& os, FetchPriorityAttribute value) {
  return os << FetchPriorityAttributeToString(value);
}

namespace internal {

}  // namespace internal
}  // namespace mojom
}  // namespace network

namespace perfetto {

// static
void TraceFormatTraits<::network::mojom::RequestPriority>::WriteIntoTrace(
   perfetto::TracedValue context, ::network::mojom::RequestPriority value) {
  return std::move(context).WriteString(::network::mojom::RequestPriorityToString(value));
}

} // namespace perfetto

namespace perfetto {

// static
void TraceFormatTraits<::network::mojom::FetchPriorityAttribute>::WriteIntoTrace(
   perfetto::TracedValue context, ::network::mojom::FetchPriorityAttribute value) {
  return std::move(context).WriteString(::network::mojom::FetchPriorityAttributeToString(value));
}

} // namespace perfetto