Commit b422ae79 authored by Robert Sesek's avatar Robert Sesek Committed by Commit Bot

Convert network.mojom.LoggingSettings to use handle<platform>

Bug: 710376
Change-Id: I78027a4bb288f9136de105c76df364cf24c70087
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2053254Reviewed-by: default avatarTom Sepez <tsepez@chromium.org>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Commit-Queue: Robert Sesek <rsesek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#741537}
parent 0ba5f972
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/network_service_instance.h" #include "content/public/browser/network_service_instance.h"
#include "content/public/common/network_service_util.h" #include "content/public/common/network_service_util.h"
#include "mojo/public/cpp/system/platform_handle.h"
#include "services/network/public/mojom/network_service.mojom.h" #include "services/network/public/mojom/network_service.mojom.h"
namespace logging { namespace logging {
...@@ -53,13 +52,13 @@ void SymlinkSetUp(const base::CommandLine& command_line, ...@@ -53,13 +52,13 @@ void SymlinkSetUp(const base::CommandLine& command_line,
if (content::IsOutOfProcessNetworkService()) { if (content::IsOutOfProcessNetworkService()) {
auto logging_settings = network::mojom::LoggingSettings::New(); auto logging_settings = network::mojom::LoggingSettings::New();
logging_settings->logging_dest = settings.logging_dest; logging_settings->logging_dest = settings.logging_dest;
const int log_file_descriptor = fileno(logging::DuplicateLogFILE()); base::ScopedFD log_file_descriptor(fileno(logging::DuplicateLogFILE()));
if (log_file_descriptor < 0) { if (log_file_descriptor.get() < 0) {
DLOG(WARNING) << "Unable to duplicate log file handle"; DLOG(WARNING) << "Unable to duplicate log file handle";
return; return;
} }
logging_settings->log_file_descriptor = logging_settings->log_file_descriptor =
mojo::WrapPlatformFile(log_file_descriptor); mojo::PlatformHandle(std::move(log_file_descriptor));
content::GetNetworkService()->ReinitializeLogging( content::GetNetworkService()->ReinitializeLogging(
std::move(logging_settings)); std::move(logging_settings));
} }
......
...@@ -74,10 +74,6 @@ ...@@ -74,10 +74,6 @@
#include "net/android/http_auth_negotiate_android.h" #include "net/android/http_auth_negotiate_android.h"
#endif #endif
#if defined(OS_CHROMEOS)
#include "mojo/public/cpp/system/platform_handle.h"
#endif
namespace network { namespace network {
namespace { namespace {
...@@ -414,14 +410,8 @@ void NetworkService::DeregisterNetworkContext(NetworkContext* network_context) { ...@@ -414,14 +410,8 @@ void NetworkService::DeregisterNetworkContext(NetworkContext* network_context) {
void NetworkService::ReinitializeLogging(mojom::LoggingSettingsPtr settings) { void NetworkService::ReinitializeLogging(mojom::LoggingSettingsPtr settings) {
logging::LoggingSettings logging_settings; logging::LoggingSettings logging_settings;
logging_settings.logging_dest = settings->logging_dest; logging_settings.logging_dest = settings->logging_dest;
int log_file_descriptor = -1; base::ScopedFD log_file_descriptor = settings->log_file_descriptor.TakeFD();
if (mojo::UnwrapPlatformFile(std::move(settings->log_file_descriptor), logging_settings.log_file = fdopen(log_file_descriptor.release(), "a");
&log_file_descriptor) != MOJO_RESULT_OK ||
log_file_descriptor < 0) {
LOG(ERROR) << "Failed to read new log file handle";
return;
}
logging_settings.log_file = fdopen(log_file_descriptor, "a");
if (!logging_settings.log_file) { if (!logging_settings.log_file) {
LOG(ERROR) << "Failed to open new log file handle"; LOG(ERROR) << "Failed to open new log file handle";
return; return;
......
...@@ -161,7 +161,7 @@ struct NetworkServiceParams { ...@@ -161,7 +161,7 @@ struct NetworkServiceParams {
[EnableIf=is_chromeos] [EnableIf=is_chromeos]
struct LoggingSettings { struct LoggingSettings {
uint32 logging_dest; uint32 logging_dest;
handle log_file_descriptor; handle<platform> log_file_descriptor;
}; };
// Browser interface to the network service. // Browser interface to the network service.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment