crashpad/util/mach/composite_mach_message_server.cc
Hans Wennborg 032f1aecc2 Include-what-you-use related to logging.h
Add direct includes for things provided transitively by logging.h
(or by other headers including logging.h).

This is in preparation for cleaning up unnecessary includes of
logging.h in header files (so if something depends on logging.h,
it needs include it explicitly), and for when Chromium's logging.h
no longer includes check.h, check_op.h, and notreached.h.

DEPS is also updated to roll mini_chromium to ae14a14ab4 which
includes these new header files.

Bug: chromium:1031540
Change-Id: I36f646d0a93854989dc602d0dc7139dd7a7b8621
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2250251
Commit-Queue: Hans Wennborg <hans@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-06-18 13:51:20 +00:00

88 lines
2.8 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Copyright 2014 The Crashpad Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "util/mach/composite_mach_message_server.h"
#include <algorithm>
#include <ostream>
#include <utility>
#include "base/logging.h"
#include "util/mach/mach_message.h"
namespace crashpad {
CompositeMachMessageServer::CompositeMachMessageServer()
: MachMessageServer::Interface(),
handler_map_(),
request_size_(sizeof(mach_msg_header_t)),
reply_size_(sizeof(mig_reply_error_t)) {
}
CompositeMachMessageServer::~CompositeMachMessageServer() {
}
void CompositeMachMessageServer::AddHandler(
MachMessageServer::Interface* handler) {
// Other cycles would be invalid as well, but they arent currently checked.
DCHECK_NE(handler, this);
std::set<mach_msg_id_t> request_ids = handler->MachMessageServerRequestIDs();
for (mach_msg_id_t request_id : request_ids) {
std::pair<HandlerMap::const_iterator, bool> result =
handler_map_.insert(std::make_pair(request_id, handler));
CHECK(result.second) << "duplicate request ID " << request_id;
}
request_size_ =
std::max(request_size_, handler->MachMessageServerRequestSize());
reply_size_ = std::max(reply_size_, handler->MachMessageServerReplySize());
}
bool CompositeMachMessageServer::MachMessageServerFunction(
const mach_msg_header_t* in,
mach_msg_header_t* out,
bool* destroy_complex_request) {
HandlerMap::const_iterator iterator = handler_map_.find(in->msgh_id);
if (iterator == handler_map_.end()) {
// Do what MIG-generated server routines do when they cant dispatch a
// message.
PrepareMIGReplyFromRequest(in, out);
SetMIGReplyError(out, MIG_BAD_ID);
return false;
}
MachMessageServer::Interface* handler = iterator->second;
return handler->MachMessageServerFunction(in, out, destroy_complex_request);
}
std::set<mach_msg_id_t>
CompositeMachMessageServer::MachMessageServerRequestIDs() {
std::set<mach_msg_id_t> request_ids;
for (const auto& entry : handler_map_) {
request_ids.insert(entry.first);
}
return request_ids;
}
mach_msg_size_t CompositeMachMessageServer::MachMessageServerRequestSize() {
return request_size_;
}
mach_msg_size_t CompositeMachMessageServer::MachMessageServerReplySize() {
return reply_size_;
}
} // namespace crashpad