From 4a8f32142919c1f87ed1d4a3f2872d45b1542dae Mon Sep 17 00:00:00 2001 From: Carlos O'Ryan Date: Mon, 9 May 2022 09:16:52 -0700 Subject: [PATCH] cleanup(storage): refactor `HeadersMap` definition (#8924) --- .../storage/google_cloud_cpp_storage.bzl | 1 + .../storage/google_cloud_cpp_storage.cmake | 1 + google/cloud/storage/headers_map.h | 35 +++++++++++++++++++ .../internal/grpc_object_read_source.cc | 2 -- google/cloud/storage/object_read_stream.h | 5 +-- google/cloud/storage/object_write_stream.h | 5 +-- 6 files changed, 39 insertions(+), 10 deletions(-) create mode 100644 google/cloud/storage/headers_map.h diff --git a/google/cloud/storage/google_cloud_cpp_storage.bzl b/google/cloud/storage/google_cloud_cpp_storage.bzl index 8e7aa0cbbd680..44ca76aa32158 100644 --- a/google/cloud/storage/google_cloud_cpp_storage.bzl +++ b/google/cloud/storage/google_cloud_cpp_storage.bzl @@ -25,6 +25,7 @@ google_cloud_cpp_storage_hdrs = [ "download_options.h", "hash_mismatch_error.h", "hashing_options.h", + "headers_map.h", "hmac_key_metadata.h", "iam_policy.h", "idempotency_policy.h", diff --git a/google/cloud/storage/google_cloud_cpp_storage.cmake b/google/cloud/storage/google_cloud_cpp_storage.cmake index 637ec3155d1f1..b07d6fde6cb8b 100644 --- a/google/cloud/storage/google_cloud_cpp_storage.cmake +++ b/google/cloud/storage/google_cloud_cpp_storage.cmake @@ -35,6 +35,7 @@ add_library( hash_mismatch_error.h hashing_options.cc hashing_options.h + headers_map.h hmac_key_metadata.cc hmac_key_metadata.h iam_policy.cc diff --git a/google/cloud/storage/headers_map.h b/google/cloud/storage/headers_map.h new file mode 100644 index 0000000000000..6cc830e758669 --- /dev/null +++ b/google/cloud/storage/headers_map.h @@ -0,0 +1,35 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_HEADERS_MAP_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_HEADERS_MAP_H + +#include "google/cloud/storage/version.h" +#include +#include + +namespace google { +namespace cloud { +namespace storage { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/// Represents the headers returned in a streaming upload or download operation. +using HeadersMap = std::multimap; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace storage +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_HEADERS_MAP_H diff --git a/google/cloud/storage/internal/grpc_object_read_source.cc b/google/cloud/storage/internal/grpc_object_read_source.cc index 58a43b43d1341..15b01d95f1716 100644 --- a/google/cloud/storage/internal/grpc_object_read_source.cc +++ b/google/cloud/storage/internal/grpc_object_read_source.cc @@ -24,8 +24,6 @@ namespace storage { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN namespace internal { -using HeadersMap = std::multimap; - GrpcObjectReadSource::GrpcObjectReadSource(std::unique_ptr stream) : stream_(std::move(stream)) {} diff --git a/google/cloud/storage/object_read_stream.h b/google/cloud/storage/object_read_stream.h index 4d3a4bbb11041..bee1ad98e2218 100644 --- a/google/cloud/storage/object_read_stream.h +++ b/google/cloud/storage/object_read_stream.h @@ -15,10 +15,10 @@ #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_OBJECT_READ_STREAM_H #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_OBJECT_READ_STREAM_H +#include "google/cloud/storage/headers_map.h" #include "google/cloud/storage/internal/object_read_streambuf.h" #include "google/cloud/storage/version.h" #include -#include #include #include @@ -27,9 +27,6 @@ namespace cloud { namespace storage { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN -/// Represents the headers returned in a streaming upload or download operation. -using HeadersMap = std::multimap; - /** * Defines a `std::basic_istream` to read from a GCS Object. */ diff --git a/google/cloud/storage/object_write_stream.h b/google/cloud/storage/object_write_stream.h index 2c6923510ca39..45aac88d0f95a 100644 --- a/google/cloud/storage/object_write_stream.h +++ b/google/cloud/storage/object_write_stream.h @@ -15,9 +15,9 @@ #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_OBJECT_WRITE_STREAM_H #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_OBJECT_WRITE_STREAM_H +#include "google/cloud/storage/headers_map.h" #include "google/cloud/storage/internal/object_write_streambuf.h" #include "google/cloud/storage/version.h" -#include #include #include #include @@ -27,9 +27,6 @@ namespace cloud { namespace storage { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN -/// Represents the headers returned in a streaming upload or download operation. -using HeadersMap = std::multimap; - /** * Defines a `std::basic_ostream` to write to a GCS object. *