cURL: follow redirects
[LibreOffice.git] / binaryurp / source / outgoingrequests.cxx
blobb6aa946d8e9af4f8376777b9468ed6eb241fde9b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "sal/config.h"
22 #include <cassert>
24 #include "com/sun/star/uno/RuntimeException.hpp"
25 #include "rtl/byteseq.hxx"
26 #include "osl/mutex.hxx"
27 #include <osl/diagnose.h>
29 #include "lessoperators.hxx"
30 #include "outgoingrequest.hxx"
31 #include "outgoingrequests.hxx"
33 namespace binaryurp {
35 OutgoingRequests::OutgoingRequests() {}
37 OutgoingRequests::~OutgoingRequests() {}
39 void OutgoingRequests::push(
40 rtl::ByteSequence const & tid, OutgoingRequest const & request)
42 osl::MutexGuard g(mutex_);
43 map_[tid].push_back(request);
46 OutgoingRequest OutgoingRequests::top(rtl::ByteSequence const & tid) {
47 osl::MutexGuard g(mutex_);
48 Map::iterator i(map_.find(tid));
49 if (i == map_.end()) {
50 throw css::uno::RuntimeException(
51 "URP: reply for unknown TID");
53 assert(!i->second.empty());
54 return i->second.back();
57 void OutgoingRequests::pop(rtl::ByteSequence const & tid) throw () {
58 osl::MutexGuard g(mutex_);
59 Map::iterator i(map_.find(tid));
60 assert(i != map_.end());
61 i->second.pop_back();
62 if (i->second.empty()) {
63 map_.erase(i);
69 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */