diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /toolkit/components/viaduct | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/viaduct')
-rw-r--r-- | toolkit/components/viaduct/Viaduct.cpp | 28 | ||||
-rw-r--r-- | toolkit/components/viaduct/Viaduct.h | 47 | ||||
-rw-r--r-- | toolkit/components/viaduct/ViaductRequest.cpp | 335 | ||||
-rw-r--r-- | toolkit/components/viaduct/ViaductRequest.h | 58 | ||||
-rw-r--r-- | toolkit/components/viaduct/fetch_msg_types.pb.cc | 1154 | ||||
-rw-r--r-- | toolkit/components/viaduct/fetch_msg_types.pb.h | 1296 | ||||
-rw-r--r-- | toolkit/components/viaduct/fetch_msg_types.proto | 42 | ||||
-rw-r--r-- | toolkit/components/viaduct/moz.build | 22 |
8 files changed, 2982 insertions, 0 deletions
diff --git a/toolkit/components/viaduct/Viaduct.cpp b/toolkit/components/viaduct/Viaduct.cpp new file mode 100644 index 0000000000..20111b4a44 --- /dev/null +++ b/toolkit/components/viaduct/Viaduct.cpp @@ -0,0 +1,28 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ + +#include "mozilla/Viaduct.h" + +#include "mozilla/ViaductRequest.h" + +namespace mozilla { + +namespace { + +extern "C" { +uint8_t viaduct_initialize( + ViaductByteBuffer (*fetch_callback)(ViaductByteBuffer)); +} + +static ViaductByteBuffer ViaductCallback(ViaductByteBuffer buffer) { + MOZ_ASSERT(!NS_IsMainThread(), "Background thread only!"); + RefPtr<ViaductRequest> request = new ViaductRequest(); + return request->MakeRequest(buffer); +} + +} // namespace + +void InitializeViaduct() { viaduct_initialize(ViaductCallback); } + +} // namespace mozilla diff --git a/toolkit/components/viaduct/Viaduct.h b/toolkit/components/viaduct/Viaduct.h new file mode 100644 index 0000000000..3fcf679219 --- /dev/null +++ b/toolkit/components/viaduct/Viaduct.h @@ -0,0 +1,47 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_Viaduct_h +#define mozilla_Viaduct_h + +/** + * Viaduct is a way for Application Services Rust components + * (https://github.com/mozilla/application-services) to make network requests + * using a trusted stack (gecko). + * + * The way it works is roughly as follows: + * - First we register a callback using `viaduct_initialize` + * (InitializeViaduct). This callback is stored on the Rust side + * in a static variable, therefore InitializeViaduct() must be called only once. + * + * - When the Rust code needs to make a network request, our callback + * (ViaductCallback) will be called with a protocol buffer describing + * the request to make on their behalf. Note 1: The callback MUST be called from + * a background thread as it is blocking. Note 2: It is our side responsibility + * to call `viaduct_destroy_bytebuffer` on the buffer. + * + * - We set a semaphore to make the background thread wait while we make the + * request on the main thread using nsIChannel. (ViaductRequest::MakeRequest) + * + * - Once a response is received, we allocate a bytebuffer to store the + * response using `viaduct_alloc_bytebuffer` and unlock the semaphore. + * (ViaductRequest::OnStopRequest) + * + * - The background thread is unlocked, and the callback returns the response to + * the Rust caller. (ViaductCallback) + * + * - The Rust caller will free the response buffer we allocated earlier. + * + * Reference: + * https://github.com/mozilla/application-services/blob/master/components/viaduct/README.md + */ + +namespace mozilla { + +// Should only be called once during startup to initialize the Viaduct callback. +void InitializeViaduct(); + +} // namespace mozilla + +#endif // mozilla_Viaduct_h diff --git a/toolkit/components/viaduct/ViaductRequest.cpp b/toolkit/components/viaduct/ViaductRequest.cpp new file mode 100644 index 0000000000..2e6c2369a5 --- /dev/null +++ b/toolkit/components/viaduct/ViaductRequest.cpp @@ -0,0 +1,335 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ + +#include "mozilla/ViaductRequest.h" + +#include "mozilla/ClearOnShutdown.h" +#include "mozilla/ErrorNames.h" +#include "mozilla/ResultExtensions.h" +#include "mozilla/ScopeExit.h" +#include "mozilla/Services.h" +#include "mozilla/Try.h" + +#include "nsComponentManagerUtils.h" +#include "nsContentUtils.h" +#include "nsIAsyncVerifyRedirectCallback.h" +#include "nsIHttpChannel.h" +#include "nsIHttpHeaderVisitor.h" +#include "nsIInputStream.h" +#include "nsIUploadChannel2.h" +#include "nsIURI.h" +#include "nsNetUtil.h" +#include "nsPrintfCString.h" +#include "nsString.h" +#include "nsStringStream.h" +#include "nsThreadUtils.h" + +namespace mozilla { + +namespace { + +extern "C" { +ViaductByteBuffer viaduct_alloc_bytebuffer(int32_t); +void viaduct_destroy_bytebuffer(ViaductByteBuffer); +} + +} // namespace + +class HeaderVisitor final : public nsIHttpHeaderVisitor { + public: + NS_DECL_ISUPPORTS + NS_DECL_NSIHTTPHEADERVISITOR + + explicit HeaderVisitor( + google::protobuf::Map<std::string, std::string>* aHeaders) + : mHeaders(aHeaders) {} + + private: + google::protobuf::Map<std::string, std::string>* mHeaders; + ~HeaderVisitor() = default; +}; + +NS_IMETHODIMP +HeaderVisitor::VisitHeader(const nsACString& aHeader, + const nsACString& aValue) { + (*mHeaders)[aHeader.BeginReading()] = aValue.BeginReading(); + return NS_OK; +} +NS_IMPL_ISUPPORTS(HeaderVisitor, nsIHttpHeaderVisitor) + +nsCString ConvertMethod( + appservices::httpconfig::protobuf::Request_Method method); + +/////////////////////////////////////////////////////////////////////////////// +// ViaductRequest implementation + +ViaductByteBuffer ViaductRequest::MakeRequest(ViaductByteBuffer reqBuf) { + MOZ_ASSERT(!NS_IsMainThread(), "Background thread only!"); + auto clearBuf = MakeScopeExit([&] { viaduct_destroy_bytebuffer(reqBuf); }); + // We keep the protobuf parsing/serializing in the background thread. + appservices::httpconfig::protobuf::Request request; + if (!request.ParseFromArray(static_cast<const void*>(reqBuf.data), + reqBuf.len)) { + // We still need to return something! + return ViaductByteBuffer{.len = 0, .data = nullptr}; + } + MonitorAutoLock lock(mMonitor); + NS_DispatchToMainThread(NS_NewRunnableFunction( + "ViaductRequest::LaunchRequest", [this, &request]() { + nsresult rv = LaunchRequest(request); + if (NS_WARN_IF(NS_FAILED(rv))) { + // Something went very very wrong, but we still have to unblock + // the calling thread. + NotifyMonitor(); + } + })); + while (!mDone) { + mMonitor.Wait(); + } + ViaductByteBuffer respBuf = + viaduct_alloc_bytebuffer(mResponse.ByteSizeLong()); + if (!mResponse.SerializeToArray(respBuf.data, respBuf.len)) { + viaduct_destroy_bytebuffer(respBuf); + return ViaductByteBuffer{.len = 0, .data = nullptr}; + } + return respBuf; +} + +nsresult ViaductRequest::LaunchRequest( + appservices::httpconfig::protobuf::Request& request) { + if (PastShutdownPhase(ShutdownPhase::AppShutdownNetTeardown)) { + return NS_ERROR_FAILURE; + } + nsCOMPtr<nsIURI> uri; + nsresult rv = NS_NewURI(getter_AddRefs(uri), request.url().c_str()); + NS_ENSURE_SUCCESS(rv, rv); + + nsSecurityFlags secFlags = + nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_SEC_CONTEXT_IS_NULL | + nsILoadInfo::SEC_COOKIES_OMIT; + uint32_t loadFlags = 0; + + if (!request.use_caches()) { + loadFlags |= nsIRequest::LOAD_BYPASS_CACHE; + } + + if (!request.follow_redirects()) { + secFlags |= nsILoadInfo::SEC_DONT_FOLLOW_REDIRECTS; + } + + rv = NS_NewChannel(getter_AddRefs(mChannel), uri, + nsContentUtils::GetSystemPrincipal(), secFlags, + nsIContentPolicy::TYPE_OTHER, + nullptr, // nsICookieJarSettings + nullptr, // aPerformanceStorage + nullptr, // aLoadGroup + nullptr, loadFlags); + NS_ENSURE_SUCCESS(rv, rv); + + nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(mChannel); + nsCString method = ConvertMethod(request.method()); + rv = httpChannel->SetRequestMethod(method); + NS_ENSURE_SUCCESS(rv, rv); + + for (auto& header : request.headers()) { + rv = httpChannel->SetRequestHeader( + nsDependentCString(header.first.c_str(), header.first.size()), + nsDependentCString(header.second.c_str(), header.second.size()), + false /* merge */); + NS_ENSURE_SUCCESS(rv, rv); + } + + // Body + if (request.has_body()) { + const std::string& body = request.body(); + nsCOMPtr<nsIStringInputStream> stream( + do_CreateInstance(NS_STRINGINPUTSTREAM_CONTRACTID)); + rv = stream->SetData(body.data(), body.size()); + NS_ENSURE_SUCCESS(rv, rv); + nsCOMPtr<nsIUploadChannel2> uploadChannel = do_QueryInterface(mChannel); + uploadChannel->ExplicitSetUploadStream(stream, VoidCString(), -1, method, + false /* aStreamHasHeaders */); + } + + MOZ_TRY_VAR( + mConnectTimeoutTimer, + NS_NewTimerWithCallback(this, request.connect_timeout_secs() * 1000, + nsITimer::TYPE_ONE_SHOT)); + MOZ_TRY_VAR(mReadTimeoutTimer, + NS_NewTimerWithCallback(this, request.read_timeout_secs() * 1000, + nsITimer::TYPE_ONE_SHOT)); + + rv = httpChannel->AsyncOpen(this); + NS_ENSURE_SUCCESS(rv, rv); + + return rv; +} + +nsCString ConvertMethod( + appservices::httpconfig::protobuf::Request_Method method) { + using appservices::httpconfig::protobuf::Request_Method; + switch (method) { + case Request_Method::Request_Method_GET: + return "GET"_ns; + case Request_Method::Request_Method_HEAD: + return "HEAD"_ns; + case Request_Method::Request_Method_POST: + return "POST"_ns; + case Request_Method::Request_Method_PUT: + return "PUT"_ns; + case Request_Method::Request_Method_DELETE: + return "DELETE"_ns; + case Request_Method::Request_Method_CONNECT: + return "CONNECT"_ns; + case Request_Method::Request_Method_OPTIONS: + return "OPTIONS"_ns; + case Request_Method::Request_Method_TRACE: + return "TRACE"_ns; + case Request_Method::Request_Method_PATCH: + return "PATCH"_ns; + } + return "UNKNOWN"_ns; +} + +void ViaductRequest::ClearTimers() { + if (mConnectTimeoutTimer) { + mConnectTimeoutTimer->Cancel(); + mConnectTimeoutTimer = nullptr; + } + if (mReadTimeoutTimer) { + mReadTimeoutTimer->Cancel(); + mReadTimeoutTimer = nullptr; + } +} + +void ViaductRequest::NotifyMonitor() { + MonitorAutoLock lock(mMonitor); + mDone = true; + mMonitor.Notify(); +} + +ViaductRequest::~ViaductRequest() { + ClearTimers(); + if (mChannel) { + mChannel->Cancel(NS_ERROR_ABORT); + mChannel = nullptr; + } + NotifyMonitor(); +} + +NS_IMPL_ISUPPORTS(ViaductRequest, nsIStreamListener, nsITimerCallback, nsINamed, + nsIChannelEventSink) + +/////////////////////////////////////////////////////////////////////////////// +// nsIStreamListener implementation + +NS_IMETHODIMP +ViaductRequest::OnStartRequest(nsIRequest* aRequest) { + if (mConnectTimeoutTimer) { + mConnectTimeoutTimer->Cancel(); + mConnectTimeoutTimer = nullptr; + } + return NS_OK; +} + +static nsresult AssignResponseToBuffer(nsIInputStream* aIn, void* aClosure, + const char* aFromRawSegment, + uint32_t aToOffset, uint32_t aCount, + uint32_t* aWriteCount) { + nsCString* buf = static_cast<nsCString*>(aClosure); + buf->Append(aFromRawSegment, aCount); + *aWriteCount = aCount; + return NS_OK; +} + +NS_IMETHODIMP +ViaductRequest::OnDataAvailable(nsIRequest* aRequest, + nsIInputStream* aInputStream, uint64_t aOffset, + uint32_t aCount) { + nsresult rv; + uint32_t readCount; + rv = aInputStream->ReadSegments(AssignResponseToBuffer, &mBodyBuffer, aCount, + &readCount); + NS_ENSURE_SUCCESS(rv, rv); + return NS_OK; +} + +NS_IMETHODIMP +ViaductRequest::OnStopRequest(nsIRequest* aRequest, nsresult aStatusCode) { + ClearTimers(); + auto defer = MakeScopeExit([&] { + mChannel = nullptr; + NotifyMonitor(); + }); + + if (NS_FAILED(aStatusCode)) { + nsCString errorName; + GetErrorName(aStatusCode, errorName); + nsPrintfCString msg("Request error: %s", errorName.get()); + mResponse.set_exception_message(msg.BeginReading()); + } else { + nsresult rv; + nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aRequest, &rv); + // Early return is OK because MakeScopeExit will call Notify() + // and unblock the original calling thread. + NS_ENSURE_SUCCESS(rv, rv); + + uint32_t httpStatus; + rv = httpChannel->GetResponseStatus(&httpStatus); + NS_ENSURE_SUCCESS(rv, rv); + mResponse.set_status(httpStatus); + + nsCOMPtr<nsIURI> uri; + httpChannel->GetURI(getter_AddRefs(uri)); + nsAutoCString uriStr; + uri->GetSpec(uriStr); + mResponse.set_url(uriStr.BeginReading()); + + auto* headers = mResponse.mutable_headers(); + nsCOMPtr<nsIHttpHeaderVisitor> visitor = new HeaderVisitor(headers); + rv = httpChannel->VisitResponseHeaders(visitor); + NS_ENSURE_SUCCESS(rv, rv); + + mResponse.set_body(mBodyBuffer.BeginReading(), mBodyBuffer.Length()); + } + + return NS_OK; +} + +/////////////////////////////////////////////////////////////////////////////// +// nsIChannelEventSink implementation + +NS_IMETHODIMP +ViaductRequest::AsyncOnChannelRedirect( + nsIChannel* aOldChannel, nsIChannel* aNewChannel, uint32_t flags, + nsIAsyncVerifyRedirectCallback* callback) { + mChannel = aNewChannel; + callback->OnRedirectVerifyCallback(NS_OK); + return NS_OK; +} + +/////////////////////////////////////////////////////////////////////////////// +// nsITimerCallback implementation + +NS_IMETHODIMP +ViaductRequest::Notify(nsITimer* timer) { + ClearTimers(); + // Cancelling the channel will trigger OnStopRequest. + if (mChannel) { + mChannel->Cancel(NS_ERROR_ABORT); + mChannel = nullptr; + } + return NS_OK; +} + +/////////////////////////////////////////////////////////////////////////////// +// nsINamed implementation + +NS_IMETHODIMP +ViaductRequest::GetName(nsACString& aName) { + aName.AssignLiteral("ViaductRequest"); + return NS_OK; +} + +}; // namespace mozilla diff --git a/toolkit/components/viaduct/ViaductRequest.h b/toolkit/components/viaduct/ViaductRequest.h new file mode 100644 index 0000000000..8e5963c236 --- /dev/null +++ b/toolkit/components/viaduct/ViaductRequest.h @@ -0,0 +1,58 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_ViaductRequest_h +#define mozilla_ViaductRequest_h + +#include "mozilla/Monitor.h" +#include "mozilla/fetch_msg_types.pb.h" +#include "mozilla/Viaduct.h" + +#include "nsCOMPtr.h" +#include "nsIChannel.h" +#include "nsIChannelEventSink.h" +#include "nsIStreamListener.h" +#include "nsITimer.h" + +namespace mozilla { + +// A mapping of the ByteBuffer repr(C) Rust struct. +struct ViaductByteBuffer { + int64_t len; + uint8_t* data; +}; + +class ViaductRequest final : public nsIStreamListener, + public nsITimerCallback, + public nsINamed, + public nsIChannelEventSink { + public: + NS_DECL_THREADSAFE_ISUPPORTS + NS_DECL_NSIREQUESTOBSERVER + NS_DECL_NSISTREAMLISTENER + NS_DECL_NSITIMERCALLBACK + NS_DECL_NSINAMED + NS_DECL_NSICHANNELEVENTSINK + + ViaductRequest() + : mDone(false), mChannel(nullptr), mMonitor("ViaductRequest") {} + ViaductByteBuffer MakeRequest(ViaductByteBuffer reqBuf); + + private: + nsresult LaunchRequest(appservices::httpconfig::protobuf::Request&); + void ClearTimers(); + void NotifyMonitor(); + bool mDone; + nsCOMPtr<nsIChannel> mChannel; + nsCString mBodyBuffer; + nsCOMPtr<nsITimer> mConnectTimeoutTimer; + nsCOMPtr<nsITimer> mReadTimeoutTimer; + appservices::httpconfig::protobuf::Response mResponse; + Monitor mMonitor MOZ_UNANNOTATED; + ~ViaductRequest(); +}; + +}; // namespace mozilla + +#endif // mozilla_ViaductRequest_h diff --git a/toolkit/components/viaduct/fetch_msg_types.pb.cc b/toolkit/components/viaduct/fetch_msg_types.pb.cc new file mode 100644 index 0000000000..0522b4e2db --- /dev/null +++ b/toolkit/components/viaduct/fetch_msg_types.pb.cc @@ -0,0 +1,1154 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: fetch_msg_types.proto + +#include "fetch_msg_types.pb.h" + +#include <algorithm> + +#include <google/protobuf/io/coded_stream.h> +#include <google/protobuf/extension_set.h> +#include <google/protobuf/wire_format_lite.h> +#include <google/protobuf/io/zero_copy_stream_impl_lite.h> +// @@protoc_insertion_point(includes) +#include <google/protobuf/port_def.inc> + +PROTOBUF_PRAGMA_INIT_SEG + +namespace _pb = ::PROTOBUF_NAMESPACE_ID; +namespace _pbi = _pb::internal; + +namespace mozilla { +namespace appservices { +namespace httpconfig { +namespace protobuf { +PROTOBUF_CONSTEXPR Request_HeadersEntry_DoNotUse::Request_HeadersEntry_DoNotUse( + ::_pbi::ConstantInitialized) {} +struct Request_HeadersEntry_DoNotUseDefaultTypeInternal { + PROTOBUF_CONSTEXPR Request_HeadersEntry_DoNotUseDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} + ~Request_HeadersEntry_DoNotUseDefaultTypeInternal() {} + union { + Request_HeadersEntry_DoNotUse _instance; + }; +}; +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 Request_HeadersEntry_DoNotUseDefaultTypeInternal _Request_HeadersEntry_DoNotUse_default_instance_; +PROTOBUF_CONSTEXPR Request::Request( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_._has_bits_)*/{} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_.headers_)*/{} + , /*decltype(_impl_.url_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.body_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.method_)*/0 + , /*decltype(_impl_.follow_redirects_)*/false + , /*decltype(_impl_.use_caches_)*/false + , /*decltype(_impl_.connect_timeout_secs_)*/0 + , /*decltype(_impl_.read_timeout_secs_)*/0} {} +struct RequestDefaultTypeInternal { + PROTOBUF_CONSTEXPR RequestDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} + ~RequestDefaultTypeInternal() {} + union { + Request _instance; + }; +}; +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 RequestDefaultTypeInternal _Request_default_instance_; +PROTOBUF_CONSTEXPR Response_HeadersEntry_DoNotUse::Response_HeadersEntry_DoNotUse( + ::_pbi::ConstantInitialized) {} +struct Response_HeadersEntry_DoNotUseDefaultTypeInternal { + PROTOBUF_CONSTEXPR Response_HeadersEntry_DoNotUseDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} + ~Response_HeadersEntry_DoNotUseDefaultTypeInternal() {} + union { + Response_HeadersEntry_DoNotUse _instance; + }; +}; +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 Response_HeadersEntry_DoNotUseDefaultTypeInternal _Response_HeadersEntry_DoNotUse_default_instance_; +PROTOBUF_CONSTEXPR Response::Response( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_._has_bits_)*/{} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_.headers_)*/{} + , /*decltype(_impl_.exception_message_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.url_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.body_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.status_)*/0} {} +struct ResponseDefaultTypeInternal { + PROTOBUF_CONSTEXPR ResponseDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} + ~ResponseDefaultTypeInternal() {} + union { + Response _instance; + }; +}; +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ResponseDefaultTypeInternal _Response_default_instance_; +} // namespace protobuf +} // namespace httpconfig +} // namespace appservices +} // namespace mozilla +namespace mozilla { +namespace appservices { +namespace httpconfig { +namespace protobuf { +bool Request_Method_IsValid(int value) { + switch (value) { + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + return true; + default: + return false; + } +} + +static ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<std::string> Request_Method_strings[9] = {}; + +static const char Request_Method_names[] = + "CONNECT" + "DELETE" + "GET" + "HEAD" + "OPTIONS" + "PATCH" + "POST" + "PUT" + "TRACE"; + +static const ::PROTOBUF_NAMESPACE_ID::internal::EnumEntry Request_Method_entries[] = { + { {Request_Method_names + 0, 7}, 5 }, + { {Request_Method_names + 7, 6}, 4 }, + { {Request_Method_names + 13, 3}, 0 }, + { {Request_Method_names + 16, 4}, 1 }, + { {Request_Method_names + 20, 7}, 6 }, + { {Request_Method_names + 27, 5}, 8 }, + { {Request_Method_names + 32, 4}, 2 }, + { {Request_Method_names + 36, 3}, 3 }, + { {Request_Method_names + 39, 5}, 7 }, +}; + +static const int Request_Method_entries_by_number[] = { + 2, // 0 -> GET + 3, // 1 -> HEAD + 6, // 2 -> POST + 7, // 3 -> PUT + 1, // 4 -> DELETE + 0, // 5 -> CONNECT + 4, // 6 -> OPTIONS + 8, // 7 -> TRACE + 5, // 8 -> PATCH +}; + +const std::string& Request_Method_Name( + Request_Method value) { + static const bool dummy = + ::PROTOBUF_NAMESPACE_ID::internal::InitializeEnumStrings( + Request_Method_entries, + Request_Method_entries_by_number, + 9, Request_Method_strings); + (void) dummy; + int idx = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumName( + Request_Method_entries, + Request_Method_entries_by_number, + 9, value); + return idx == -1 ? ::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString() : + Request_Method_strings[idx].get(); +} +bool Request_Method_Parse( + ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, Request_Method* value) { + int int_value; + bool success = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumValue( + Request_Method_entries, 9, name, &int_value); + if (success) { + *value = static_cast<Request_Method>(int_value); + } + return success; +} +#if (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) +constexpr Request_Method Request::GET; +constexpr Request_Method Request::HEAD; +constexpr Request_Method Request::POST; +constexpr Request_Method Request::PUT; +constexpr Request_Method Request::DELETE; +constexpr Request_Method Request::CONNECT; +constexpr Request_Method Request::OPTIONS; +constexpr Request_Method Request::TRACE; +constexpr Request_Method Request::PATCH; +constexpr Request_Method Request::Method_MIN; +constexpr Request_Method Request::Method_MAX; +constexpr int Request::Method_ARRAYSIZE; +#endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) + +// =================================================================== + +Request_HeadersEntry_DoNotUse::Request_HeadersEntry_DoNotUse() {} +Request_HeadersEntry_DoNotUse::Request_HeadersEntry_DoNotUse(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : SuperType(arena) {} +void Request_HeadersEntry_DoNotUse::MergeFrom(const Request_HeadersEntry_DoNotUse& other) { + MergeFromInternal(other); +} + +// =================================================================== + +class Request::_Internal { + public: + using HasBits = decltype(std::declval<Request>()._impl_._has_bits_); + static void set_has_method(HasBits* has_bits) { + (*has_bits)[0] |= 4u; + } + static void set_has_url(HasBits* has_bits) { + (*has_bits)[0] |= 1u; + } + static void set_has_body(HasBits* has_bits) { + (*has_bits)[0] |= 2u; + } + static void set_has_follow_redirects(HasBits* has_bits) { + (*has_bits)[0] |= 8u; + } + static void set_has_use_caches(HasBits* has_bits) { + (*has_bits)[0] |= 16u; + } + static void set_has_connect_timeout_secs(HasBits* has_bits) { + (*has_bits)[0] |= 32u; + } + static void set_has_read_timeout_secs(HasBits* has_bits) { + (*has_bits)[0] |= 64u; + } + static bool MissingRequiredFields(const HasBits& has_bits) { + return ((has_bits[0] & 0x0000007d) ^ 0x0000007d) != 0; + } +}; + +Request::Request(::PROTOBUF_NAMESPACE_ID::Arena* arena, + bool is_message_owned) + : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { + SharedCtor(arena, is_message_owned); + // @@protoc_insertion_point(arena_constructor:mozilla.appservices.httpconfig.protobuf.Request) +} +Request::Request(const Request& from) + : ::PROTOBUF_NAMESPACE_ID::MessageLite() { + Request* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){from._impl_._has_bits_} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_.headers_)*/{} + , decltype(_impl_.url_){} + , decltype(_impl_.body_){} + , decltype(_impl_.method_){} + , decltype(_impl_.follow_redirects_){} + , decltype(_impl_.use_caches_){} + , decltype(_impl_.connect_timeout_secs_){} + , decltype(_impl_.read_timeout_secs_){}}; + + _internal_metadata_.MergeFrom<std::string>(from._internal_metadata_); + _this->_impl_.headers_.MergeFrom(from._impl_.headers_); + _impl_.url_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.url_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (from._internal_has_url()) { + _this->_impl_.url_.Set(from._internal_url(), + _this->GetArenaForAllocation()); + } + _impl_.body_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.body_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (from._internal_has_body()) { + _this->_impl_.body_.Set(from._internal_body(), + _this->GetArenaForAllocation()); + } + ::memcpy(&_impl_.method_, &from._impl_.method_, + static_cast<size_t>(reinterpret_cast<char*>(&_impl_.read_timeout_secs_) - + reinterpret_cast<char*>(&_impl_.method_)) + sizeof(_impl_.read_timeout_secs_)); + // @@protoc_insertion_point(copy_constructor:mozilla.appservices.httpconfig.protobuf.Request) +} + +inline void Request::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_.headers_)*/{::_pbi::ArenaInitialized(), arena} + , decltype(_impl_.url_){} + , decltype(_impl_.body_){} + , decltype(_impl_.method_){0} + , decltype(_impl_.follow_redirects_){false} + , decltype(_impl_.use_caches_){false} + , decltype(_impl_.connect_timeout_secs_){0} + , decltype(_impl_.read_timeout_secs_){0} + }; + _impl_.url_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.url_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.body_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.body_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING +} + +Request::~Request() { + // @@protoc_insertion_point(destructor:mozilla.appservices.httpconfig.protobuf.Request) + if (auto *arena = _internal_metadata_.DeleteReturnArena<std::string>()) { + (void)arena; + return; + } + SharedDtor(); +} + +inline void Request::SharedDtor() { + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); + _impl_.headers_.Destruct(); + _impl_.headers_.~MapFieldLite(); + _impl_.url_.Destroy(); + _impl_.body_.Destroy(); +} + +void Request::SetCachedSize(int size) const { + _impl_._cached_size_.Set(size); +} + +void Request::Clear() { +// @@protoc_insertion_point(message_clear_start:mozilla.appservices.httpconfig.protobuf.Request) + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + _impl_.headers_.Clear(); + cached_has_bits = _impl_._has_bits_[0]; + if (cached_has_bits & 0x00000003u) { + if (cached_has_bits & 0x00000001u) { + _impl_.url_.ClearNonDefaultToEmpty(); + } + if (cached_has_bits & 0x00000002u) { + _impl_.body_.ClearNonDefaultToEmpty(); + } + } + if (cached_has_bits & 0x0000007cu) { + ::memset(&_impl_.method_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&_impl_.read_timeout_secs_) - + reinterpret_cast<char*>(&_impl_.method_)) + sizeof(_impl_.read_timeout_secs_)); + } + _impl_._has_bits_.Clear(); + _internal_metadata_.Clear<std::string>(); +} + +const char* Request::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + _Internal::HasBits has_bits{}; + while (!ctx->Done(&ptr)) { + uint32_t tag; + ptr = ::_pbi::ReadTag(ptr, &tag); + switch (tag >> 3) { + // required .mozilla.appservices.httpconfig.protobuf.Request.Method method = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 8)) { + uint64_t val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + if (PROTOBUF_PREDICT_TRUE(::mozilla::appservices::httpconfig::protobuf::Request_Method_IsValid(val))) { + _internal_set_method(static_cast<::mozilla::appservices::httpconfig::protobuf::Request_Method>(val)); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(1, val, mutable_unknown_fields()); + } + } else + goto handle_unusual; + continue; + // required string url = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) { + auto str = _internal_mutable_url(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // optional bytes body = 3; + case 3: + if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 26)) { + auto str = _internal_mutable_body(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // map<string, string> headers = 4; + case 4: + if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 34)) { + ptr -= 1; + do { + ptr += 1; + ptr = ctx->ParseMessage(&_impl_.headers_, ptr); + CHK_(ptr); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<34>(ptr)); + } else + goto handle_unusual; + continue; + // required bool follow_redirects = 5; + case 5: + if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 40)) { + _Internal::set_has_follow_redirects(&has_bits); + _impl_.follow_redirects_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // required bool use_caches = 6; + case 6: + if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 48)) { + _Internal::set_has_use_caches(&has_bits); + _impl_.use_caches_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // required int32 connect_timeout_secs = 7; + case 7: + if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 56)) { + _Internal::set_has_connect_timeout_secs(&has_bits); + _impl_.connect_timeout_secs_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // required int32 read_timeout_secs = 8; + case 8: + if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 64)) { + _Internal::set_has_read_timeout_secs(&has_bits); + _impl_.read_timeout_secs_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + default: + goto handle_unusual; + } // switch + handle_unusual: + if ((tag == 0) || ((tag & 7) == 4)) { + CHK_(ptr); + ctx->SetLastTag(tag); + goto message_done; + } + ptr = UnknownFieldParse( + tag, + _internal_metadata_.mutable_unknown_fields<std::string>(), + ptr, ctx); + CHK_(ptr != nullptr); + } // while +message_done: + _impl_._has_bits_.Or(has_bits); + return ptr; +failure: + ptr = nullptr; + goto message_done; +#undef CHK_ +} + +uint8_t* Request::_InternalSerialize( + uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:mozilla.appservices.httpconfig.protobuf.Request) + uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = _impl_._has_bits_[0]; + // required .mozilla.appservices.httpconfig.protobuf.Request.Method method = 1; + if (cached_has_bits & 0x00000004u) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteEnumToArray( + 1, this->_internal_method(), target); + } + + // required string url = 2; + if (cached_has_bits & 0x00000001u) { + target = stream->WriteStringMaybeAliased( + 2, this->_internal_url(), target); + } + + // optional bytes body = 3; + if (cached_has_bits & 0x00000002u) { + target = stream->WriteBytesMaybeAliased( + 3, this->_internal_body(), target); + } + + // map<string, string> headers = 4; + if (!this->_internal_headers().empty()) { + using MapType = ::_pb::Map<std::string, std::string>; + using WireHelper = Request_HeadersEntry_DoNotUse::Funcs; + const auto& map_field = this->_internal_headers(); + auto check_utf8 = [](const MapType::value_type& entry) { + (void)entry; + }; + + if (stream->IsSerializationDeterministic() && map_field.size() > 1) { + for (const auto& entry : ::_pbi::MapSorterPtr<MapType>(map_field)) { + target = WireHelper::InternalSerialize(4, entry.first, entry.second, target, stream); + check_utf8(entry); + } + } else { + for (const auto& entry : map_field) { + target = WireHelper::InternalSerialize(4, entry.first, entry.second, target, stream); + check_utf8(entry); + } + } + } + + // required bool follow_redirects = 5; + if (cached_has_bits & 0x00000008u) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteBoolToArray(5, this->_internal_follow_redirects(), target); + } + + // required bool use_caches = 6; + if (cached_has_bits & 0x00000010u) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteBoolToArray(6, this->_internal_use_caches(), target); + } + + // required int32 connect_timeout_secs = 7; + if (cached_has_bits & 0x00000020u) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteInt32ToArray(7, this->_internal_connect_timeout_secs(), target); + } + + // required int32 read_timeout_secs = 8; + if (cached_has_bits & 0x00000040u) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteInt32ToArray(8, this->_internal_read_timeout_secs(), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = stream->WriteRaw(_internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), + static_cast<int>(_internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); + } + // @@protoc_insertion_point(serialize_to_array_end:mozilla.appservices.httpconfig.protobuf.Request) + return target; +} + +size_t Request::RequiredFieldsByteSizeFallback() const { +// @@protoc_insertion_point(required_fields_byte_size_fallback_start:mozilla.appservices.httpconfig.protobuf.Request) + size_t total_size = 0; + + if (_internal_has_url()) { + // required string url = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_url()); + } + + if (_internal_has_method()) { + // required .mozilla.appservices.httpconfig.protobuf.Request.Method method = 1; + total_size += 1 + + ::_pbi::WireFormatLite::EnumSize(this->_internal_method()); + } + + if (_internal_has_follow_redirects()) { + // required bool follow_redirects = 5; + total_size += 1 + 1; + } + + if (_internal_has_use_caches()) { + // required bool use_caches = 6; + total_size += 1 + 1; + } + + if (_internal_has_connect_timeout_secs()) { + // required int32 connect_timeout_secs = 7; + total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_connect_timeout_secs()); + } + + if (_internal_has_read_timeout_secs()) { + // required int32 read_timeout_secs = 8; + total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_read_timeout_secs()); + } + + return total_size; +} +size_t Request::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:mozilla.appservices.httpconfig.protobuf.Request) + size_t total_size = 0; + + if (((_impl_._has_bits_[0] & 0x0000007d) ^ 0x0000007d) == 0) { // All required fields are present. + // required string url = 2; + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_url()); + + // required .mozilla.appservices.httpconfig.protobuf.Request.Method method = 1; + total_size += 1 + + ::_pbi::WireFormatLite::EnumSize(this->_internal_method()); + + // required bool follow_redirects = 5; + total_size += 1 + 1; + + // required bool use_caches = 6; + total_size += 1 + 1; + + // required int32 connect_timeout_secs = 7; + total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_connect_timeout_secs()); + + // required int32 read_timeout_secs = 8; + total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_read_timeout_secs()); + + } else { + total_size += RequiredFieldsByteSizeFallback(); + } + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // map<string, string> headers = 4; + total_size += 1 * + ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->_internal_headers_size()); + for (::PROTOBUF_NAMESPACE_ID::Map< std::string, std::string >::const_iterator + it = this->_internal_headers().begin(); + it != this->_internal_headers().end(); ++it) { + total_size += Request_HeadersEntry_DoNotUse::Funcs::ByteSizeLong(it->first, it->second); + } + + // optional bytes body = 3; + cached_has_bits = _impl_._has_bits_[0]; + if (cached_has_bits & 0x00000002u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_body()); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + total_size += _internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); + } + int cached_size = ::_pbi::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; +} + +void Request::CheckTypeAndMergeFrom( + const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { + MergeFrom(*::_pbi::DownCast<const Request*>( + &from)); +} + +void Request::MergeFrom(const Request& from) { + Request* const _this = this; + // @@protoc_insertion_point(class_specific_merge_from_start:mozilla.appservices.httpconfig.protobuf.Request) + GOOGLE_DCHECK_NE(&from, _this); + uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + _this->_impl_.headers_.MergeFrom(from._impl_.headers_); + cached_has_bits = from._impl_._has_bits_[0]; + if (cached_has_bits & 0x0000007fu) { + if (cached_has_bits & 0x00000001u) { + _this->_internal_set_url(from._internal_url()); + } + if (cached_has_bits & 0x00000002u) { + _this->_internal_set_body(from._internal_body()); + } + if (cached_has_bits & 0x00000004u) { + _this->_impl_.method_ = from._impl_.method_; + } + if (cached_has_bits & 0x00000008u) { + _this->_impl_.follow_redirects_ = from._impl_.follow_redirects_; + } + if (cached_has_bits & 0x00000010u) { + _this->_impl_.use_caches_ = from._impl_.use_caches_; + } + if (cached_has_bits & 0x00000020u) { + _this->_impl_.connect_timeout_secs_ = from._impl_.connect_timeout_secs_; + } + if (cached_has_bits & 0x00000040u) { + _this->_impl_.read_timeout_secs_ = from._impl_.read_timeout_secs_; + } + _this->_impl_._has_bits_[0] |= cached_has_bits; + } + _this->_internal_metadata_.MergeFrom<std::string>(from._internal_metadata_); +} + +void Request::CopyFrom(const Request& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:mozilla.appservices.httpconfig.protobuf.Request) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool Request::IsInitialized() const { + if (_Internal::MissingRequiredFields(_impl_._has_bits_)) return false; + return true; +} + +void Request::InternalSwap(Request* other) { + using std::swap; + auto* lhs_arena = GetArenaForAllocation(); + auto* rhs_arena = other->GetArenaForAllocation(); + _internal_metadata_.InternalSwap(&other->_internal_metadata_); + swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); + _impl_.headers_.InternalSwap(&other->_impl_.headers_); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.url_, lhs_arena, + &other->_impl_.url_, rhs_arena + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.body_, lhs_arena, + &other->_impl_.body_, rhs_arena + ); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(Request, _impl_.read_timeout_secs_) + + sizeof(Request::_impl_.read_timeout_secs_) + - PROTOBUF_FIELD_OFFSET(Request, _impl_.method_)>( + reinterpret_cast<char*>(&_impl_.method_), + reinterpret_cast<char*>(&other->_impl_.method_)); +} + +std::string Request::GetTypeName() const { + return "mozilla.appservices.httpconfig.protobuf.Request"; +} + + +// =================================================================== + +Response_HeadersEntry_DoNotUse::Response_HeadersEntry_DoNotUse() {} +Response_HeadersEntry_DoNotUse::Response_HeadersEntry_DoNotUse(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : SuperType(arena) {} +void Response_HeadersEntry_DoNotUse::MergeFrom(const Response_HeadersEntry_DoNotUse& other) { + MergeFromInternal(other); +} + +// =================================================================== + +class Response::_Internal { + public: + using HasBits = decltype(std::declval<Response>()._impl_._has_bits_); + static void set_has_exception_message(HasBits* has_bits) { + (*has_bits)[0] |= 1u; + } + static void set_has_url(HasBits* has_bits) { + (*has_bits)[0] |= 2u; + } + static void set_has_status(HasBits* has_bits) { + (*has_bits)[0] |= 8u; + } + static void set_has_body(HasBits* has_bits) { + (*has_bits)[0] |= 4u; + } +}; + +Response::Response(::PROTOBUF_NAMESPACE_ID::Arena* arena, + bool is_message_owned) + : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) { + SharedCtor(arena, is_message_owned); + // @@protoc_insertion_point(arena_constructor:mozilla.appservices.httpconfig.protobuf.Response) +} +Response::Response(const Response& from) + : ::PROTOBUF_NAMESPACE_ID::MessageLite() { + Response* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){from._impl_._has_bits_} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_.headers_)*/{} + , decltype(_impl_.exception_message_){} + , decltype(_impl_.url_){} + , decltype(_impl_.body_){} + , decltype(_impl_.status_){}}; + + _internal_metadata_.MergeFrom<std::string>(from._internal_metadata_); + _this->_impl_.headers_.MergeFrom(from._impl_.headers_); + _impl_.exception_message_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.exception_message_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (from._internal_has_exception_message()) { + _this->_impl_.exception_message_.Set(from._internal_exception_message(), + _this->GetArenaForAllocation()); + } + _impl_.url_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.url_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (from._internal_has_url()) { + _this->_impl_.url_.Set(from._internal_url(), + _this->GetArenaForAllocation()); + } + _impl_.body_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.body_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (from._internal_has_body()) { + _this->_impl_.body_.Set(from._internal_body(), + _this->GetArenaForAllocation()); + } + _this->_impl_.status_ = from._impl_.status_; + // @@protoc_insertion_point(copy_constructor:mozilla.appservices.httpconfig.protobuf.Response) +} + +inline void Response::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_._has_bits_){} + , /*decltype(_impl_._cached_size_)*/{} + , /*decltype(_impl_.headers_)*/{::_pbi::ArenaInitialized(), arena} + , decltype(_impl_.exception_message_){} + , decltype(_impl_.url_){} + , decltype(_impl_.body_){} + , decltype(_impl_.status_){0} + }; + _impl_.exception_message_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.exception_message_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.url_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.url_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.body_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.body_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING +} + +Response::~Response() { + // @@protoc_insertion_point(destructor:mozilla.appservices.httpconfig.protobuf.Response) + if (auto *arena = _internal_metadata_.DeleteReturnArena<std::string>()) { + (void)arena; + return; + } + SharedDtor(); +} + +inline void Response::SharedDtor() { + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); + _impl_.headers_.Destruct(); + _impl_.headers_.~MapFieldLite(); + _impl_.exception_message_.Destroy(); + _impl_.url_.Destroy(); + _impl_.body_.Destroy(); +} + +void Response::SetCachedSize(int size) const { + _impl_._cached_size_.Set(size); +} + +void Response::Clear() { +// @@protoc_insertion_point(message_clear_start:mozilla.appservices.httpconfig.protobuf.Response) + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + _impl_.headers_.Clear(); + cached_has_bits = _impl_._has_bits_[0]; + if (cached_has_bits & 0x00000007u) { + if (cached_has_bits & 0x00000001u) { + _impl_.exception_message_.ClearNonDefaultToEmpty(); + } + if (cached_has_bits & 0x00000002u) { + _impl_.url_.ClearNonDefaultToEmpty(); + } + if (cached_has_bits & 0x00000004u) { + _impl_.body_.ClearNonDefaultToEmpty(); + } + } + _impl_.status_ = 0; + _impl_._has_bits_.Clear(); + _internal_metadata_.Clear<std::string>(); +} + +const char* Response::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + _Internal::HasBits has_bits{}; + while (!ctx->Done(&ptr)) { + uint32_t tag; + ptr = ::_pbi::ReadTag(ptr, &tag); + switch (tag >> 3) { + // optional string exception_message = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) { + auto str = _internal_mutable_exception_message(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // optional string url = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) { + auto str = _internal_mutable_url(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // optional int32 status = 3; + case 3: + if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 24)) { + _Internal::set_has_status(&has_bits); + _impl_.status_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // optional bytes body = 4; + case 4: + if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 34)) { + auto str = _internal_mutable_body(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // map<string, string> headers = 5; + case 5: + if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 42)) { + ptr -= 1; + do { + ptr += 1; + ptr = ctx->ParseMessage(&_impl_.headers_, ptr); + CHK_(ptr); + if (!ctx->DataAvailable(ptr)) break; + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<42>(ptr)); + } else + goto handle_unusual; + continue; + default: + goto handle_unusual; + } // switch + handle_unusual: + if ((tag == 0) || ((tag & 7) == 4)) { + CHK_(ptr); + ctx->SetLastTag(tag); + goto message_done; + } + ptr = UnknownFieldParse( + tag, + _internal_metadata_.mutable_unknown_fields<std::string>(), + ptr, ctx); + CHK_(ptr != nullptr); + } // while +message_done: + _impl_._has_bits_.Or(has_bits); + return ptr; +failure: + ptr = nullptr; + goto message_done; +#undef CHK_ +} + +uint8_t* Response::_InternalSerialize( + uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:mozilla.appservices.httpconfig.protobuf.Response) + uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + cached_has_bits = _impl_._has_bits_[0]; + // optional string exception_message = 1; + if (cached_has_bits & 0x00000001u) { + target = stream->WriteStringMaybeAliased( + 1, this->_internal_exception_message(), target); + } + + // optional string url = 2; + if (cached_has_bits & 0x00000002u) { + target = stream->WriteStringMaybeAliased( + 2, this->_internal_url(), target); + } + + // optional int32 status = 3; + if (cached_has_bits & 0x00000008u) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteInt32ToArray(3, this->_internal_status(), target); + } + + // optional bytes body = 4; + if (cached_has_bits & 0x00000004u) { + target = stream->WriteBytesMaybeAliased( + 4, this->_internal_body(), target); + } + + // map<string, string> headers = 5; + if (!this->_internal_headers().empty()) { + using MapType = ::_pb::Map<std::string, std::string>; + using WireHelper = Response_HeadersEntry_DoNotUse::Funcs; + const auto& map_field = this->_internal_headers(); + auto check_utf8 = [](const MapType::value_type& entry) { + (void)entry; + }; + + if (stream->IsSerializationDeterministic() && map_field.size() > 1) { + for (const auto& entry : ::_pbi::MapSorterPtr<MapType>(map_field)) { + target = WireHelper::InternalSerialize(5, entry.first, entry.second, target, stream); + check_utf8(entry); + } + } else { + for (const auto& entry : map_field) { + target = WireHelper::InternalSerialize(5, entry.first, entry.second, target, stream); + check_utf8(entry); + } + } + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = stream->WriteRaw(_internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(), + static_cast<int>(_internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target); + } + // @@protoc_insertion_point(serialize_to_array_end:mozilla.appservices.httpconfig.protobuf.Response) + return target; +} + +size_t Response::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:mozilla.appservices.httpconfig.protobuf.Response) + size_t total_size = 0; + + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // map<string, string> headers = 5; + total_size += 1 * + ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->_internal_headers_size()); + for (::PROTOBUF_NAMESPACE_ID::Map< std::string, std::string >::const_iterator + it = this->_internal_headers().begin(); + it != this->_internal_headers().end(); ++it) { + total_size += Response_HeadersEntry_DoNotUse::Funcs::ByteSizeLong(it->first, it->second); + } + + cached_has_bits = _impl_._has_bits_[0]; + if (cached_has_bits & 0x0000000fu) { + // optional string exception_message = 1; + if (cached_has_bits & 0x00000001u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_exception_message()); + } + + // optional string url = 2; + if (cached_has_bits & 0x00000002u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_url()); + } + + // optional bytes body = 4; + if (cached_has_bits & 0x00000004u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( + this->_internal_body()); + } + + // optional int32 status = 3; + if (cached_has_bits & 0x00000008u) { + total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_status()); + } + + } + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + total_size += _internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size(); + } + int cached_size = ::_pbi::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; +} + +void Response::CheckTypeAndMergeFrom( + const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) { + MergeFrom(*::_pbi::DownCast<const Response*>( + &from)); +} + +void Response::MergeFrom(const Response& from) { + Response* const _this = this; + // @@protoc_insertion_point(class_specific_merge_from_start:mozilla.appservices.httpconfig.protobuf.Response) + GOOGLE_DCHECK_NE(&from, _this); + uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + _this->_impl_.headers_.MergeFrom(from._impl_.headers_); + cached_has_bits = from._impl_._has_bits_[0]; + if (cached_has_bits & 0x0000000fu) { + if (cached_has_bits & 0x00000001u) { + _this->_internal_set_exception_message(from._internal_exception_message()); + } + if (cached_has_bits & 0x00000002u) { + _this->_internal_set_url(from._internal_url()); + } + if (cached_has_bits & 0x00000004u) { + _this->_internal_set_body(from._internal_body()); + } + if (cached_has_bits & 0x00000008u) { + _this->_impl_.status_ = from._impl_.status_; + } + _this->_impl_._has_bits_[0] |= cached_has_bits; + } + _this->_internal_metadata_.MergeFrom<std::string>(from._internal_metadata_); +} + +void Response::CopyFrom(const Response& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:mozilla.appservices.httpconfig.protobuf.Response) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool Response::IsInitialized() const { + return true; +} + +void Response::InternalSwap(Response* other) { + using std::swap; + auto* lhs_arena = GetArenaForAllocation(); + auto* rhs_arena = other->GetArenaForAllocation(); + _internal_metadata_.InternalSwap(&other->_internal_metadata_); + swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); + _impl_.headers_.InternalSwap(&other->_impl_.headers_); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.exception_message_, lhs_arena, + &other->_impl_.exception_message_, rhs_arena + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.url_, lhs_arena, + &other->_impl_.url_, rhs_arena + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.body_, lhs_arena, + &other->_impl_.body_, rhs_arena + ); + swap(_impl_.status_, other->_impl_.status_); +} + +std::string Response::GetTypeName() const { + return "mozilla.appservices.httpconfig.protobuf.Response"; +} + + +// @@protoc_insertion_point(namespace_scope) +} // namespace protobuf +} // namespace httpconfig +} // namespace appservices +} // namespace mozilla +PROTOBUF_NAMESPACE_OPEN +template<> PROTOBUF_NOINLINE ::mozilla::appservices::httpconfig::protobuf::Request_HeadersEntry_DoNotUse* +Arena::CreateMaybeMessage< ::mozilla::appservices::httpconfig::protobuf::Request_HeadersEntry_DoNotUse >(Arena* arena) { + return Arena::CreateMessageInternal< ::mozilla::appservices::httpconfig::protobuf::Request_HeadersEntry_DoNotUse >(arena); +} +template<> PROTOBUF_NOINLINE ::mozilla::appservices::httpconfig::protobuf::Request* +Arena::CreateMaybeMessage< ::mozilla::appservices::httpconfig::protobuf::Request >(Arena* arena) { + return Arena::CreateMessageInternal< ::mozilla::appservices::httpconfig::protobuf::Request >(arena); +} +template<> PROTOBUF_NOINLINE ::mozilla::appservices::httpconfig::protobuf::Response_HeadersEntry_DoNotUse* +Arena::CreateMaybeMessage< ::mozilla::appservices::httpconfig::protobuf::Response_HeadersEntry_DoNotUse >(Arena* arena) { + return Arena::CreateMessageInternal< ::mozilla::appservices::httpconfig::protobuf::Response_HeadersEntry_DoNotUse >(arena); +} +template<> PROTOBUF_NOINLINE ::mozilla::appservices::httpconfig::protobuf::Response* +Arena::CreateMaybeMessage< ::mozilla::appservices::httpconfig::protobuf::Response >(Arena* arena) { + return Arena::CreateMessageInternal< ::mozilla::appservices::httpconfig::protobuf::Response >(arena); +} +PROTOBUF_NAMESPACE_CLOSE + +// @@protoc_insertion_point(global_scope) +#include <google/protobuf/port_undef.inc> diff --git a/toolkit/components/viaduct/fetch_msg_types.pb.h b/toolkit/components/viaduct/fetch_msg_types.pb.h new file mode 100644 index 0000000000..afd749888a --- /dev/null +++ b/toolkit/components/viaduct/fetch_msg_types.pb.h @@ -0,0 +1,1296 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: fetch_msg_types.proto + +#ifndef GOOGLE_PROTOBUF_INCLUDED_fetch_5fmsg_5ftypes_2eproto +#define GOOGLE_PROTOBUF_INCLUDED_fetch_5fmsg_5ftypes_2eproto + +#include <limits> +#include <string> + +#include <google/protobuf/port_def.inc> +#if PROTOBUF_VERSION < 3021000 +#error This file was generated by a newer version of protoc which is +#error incompatible with your Protocol Buffer headers. Please update +#error your headers. +#endif +#if 3021006 < PROTOBUF_MIN_PROTOC_VERSION +#error This file was generated by an older version of protoc which is +#error incompatible with your Protocol Buffer headers. Please +#error regenerate this file with a newer version of protoc. +#endif + +#include <google/protobuf/port_undef.inc> +#include <google/protobuf/io/coded_stream.h> +#include <google/protobuf/arena.h> +#include <google/protobuf/arenastring.h> +#include <google/protobuf/generated_message_util.h> +#include <google/protobuf/metadata_lite.h> +#include <google/protobuf/message_lite.h> +#include <google/protobuf/repeated_field.h> // IWYU pragma: export +#include <google/protobuf/extension_set.h> // IWYU pragma: export +#include <google/protobuf/map.h> // IWYU pragma: export +#include <google/protobuf/map_entry_lite.h> +#include <google/protobuf/map_field_lite.h> +#include <google/protobuf/generated_enum_util.h> +// @@protoc_insertion_point(includes) +#include <google/protobuf/port_def.inc> +#define PROTOBUF_INTERNAL_EXPORT_fetch_5fmsg_5ftypes_2eproto +PROTOBUF_NAMESPACE_OPEN +namespace internal { +class AnyMetadata; +} // namespace internal +PROTOBUF_NAMESPACE_CLOSE + +// Internal implementation detail -- do not use these members. +struct TableStruct_fetch_5fmsg_5ftypes_2eproto { + static const uint32_t offsets[]; +}; +namespace mozilla { +namespace appservices { +namespace httpconfig { +namespace protobuf { +class Request; +struct RequestDefaultTypeInternal; +extern RequestDefaultTypeInternal _Request_default_instance_; +class Request_HeadersEntry_DoNotUse; +struct Request_HeadersEntry_DoNotUseDefaultTypeInternal; +extern Request_HeadersEntry_DoNotUseDefaultTypeInternal _Request_HeadersEntry_DoNotUse_default_instance_; +class Response; +struct ResponseDefaultTypeInternal; +extern ResponseDefaultTypeInternal _Response_default_instance_; +class Response_HeadersEntry_DoNotUse; +struct Response_HeadersEntry_DoNotUseDefaultTypeInternal; +extern Response_HeadersEntry_DoNotUseDefaultTypeInternal _Response_HeadersEntry_DoNotUse_default_instance_; +} // namespace protobuf +} // namespace httpconfig +} // namespace appservices +} // namespace mozilla +PROTOBUF_NAMESPACE_OPEN +template<> ::mozilla::appservices::httpconfig::protobuf::Request* Arena::CreateMaybeMessage<::mozilla::appservices::httpconfig::protobuf::Request>(Arena*); +template<> ::mozilla::appservices::httpconfig::protobuf::Request_HeadersEntry_DoNotUse* Arena::CreateMaybeMessage<::mozilla::appservices::httpconfig::protobuf::Request_HeadersEntry_DoNotUse>(Arena*); +template<> ::mozilla::appservices::httpconfig::protobuf::Response* Arena::CreateMaybeMessage<::mozilla::appservices::httpconfig::protobuf::Response>(Arena*); +template<> ::mozilla::appservices::httpconfig::protobuf::Response_HeadersEntry_DoNotUse* Arena::CreateMaybeMessage<::mozilla::appservices::httpconfig::protobuf::Response_HeadersEntry_DoNotUse>(Arena*); +PROTOBUF_NAMESPACE_CLOSE +namespace mozilla { +namespace appservices { +namespace httpconfig { +namespace protobuf { + +enum Request_Method : int { + Request_Method_GET = 0, + Request_Method_HEAD = 1, + Request_Method_POST = 2, + Request_Method_PUT = 3, + Request_Method_DELETE = 4, + Request_Method_CONNECT = 5, + Request_Method_OPTIONS = 6, + Request_Method_TRACE = 7, + Request_Method_PATCH = 8 +}; +bool Request_Method_IsValid(int value); +constexpr Request_Method Request_Method_Method_MIN = Request_Method_GET; +constexpr Request_Method Request_Method_Method_MAX = Request_Method_PATCH; +constexpr int Request_Method_Method_ARRAYSIZE = Request_Method_Method_MAX + 1; + +const std::string& Request_Method_Name(Request_Method value); +template<typename T> +inline const std::string& Request_Method_Name(T enum_t_value) { + static_assert(::std::is_same<T, Request_Method>::value || + ::std::is_integral<T>::value, + "Incorrect type passed to function Request_Method_Name."); + return Request_Method_Name(static_cast<Request_Method>(enum_t_value)); +} +bool Request_Method_Parse( + ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, Request_Method* value); +// =================================================================== + +class Request_HeadersEntry_DoNotUse : public ::PROTOBUF_NAMESPACE_ID::internal::MapEntryLite<Request_HeadersEntry_DoNotUse, + std::string, std::string, + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_STRING, + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_STRING> { +public: + typedef ::PROTOBUF_NAMESPACE_ID::internal::MapEntryLite<Request_HeadersEntry_DoNotUse, + std::string, std::string, + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_STRING, + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_STRING> SuperType; + Request_HeadersEntry_DoNotUse(); + explicit PROTOBUF_CONSTEXPR Request_HeadersEntry_DoNotUse( + ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit Request_HeadersEntry_DoNotUse(::PROTOBUF_NAMESPACE_ID::Arena* arena); + void MergeFrom(const Request_HeadersEntry_DoNotUse& other); + static const Request_HeadersEntry_DoNotUse* internal_default_instance() { return reinterpret_cast<const Request_HeadersEntry_DoNotUse*>(&_Request_HeadersEntry_DoNotUse_default_instance_); } + static bool ValidateKey(void*) { return true; } + static bool ValidateValue(void*) { return true; } + friend struct ::TableStruct_fetch_5fmsg_5ftypes_2eproto; +}; + +// ------------------------------------------------------------------- + +class Request final : + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:mozilla.appservices.httpconfig.protobuf.Request) */ { + public: + inline Request() : Request(nullptr) {} + ~Request() override; + explicit PROTOBUF_CONSTEXPR Request(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + + Request(const Request& from); + Request(Request&& from) noexcept + : Request() { + *this = ::std::move(from); + } + + inline Request& operator=(const Request& from) { + CopyFrom(from); + return *this; + } + inline Request& operator=(Request&& from) noexcept { + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetOwningArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const std::string& unknown_fields() const { + return _internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); + } + inline std::string* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<std::string>(); + } + + static const Request& default_instance() { + return *internal_default_instance(); + } + static inline const Request* internal_default_instance() { + return reinterpret_cast<const Request*>( + &_Request_default_instance_); + } + static constexpr int kIndexInFileMessages = + 1; + + friend void swap(Request& a, Request& b) { + a.Swap(&b); + } + inline void Swap(Request* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() == other->GetOwningArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(Request* other) { + if (other == this) return; + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + Request* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage<Request>(arena); + } + void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; + void CopyFrom(const Request& from); + void MergeFrom(const Request& from); + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + uint8_t* _InternalSerialize( + uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } + + private: + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); + void SharedDtor(); + void SetCachedSize(int size) const; + void InternalSwap(Request* other); + + private: + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "mozilla.appservices.httpconfig.protobuf.Request"; + } + protected: + explicit Request(::PROTOBUF_NAMESPACE_ID::Arena* arena, + bool is_message_owned = false); + public: + + std::string GetTypeName() const final; + + // nested types ---------------------------------------------------- + + + typedef Request_Method Method; + static constexpr Method GET = + Request_Method_GET; + static constexpr Method HEAD = + Request_Method_HEAD; + static constexpr Method POST = + Request_Method_POST; + static constexpr Method PUT = + Request_Method_PUT; + static constexpr Method DELETE = + Request_Method_DELETE; + static constexpr Method CONNECT = + Request_Method_CONNECT; + static constexpr Method OPTIONS = + Request_Method_OPTIONS; + static constexpr Method TRACE = + Request_Method_TRACE; + static constexpr Method PATCH = + Request_Method_PATCH; + static inline bool Method_IsValid(int value) { + return Request_Method_IsValid(value); + } + static constexpr Method Method_MIN = + Request_Method_Method_MIN; + static constexpr Method Method_MAX = + Request_Method_Method_MAX; + static constexpr int Method_ARRAYSIZE = + Request_Method_Method_ARRAYSIZE; + template<typename T> + static inline const std::string& Method_Name(T enum_t_value) { + static_assert(::std::is_same<T, Method>::value || + ::std::is_integral<T>::value, + "Incorrect type passed to function Method_Name."); + return Request_Method_Name(enum_t_value); + } + static inline bool Method_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name, + Method* value) { + return Request_Method_Parse(name, value); + } + + // accessors ------------------------------------------------------- + + enum : int { + kHeadersFieldNumber = 4, + kUrlFieldNumber = 2, + kBodyFieldNumber = 3, + kMethodFieldNumber = 1, + kFollowRedirectsFieldNumber = 5, + kUseCachesFieldNumber = 6, + kConnectTimeoutSecsFieldNumber = 7, + kReadTimeoutSecsFieldNumber = 8, + }; + // map<string, string> headers = 4; + int headers_size() const; + private: + int _internal_headers_size() const; + public: + void clear_headers(); + private: + const ::PROTOBUF_NAMESPACE_ID::Map< std::string, std::string >& + _internal_headers() const; + ::PROTOBUF_NAMESPACE_ID::Map< std::string, std::string >* + _internal_mutable_headers(); + public: + const ::PROTOBUF_NAMESPACE_ID::Map< std::string, std::string >& + headers() const; + ::PROTOBUF_NAMESPACE_ID::Map< std::string, std::string >* + mutable_headers(); + + // required string url = 2; + bool has_url() const; + private: + bool _internal_has_url() const; + public: + void clear_url(); + const std::string& url() const; + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_url(ArgT0&& arg0, ArgT... args); + std::string* mutable_url(); + PROTOBUF_NODISCARD std::string* release_url(); + void set_allocated_url(std::string* url); + private: + const std::string& _internal_url() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_url(const std::string& value); + std::string* _internal_mutable_url(); + public: + + // optional bytes body = 3; + bool has_body() const; + private: + bool _internal_has_body() const; + public: + void clear_body(); + const std::string& body() const; + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_body(ArgT0&& arg0, ArgT... args); + std::string* mutable_body(); + PROTOBUF_NODISCARD std::string* release_body(); + void set_allocated_body(std::string* body); + private: + const std::string& _internal_body() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_body(const std::string& value); + std::string* _internal_mutable_body(); + public: + + // required .mozilla.appservices.httpconfig.protobuf.Request.Method method = 1; + bool has_method() const; + private: + bool _internal_has_method() const; + public: + void clear_method(); + ::mozilla::appservices::httpconfig::protobuf::Request_Method method() const; + void set_method(::mozilla::appservices::httpconfig::protobuf::Request_Method value); + private: + ::mozilla::appservices::httpconfig::protobuf::Request_Method _internal_method() const; + void _internal_set_method(::mozilla::appservices::httpconfig::protobuf::Request_Method value); + public: + + // required bool follow_redirects = 5; + bool has_follow_redirects() const; + private: + bool _internal_has_follow_redirects() const; + public: + void clear_follow_redirects(); + bool follow_redirects() const; + void set_follow_redirects(bool value); + private: + bool _internal_follow_redirects() const; + void _internal_set_follow_redirects(bool value); + public: + + // required bool use_caches = 6; + bool has_use_caches() const; + private: + bool _internal_has_use_caches() const; + public: + void clear_use_caches(); + bool use_caches() const; + void set_use_caches(bool value); + private: + bool _internal_use_caches() const; + void _internal_set_use_caches(bool value); + public: + + // required int32 connect_timeout_secs = 7; + bool has_connect_timeout_secs() const; + private: + bool _internal_has_connect_timeout_secs() const; + public: + void clear_connect_timeout_secs(); + int32_t connect_timeout_secs() const; + void set_connect_timeout_secs(int32_t value); + private: + int32_t _internal_connect_timeout_secs() const; + void _internal_set_connect_timeout_secs(int32_t value); + public: + + // required int32 read_timeout_secs = 8; + bool has_read_timeout_secs() const; + private: + bool _internal_has_read_timeout_secs() const; + public: + void clear_read_timeout_secs(); + int32_t read_timeout_secs() const; + void set_read_timeout_secs(int32_t value); + private: + int32_t _internal_read_timeout_secs() const; + void _internal_set_read_timeout_secs(int32_t value); + public: + + // @@protoc_insertion_point(class_scope:mozilla.appservices.httpconfig.protobuf.Request) + private: + class _Internal; + + // helper for ByteSizeLong() + size_t RequiredFieldsByteSizeFallback() const; + + template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::internal::MapFieldLite< + Request_HeadersEntry_DoNotUse, + std::string, std::string, + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_STRING, + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_STRING> headers_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr url_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr body_; + int method_; + bool follow_redirects_; + bool use_caches_; + int32_t connect_timeout_secs_; + int32_t read_timeout_secs_; + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_fetch_5fmsg_5ftypes_2eproto; +}; +// ------------------------------------------------------------------- + +class Response_HeadersEntry_DoNotUse : public ::PROTOBUF_NAMESPACE_ID::internal::MapEntryLite<Response_HeadersEntry_DoNotUse, + std::string, std::string, + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_STRING, + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_STRING> { +public: + typedef ::PROTOBUF_NAMESPACE_ID::internal::MapEntryLite<Response_HeadersEntry_DoNotUse, + std::string, std::string, + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_STRING, + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_STRING> SuperType; + Response_HeadersEntry_DoNotUse(); + explicit PROTOBUF_CONSTEXPR Response_HeadersEntry_DoNotUse( + ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + explicit Response_HeadersEntry_DoNotUse(::PROTOBUF_NAMESPACE_ID::Arena* arena); + void MergeFrom(const Response_HeadersEntry_DoNotUse& other); + static const Response_HeadersEntry_DoNotUse* internal_default_instance() { return reinterpret_cast<const Response_HeadersEntry_DoNotUse*>(&_Response_HeadersEntry_DoNotUse_default_instance_); } + static bool ValidateKey(void*) { return true; } + static bool ValidateValue(void*) { return true; } + friend struct ::TableStruct_fetch_5fmsg_5ftypes_2eproto; +}; + +// ------------------------------------------------------------------- + +class Response final : + public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:mozilla.appservices.httpconfig.protobuf.Response) */ { + public: + inline Response() : Response(nullptr) {} + ~Response() override; + explicit PROTOBUF_CONSTEXPR Response(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + + Response(const Response& from); + Response(Response&& from) noexcept + : Response() { + *this = ::std::move(from); + } + + inline Response& operator=(const Response& from) { + CopyFrom(from); + return *this; + } + inline Response& operator=(Response&& from) noexcept { + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetOwningArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + inline const std::string& unknown_fields() const { + return _internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString); + } + inline std::string* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields<std::string>(); + } + + static const Response& default_instance() { + return *internal_default_instance(); + } + static inline const Response* internal_default_instance() { + return reinterpret_cast<const Response*>( + &_Response_default_instance_); + } + static constexpr int kIndexInFileMessages = + 3; + + friend void swap(Response& a, Response& b) { + a.Swap(&b); + } + inline void Swap(Response* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() == other->GetOwningArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(Response* other) { + if (other == this) return; + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + Response* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage<Response>(arena); + } + void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final; + void CopyFrom(const Response& from); + void MergeFrom(const Response& from); + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + uint8_t* _InternalSerialize( + uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } + + private: + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); + void SharedDtor(); + void SetCachedSize(int size) const; + void InternalSwap(Response* other); + + private: + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "mozilla.appservices.httpconfig.protobuf.Response"; + } + protected: + explicit Response(::PROTOBUF_NAMESPACE_ID::Arena* arena, + bool is_message_owned = false); + public: + + std::string GetTypeName() const final; + + // nested types ---------------------------------------------------- + + + // accessors ------------------------------------------------------- + + enum : int { + kHeadersFieldNumber = 5, + kExceptionMessageFieldNumber = 1, + kUrlFieldNumber = 2, + kBodyFieldNumber = 4, + kStatusFieldNumber = 3, + }; + // map<string, string> headers = 5; + int headers_size() const; + private: + int _internal_headers_size() const; + public: + void clear_headers(); + private: + const ::PROTOBUF_NAMESPACE_ID::Map< std::string, std::string >& + _internal_headers() const; + ::PROTOBUF_NAMESPACE_ID::Map< std::string, std::string >* + _internal_mutable_headers(); + public: + const ::PROTOBUF_NAMESPACE_ID::Map< std::string, std::string >& + headers() const; + ::PROTOBUF_NAMESPACE_ID::Map< std::string, std::string >* + mutable_headers(); + + // optional string exception_message = 1; + bool has_exception_message() const; + private: + bool _internal_has_exception_message() const; + public: + void clear_exception_message(); + const std::string& exception_message() const; + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_exception_message(ArgT0&& arg0, ArgT... args); + std::string* mutable_exception_message(); + PROTOBUF_NODISCARD std::string* release_exception_message(); + void set_allocated_exception_message(std::string* exception_message); + private: + const std::string& _internal_exception_message() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_exception_message(const std::string& value); + std::string* _internal_mutable_exception_message(); + public: + + // optional string url = 2; + bool has_url() const; + private: + bool _internal_has_url() const; + public: + void clear_url(); + const std::string& url() const; + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_url(ArgT0&& arg0, ArgT... args); + std::string* mutable_url(); + PROTOBUF_NODISCARD std::string* release_url(); + void set_allocated_url(std::string* url); + private: + const std::string& _internal_url() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_url(const std::string& value); + std::string* _internal_mutable_url(); + public: + + // optional bytes body = 4; + bool has_body() const; + private: + bool _internal_has_body() const; + public: + void clear_body(); + const std::string& body() const; + template <typename ArgT0 = const std::string&, typename... ArgT> + void set_body(ArgT0&& arg0, ArgT... args); + std::string* mutable_body(); + PROTOBUF_NODISCARD std::string* release_body(); + void set_allocated_body(std::string* body); + private: + const std::string& _internal_body() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_body(const std::string& value); + std::string* _internal_mutable_body(); + public: + + // optional int32 status = 3; + bool has_status() const; + private: + bool _internal_has_status() const; + public: + void clear_status(); + int32_t status() const; + void set_status(int32_t value); + private: + int32_t _internal_status() const; + void _internal_set_status(int32_t value); + public: + + // @@protoc_insertion_point(class_scope:mozilla.appservices.httpconfig.protobuf.Response) + private: + class _Internal; + + template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + ::PROTOBUF_NAMESPACE_ID::internal::MapFieldLite< + Response_HeadersEntry_DoNotUse, + std::string, std::string, + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_STRING, + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_STRING> headers_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr exception_message_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr url_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr body_; + int32_t status_; + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_fetch_5fmsg_5ftypes_2eproto; +}; +// =================================================================== + + +// =================================================================== + +#ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // __GNUC__ +// ------------------------------------------------------------------- + +// Request + +// required .mozilla.appservices.httpconfig.protobuf.Request.Method method = 1; +inline bool Request::_internal_has_method() const { + bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; + return value; +} +inline bool Request::has_method() const { + return _internal_has_method(); +} +inline void Request::clear_method() { + _impl_.method_ = 0; + _impl_._has_bits_[0] &= ~0x00000004u; +} +inline ::mozilla::appservices::httpconfig::protobuf::Request_Method Request::_internal_method() const { + return static_cast< ::mozilla::appservices::httpconfig::protobuf::Request_Method >(_impl_.method_); +} +inline ::mozilla::appservices::httpconfig::protobuf::Request_Method Request::method() const { + // @@protoc_insertion_point(field_get:mozilla.appservices.httpconfig.protobuf.Request.method) + return _internal_method(); +} +inline void Request::_internal_set_method(::mozilla::appservices::httpconfig::protobuf::Request_Method value) { + assert(::mozilla::appservices::httpconfig::protobuf::Request_Method_IsValid(value)); + _impl_._has_bits_[0] |= 0x00000004u; + _impl_.method_ = value; +} +inline void Request::set_method(::mozilla::appservices::httpconfig::protobuf::Request_Method value) { + _internal_set_method(value); + // @@protoc_insertion_point(field_set:mozilla.appservices.httpconfig.protobuf.Request.method) +} + +// required string url = 2; +inline bool Request::_internal_has_url() const { + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; + return value; +} +inline bool Request::has_url() const { + return _internal_has_url(); +} +inline void Request::clear_url() { + _impl_.url_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000001u; +} +inline const std::string& Request::url() const { + // @@protoc_insertion_point(field_get:mozilla.appservices.httpconfig.protobuf.Request.url) + return _internal_url(); +} +template <typename ArgT0, typename... ArgT> +inline PROTOBUF_ALWAYS_INLINE +void Request::set_url(ArgT0&& arg0, ArgT... args) { + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.url_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:mozilla.appservices.httpconfig.protobuf.Request.url) +} +inline std::string* Request::mutable_url() { + std::string* _s = _internal_mutable_url(); + // @@protoc_insertion_point(field_mutable:mozilla.appservices.httpconfig.protobuf.Request.url) + return _s; +} +inline const std::string& Request::_internal_url() const { + return _impl_.url_.Get(); +} +inline void Request::_internal_set_url(const std::string& value) { + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.url_.Set(value, GetArenaForAllocation()); +} +inline std::string* Request::_internal_mutable_url() { + _impl_._has_bits_[0] |= 0x00000001u; + return _impl_.url_.Mutable(GetArenaForAllocation()); +} +inline std::string* Request::release_url() { + // @@protoc_insertion_point(field_release:mozilla.appservices.httpconfig.protobuf.Request.url) + if (!_internal_has_url()) { + return nullptr; + } + _impl_._has_bits_[0] &= ~0x00000001u; + auto* p = _impl_.url_.Release(); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.url_.IsDefault()) { + _impl_.url_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + return p; +} +inline void Request::set_allocated_url(std::string* url) { + if (url != nullptr) { + _impl_._has_bits_[0] |= 0x00000001u; + } else { + _impl_._has_bits_[0] &= ~0x00000001u; + } + _impl_.url_.SetAllocated(url, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.url_.IsDefault()) { + _impl_.url_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:mozilla.appservices.httpconfig.protobuf.Request.url) +} + +// optional bytes body = 3; +inline bool Request::_internal_has_body() const { + bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; + return value; +} +inline bool Request::has_body() const { + return _internal_has_body(); +} +inline void Request::clear_body() { + _impl_.body_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000002u; +} +inline const std::string& Request::body() const { + // @@protoc_insertion_point(field_get:mozilla.appservices.httpconfig.protobuf.Request.body) + return _internal_body(); +} +template <typename ArgT0, typename... ArgT> +inline PROTOBUF_ALWAYS_INLINE +void Request::set_body(ArgT0&& arg0, ArgT... args) { + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.body_.SetBytes(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:mozilla.appservices.httpconfig.protobuf.Request.body) +} +inline std::string* Request::mutable_body() { + std::string* _s = _internal_mutable_body(); + // @@protoc_insertion_point(field_mutable:mozilla.appservices.httpconfig.protobuf.Request.body) + return _s; +} +inline const std::string& Request::_internal_body() const { + return _impl_.body_.Get(); +} +inline void Request::_internal_set_body(const std::string& value) { + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.body_.Set(value, GetArenaForAllocation()); +} +inline std::string* Request::_internal_mutable_body() { + _impl_._has_bits_[0] |= 0x00000002u; + return _impl_.body_.Mutable(GetArenaForAllocation()); +} +inline std::string* Request::release_body() { + // @@protoc_insertion_point(field_release:mozilla.appservices.httpconfig.protobuf.Request.body) + if (!_internal_has_body()) { + return nullptr; + } + _impl_._has_bits_[0] &= ~0x00000002u; + auto* p = _impl_.body_.Release(); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.body_.IsDefault()) { + _impl_.body_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + return p; +} +inline void Request::set_allocated_body(std::string* body) { + if (body != nullptr) { + _impl_._has_bits_[0] |= 0x00000002u; + } else { + _impl_._has_bits_[0] &= ~0x00000002u; + } + _impl_.body_.SetAllocated(body, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.body_.IsDefault()) { + _impl_.body_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:mozilla.appservices.httpconfig.protobuf.Request.body) +} + +// map<string, string> headers = 4; +inline int Request::_internal_headers_size() const { + return _impl_.headers_.size(); +} +inline int Request::headers_size() const { + return _internal_headers_size(); +} +inline void Request::clear_headers() { + _impl_.headers_.Clear(); +} +inline const ::PROTOBUF_NAMESPACE_ID::Map< std::string, std::string >& +Request::_internal_headers() const { + return _impl_.headers_.GetMap(); +} +inline const ::PROTOBUF_NAMESPACE_ID::Map< std::string, std::string >& +Request::headers() const { + // @@protoc_insertion_point(field_map:mozilla.appservices.httpconfig.protobuf.Request.headers) + return _internal_headers(); +} +inline ::PROTOBUF_NAMESPACE_ID::Map< std::string, std::string >* +Request::_internal_mutable_headers() { + return _impl_.headers_.MutableMap(); +} +inline ::PROTOBUF_NAMESPACE_ID::Map< std::string, std::string >* +Request::mutable_headers() { + // @@protoc_insertion_point(field_mutable_map:mozilla.appservices.httpconfig.protobuf.Request.headers) + return _internal_mutable_headers(); +} + +// required bool follow_redirects = 5; +inline bool Request::_internal_has_follow_redirects() const { + bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0; + return value; +} +inline bool Request::has_follow_redirects() const { + return _internal_has_follow_redirects(); +} +inline void Request::clear_follow_redirects() { + _impl_.follow_redirects_ = false; + _impl_._has_bits_[0] &= ~0x00000008u; +} +inline bool Request::_internal_follow_redirects() const { + return _impl_.follow_redirects_; +} +inline bool Request::follow_redirects() const { + // @@protoc_insertion_point(field_get:mozilla.appservices.httpconfig.protobuf.Request.follow_redirects) + return _internal_follow_redirects(); +} +inline void Request::_internal_set_follow_redirects(bool value) { + _impl_._has_bits_[0] |= 0x00000008u; + _impl_.follow_redirects_ = value; +} +inline void Request::set_follow_redirects(bool value) { + _internal_set_follow_redirects(value); + // @@protoc_insertion_point(field_set:mozilla.appservices.httpconfig.protobuf.Request.follow_redirects) +} + +// required bool use_caches = 6; +inline bool Request::_internal_has_use_caches() const { + bool value = (_impl_._has_bits_[0] & 0x00000010u) != 0; + return value; +} +inline bool Request::has_use_caches() const { + return _internal_has_use_caches(); +} +inline void Request::clear_use_caches() { + _impl_.use_caches_ = false; + _impl_._has_bits_[0] &= ~0x00000010u; +} +inline bool Request::_internal_use_caches() const { + return _impl_.use_caches_; +} +inline bool Request::use_caches() const { + // @@protoc_insertion_point(field_get:mozilla.appservices.httpconfig.protobuf.Request.use_caches) + return _internal_use_caches(); +} +inline void Request::_internal_set_use_caches(bool value) { + _impl_._has_bits_[0] |= 0x00000010u; + _impl_.use_caches_ = value; +} +inline void Request::set_use_caches(bool value) { + _internal_set_use_caches(value); + // @@protoc_insertion_point(field_set:mozilla.appservices.httpconfig.protobuf.Request.use_caches) +} + +// required int32 connect_timeout_secs = 7; +inline bool Request::_internal_has_connect_timeout_secs() const { + bool value = (_impl_._has_bits_[0] & 0x00000020u) != 0; + return value; +} +inline bool Request::has_connect_timeout_secs() const { + return _internal_has_connect_timeout_secs(); +} +inline void Request::clear_connect_timeout_secs() { + _impl_.connect_timeout_secs_ = 0; + _impl_._has_bits_[0] &= ~0x00000020u; +} +inline int32_t Request::_internal_connect_timeout_secs() const { + return _impl_.connect_timeout_secs_; +} +inline int32_t Request::connect_timeout_secs() const { + // @@protoc_insertion_point(field_get:mozilla.appservices.httpconfig.protobuf.Request.connect_timeout_secs) + return _internal_connect_timeout_secs(); +} +inline void Request::_internal_set_connect_timeout_secs(int32_t value) { + _impl_._has_bits_[0] |= 0x00000020u; + _impl_.connect_timeout_secs_ = value; +} +inline void Request::set_connect_timeout_secs(int32_t value) { + _internal_set_connect_timeout_secs(value); + // @@protoc_insertion_point(field_set:mozilla.appservices.httpconfig.protobuf.Request.connect_timeout_secs) +} + +// required int32 read_timeout_secs = 8; +inline bool Request::_internal_has_read_timeout_secs() const { + bool value = (_impl_._has_bits_[0] & 0x00000040u) != 0; + return value; +} +inline bool Request::has_read_timeout_secs() const { + return _internal_has_read_timeout_secs(); +} +inline void Request::clear_read_timeout_secs() { + _impl_.read_timeout_secs_ = 0; + _impl_._has_bits_[0] &= ~0x00000040u; +} +inline int32_t Request::_internal_read_timeout_secs() const { + return _impl_.read_timeout_secs_; +} +inline int32_t Request::read_timeout_secs() const { + // @@protoc_insertion_point(field_get:mozilla.appservices.httpconfig.protobuf.Request.read_timeout_secs) + return _internal_read_timeout_secs(); +} +inline void Request::_internal_set_read_timeout_secs(int32_t value) { + _impl_._has_bits_[0] |= 0x00000040u; + _impl_.read_timeout_secs_ = value; +} +inline void Request::set_read_timeout_secs(int32_t value) { + _internal_set_read_timeout_secs(value); + // @@protoc_insertion_point(field_set:mozilla.appservices.httpconfig.protobuf.Request.read_timeout_secs) +} + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// Response + +// optional string exception_message = 1; +inline bool Response::_internal_has_exception_message() const { + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; + return value; +} +inline bool Response::has_exception_message() const { + return _internal_has_exception_message(); +} +inline void Response::clear_exception_message() { + _impl_.exception_message_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000001u; +} +inline const std::string& Response::exception_message() const { + // @@protoc_insertion_point(field_get:mozilla.appservices.httpconfig.protobuf.Response.exception_message) + return _internal_exception_message(); +} +template <typename ArgT0, typename... ArgT> +inline PROTOBUF_ALWAYS_INLINE +void Response::set_exception_message(ArgT0&& arg0, ArgT... args) { + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.exception_message_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:mozilla.appservices.httpconfig.protobuf.Response.exception_message) +} +inline std::string* Response::mutable_exception_message() { + std::string* _s = _internal_mutable_exception_message(); + // @@protoc_insertion_point(field_mutable:mozilla.appservices.httpconfig.protobuf.Response.exception_message) + return _s; +} +inline const std::string& Response::_internal_exception_message() const { + return _impl_.exception_message_.Get(); +} +inline void Response::_internal_set_exception_message(const std::string& value) { + _impl_._has_bits_[0] |= 0x00000001u; + _impl_.exception_message_.Set(value, GetArenaForAllocation()); +} +inline std::string* Response::_internal_mutable_exception_message() { + _impl_._has_bits_[0] |= 0x00000001u; + return _impl_.exception_message_.Mutable(GetArenaForAllocation()); +} +inline std::string* Response::release_exception_message() { + // @@protoc_insertion_point(field_release:mozilla.appservices.httpconfig.protobuf.Response.exception_message) + if (!_internal_has_exception_message()) { + return nullptr; + } + _impl_._has_bits_[0] &= ~0x00000001u; + auto* p = _impl_.exception_message_.Release(); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.exception_message_.IsDefault()) { + _impl_.exception_message_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + return p; +} +inline void Response::set_allocated_exception_message(std::string* exception_message) { + if (exception_message != nullptr) { + _impl_._has_bits_[0] |= 0x00000001u; + } else { + _impl_._has_bits_[0] &= ~0x00000001u; + } + _impl_.exception_message_.SetAllocated(exception_message, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.exception_message_.IsDefault()) { + _impl_.exception_message_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:mozilla.appservices.httpconfig.protobuf.Response.exception_message) +} + +// optional string url = 2; +inline bool Response::_internal_has_url() const { + bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; + return value; +} +inline bool Response::has_url() const { + return _internal_has_url(); +} +inline void Response::clear_url() { + _impl_.url_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000002u; +} +inline const std::string& Response::url() const { + // @@protoc_insertion_point(field_get:mozilla.appservices.httpconfig.protobuf.Response.url) + return _internal_url(); +} +template <typename ArgT0, typename... ArgT> +inline PROTOBUF_ALWAYS_INLINE +void Response::set_url(ArgT0&& arg0, ArgT... args) { + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.url_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:mozilla.appservices.httpconfig.protobuf.Response.url) +} +inline std::string* Response::mutable_url() { + std::string* _s = _internal_mutable_url(); + // @@protoc_insertion_point(field_mutable:mozilla.appservices.httpconfig.protobuf.Response.url) + return _s; +} +inline const std::string& Response::_internal_url() const { + return _impl_.url_.Get(); +} +inline void Response::_internal_set_url(const std::string& value) { + _impl_._has_bits_[0] |= 0x00000002u; + _impl_.url_.Set(value, GetArenaForAllocation()); +} +inline std::string* Response::_internal_mutable_url() { + _impl_._has_bits_[0] |= 0x00000002u; + return _impl_.url_.Mutable(GetArenaForAllocation()); +} +inline std::string* Response::release_url() { + // @@protoc_insertion_point(field_release:mozilla.appservices.httpconfig.protobuf.Response.url) + if (!_internal_has_url()) { + return nullptr; + } + _impl_._has_bits_[0] &= ~0x00000002u; + auto* p = _impl_.url_.Release(); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.url_.IsDefault()) { + _impl_.url_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + return p; +} +inline void Response::set_allocated_url(std::string* url) { + if (url != nullptr) { + _impl_._has_bits_[0] |= 0x00000002u; + } else { + _impl_._has_bits_[0] &= ~0x00000002u; + } + _impl_.url_.SetAllocated(url, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.url_.IsDefault()) { + _impl_.url_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:mozilla.appservices.httpconfig.protobuf.Response.url) +} + +// optional int32 status = 3; +inline bool Response::_internal_has_status() const { + bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0; + return value; +} +inline bool Response::has_status() const { + return _internal_has_status(); +} +inline void Response::clear_status() { + _impl_.status_ = 0; + _impl_._has_bits_[0] &= ~0x00000008u; +} +inline int32_t Response::_internal_status() const { + return _impl_.status_; +} +inline int32_t Response::status() const { + // @@protoc_insertion_point(field_get:mozilla.appservices.httpconfig.protobuf.Response.status) + return _internal_status(); +} +inline void Response::_internal_set_status(int32_t value) { + _impl_._has_bits_[0] |= 0x00000008u; + _impl_.status_ = value; +} +inline void Response::set_status(int32_t value) { + _internal_set_status(value); + // @@protoc_insertion_point(field_set:mozilla.appservices.httpconfig.protobuf.Response.status) +} + +// optional bytes body = 4; +inline bool Response::_internal_has_body() const { + bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; + return value; +} +inline bool Response::has_body() const { + return _internal_has_body(); +} +inline void Response::clear_body() { + _impl_.body_.ClearToEmpty(); + _impl_._has_bits_[0] &= ~0x00000004u; +} +inline const std::string& Response::body() const { + // @@protoc_insertion_point(field_get:mozilla.appservices.httpconfig.protobuf.Response.body) + return _internal_body(); +} +template <typename ArgT0, typename... ArgT> +inline PROTOBUF_ALWAYS_INLINE +void Response::set_body(ArgT0&& arg0, ArgT... args) { + _impl_._has_bits_[0] |= 0x00000004u; + _impl_.body_.SetBytes(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:mozilla.appservices.httpconfig.protobuf.Response.body) +} +inline std::string* Response::mutable_body() { + std::string* _s = _internal_mutable_body(); + // @@protoc_insertion_point(field_mutable:mozilla.appservices.httpconfig.protobuf.Response.body) + return _s; +} +inline const std::string& Response::_internal_body() const { + return _impl_.body_.Get(); +} +inline void Response::_internal_set_body(const std::string& value) { + _impl_._has_bits_[0] |= 0x00000004u; + _impl_.body_.Set(value, GetArenaForAllocation()); +} +inline std::string* Response::_internal_mutable_body() { + _impl_._has_bits_[0] |= 0x00000004u; + return _impl_.body_.Mutable(GetArenaForAllocation()); +} +inline std::string* Response::release_body() { + // @@protoc_insertion_point(field_release:mozilla.appservices.httpconfig.protobuf.Response.body) + if (!_internal_has_body()) { + return nullptr; + } + _impl_._has_bits_[0] &= ~0x00000004u; + auto* p = _impl_.body_.Release(); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.body_.IsDefault()) { + _impl_.body_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + return p; +} +inline void Response::set_allocated_body(std::string* body) { + if (body != nullptr) { + _impl_._has_bits_[0] |= 0x00000004u; + } else { + _impl_._has_bits_[0] &= ~0x00000004u; + } + _impl_.body_.SetAllocated(body, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.body_.IsDefault()) { + _impl_.body_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:mozilla.appservices.httpconfig.protobuf.Response.body) +} + +// map<string, string> headers = 5; +inline int Response::_internal_headers_size() const { + return _impl_.headers_.size(); +} +inline int Response::headers_size() const { + return _internal_headers_size(); +} +inline void Response::clear_headers() { + _impl_.headers_.Clear(); +} +inline const ::PROTOBUF_NAMESPACE_ID::Map< std::string, std::string >& +Response::_internal_headers() const { + return _impl_.headers_.GetMap(); +} +inline const ::PROTOBUF_NAMESPACE_ID::Map< std::string, std::string >& +Response::headers() const { + // @@protoc_insertion_point(field_map:mozilla.appservices.httpconfig.protobuf.Response.headers) + return _internal_headers(); +} +inline ::PROTOBUF_NAMESPACE_ID::Map< std::string, std::string >* +Response::_internal_mutable_headers() { + return _impl_.headers_.MutableMap(); +} +inline ::PROTOBUF_NAMESPACE_ID::Map< std::string, std::string >* +Response::mutable_headers() { + // @@protoc_insertion_point(field_mutable_map:mozilla.appservices.httpconfig.protobuf.Response.headers) + return _internal_mutable_headers(); +} + +#ifdef __GNUC__ + #pragma GCC diagnostic pop +#endif // __GNUC__ +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + + +// @@protoc_insertion_point(namespace_scope) + +} // namespace protobuf +} // namespace httpconfig +} // namespace appservices +} // namespace mozilla + +PROTOBUF_NAMESPACE_OPEN + +template <> struct is_proto_enum< ::mozilla::appservices::httpconfig::protobuf::Request_Method> : ::std::true_type {}; + +PROTOBUF_NAMESPACE_CLOSE + +// @@protoc_insertion_point(global_scope) + +#include <google/protobuf/port_undef.inc> +#endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_fetch_5fmsg_5ftypes_2eproto diff --git a/toolkit/components/viaduct/fetch_msg_types.proto b/toolkit/components/viaduct/fetch_msg_types.proto new file mode 100644 index 0000000000..96963cef42 --- /dev/null +++ b/toolkit/components/viaduct/fetch_msg_types.proto @@ -0,0 +1,42 @@ +syntax = "proto2"; + +// Note: this file name must be unique due to how the iOS megazord works :( + +package mozilla.appservices.httpconfig.protobuf; + +option java_package = "mozilla.appservices.httpconfig"; +option java_outer_classname = "MsgTypes"; +option swift_prefix = "MsgTypes_"; +option optimize_for = LITE_RUNTIME; + +message Request { + enum Method { + GET = 0; + HEAD = 1; + POST = 2; + PUT = 3; + DELETE = 4; + CONNECT = 5; + OPTIONS = 6; + TRACE = 7; + PATCH = 8; + } + required Method method = 1; + required string url = 2; + optional bytes body = 3; + map<string, string> headers = 4; + required bool follow_redirects = 5; + required bool use_caches = 6; + required int32 connect_timeout_secs = 7; + required int32 read_timeout_secs = 8; +} + +message Response { + // If this is present, nothing else is. + optional string exception_message = 1; + optional string url = 2; + optional int32 status = 3; + optional bytes body = 4; + map<string, string> headers = 5; +} + diff --git a/toolkit/components/viaduct/moz.build b/toolkit/components/viaduct/moz.build new file mode 100644 index 0000000000..56db22762b --- /dev/null +++ b/toolkit/components/viaduct/moz.build @@ -0,0 +1,22 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +UNIFIED_SOURCES += [ + "fetch_msg_types.pb.cc", + "Viaduct.cpp", + "ViaductRequest.cpp", +] + +EXPORTS.mozilla += [ + "fetch_msg_types.pb.h", + "Viaduct.h", + "ViaductRequest.h", +] + +include("/ipc/chromium/chromium-config.mozbuild") + +DEFINES["GOOGLE_PROTOBUF_NO_RTTI"] = True +DEFINES["GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER"] = True + +FINAL_LIBRARY = "xul" |