forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Mojo] Add SetDefaultProcessErrorHandler ABI
This adds SetDefaultProcessErrorHandler to the public C ABI for Mojo Core to replace the only remaining non-public, non-Init, non-test-only API in the mojo::core namespace. Setting a default process error handler is something the Network Service uses as part of its own application logic in order to generate useful crash reports when bad IPCs are received. This suggests that the feature belongs in the public API, and indeed it must be exposed there in order to support Chrome loading Mojo Core dynamically in some runtime environments. A follow-up CL will transition call sites from the static mojo::core API to this new public one. helper in mojo/public/cpp/test_support, which is migrated to the public API by this CL. Bug: 1082473 Test: Several content_unittests tests rely on the BadMessageObserver Change-Id: I77378467afde722b8173df56538221fcaf82a4eb Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2227866 Commit-Queue: Ken Rockot <rockot@google.com> Reviewed-by: Oksana Zhuravlova <oksamyt@chromium.org> Cr-Commit-Position: refs/heads/master@{#774869}
- Loading branch information
Showing
12 changed files
with
152 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright 2020 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "mojo/public/cpp/system/functions.h" | ||
|
||
#include "base/callback.h" | ||
#include "base/no_destructor.h" | ||
|
||
namespace mojo { | ||
|
||
namespace { | ||
|
||
DefaultProcessErrorHandler& GetDefaultProcessErrorHandler() { | ||
static base::NoDestructor<DefaultProcessErrorHandler> handler; | ||
return *handler; | ||
} | ||
|
||
void HandleError(const MojoProcessErrorDetails* details) { | ||
const DefaultProcessErrorHandler& handler = GetDefaultProcessErrorHandler(); | ||
handler.Run( | ||
std::string(details->error_message, details->error_message_length)); | ||
} | ||
|
||
} // namespace | ||
|
||
void SetDefaultProcessErrorHandler(DefaultProcessErrorHandler handler) { | ||
// Ensure any previously set handler is wiped out. | ||
MojoSetDefaultProcessErrorHandler(nullptr, nullptr); | ||
auto& global_handler = GetDefaultProcessErrorHandler(); | ||
global_handler = std::move(handler); | ||
if (global_handler) | ||
MojoSetDefaultProcessErrorHandler(&HandleError, nullptr); | ||
} | ||
|
||
} // namespace mojo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters