summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/public/common/fetch/fetch_api_request_headers_mojom_traits.h
blob: 9454bd0ab0047ac2f981322c96104c483d993393 (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
// Copyright 2018 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.

#ifndef THIRD_PARTY_BLINK_PUBLIC_COMMON_FETCH_FETCH_API_REQUEST_HEADERS_MOJOM_TRAITS_H_
#define THIRD_PARTY_BLINK_PUBLIC_COMMON_FETCH_FETCH_API_REQUEST_HEADERS_MOJOM_TRAITS_H_

#include <string>

#include "base/containers/flat_map.h"
#include "base/strings/string_util.h"
#include "third_party/blink/public/common/fetch/fetch_api_request_headers_map.h"
#include "third_party/blink/public/mojom/fetch/fetch_api_request.mojom.h"

namespace mojo {

template <>
struct StructTraits<blink::mojom::FetchAPIRequestHeadersDataView,
                    blink::FetchAPIRequestHeadersMap> {
  static base::flat_map<std::string, std::string> headers(
      const blink::FetchAPIRequestHeadersMap& in_headers) {
    return {in_headers.begin(), in_headers.end()};
  }

  static bool Read(blink::mojom::FetchAPIRequestHeadersDataView in,
                   blink::FetchAPIRequestHeadersMap* out) {
    return in.ReadHeaders(out);
  }
};

}  // namespace mojo

#endif  // THIRD_PARTY_BLINK_PUBLIC_COMMON_FETCH_FETCH_API_REQUEST_HEADERS_MOJOM_TRAITS_H_