0

Remove from mojo::DataPipe.

All callers have been converted to to mojo::CreateDataPipe.

Bug: 944990
Change-Id: Ibbd3eeb4dbb6e5a99d4475cadf0dac1b0a8a61a7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2664006
Reviewed-by: Ken Rockot <rockot@google.com>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#849331}
This commit is contained in:
Robert Sesek
2021-02-02 01:47:07 +00:00
committed by Chromium LUCI CQ
parent d24a98d4db
commit 351d2d5c03
5 changed files with 1 additions and 92 deletions

@ -971,14 +971,6 @@ _BANNED_CPP_FUNCTIONS = (
True,
(),
),
(
r'/\bmojo::DataPipe\b',
(
'mojo::DataPipe is deprecated. Use mojo::CreateDataPipe instead.',
),
True,
(),
),
(
'SHFileOperation',
(

@ -2368,14 +2368,8 @@ class BannedTypeCheckTest(unittest.TestCase):
def testBannedMojoFunctions(self):
input_api = MockInputApi()
input_api.files = [
MockFile('some/cpp/problematic/file.cc',
['mojo::DataPipe();']),
MockFile('some/cpp/problematic/file2.cc',
['mojo::ConvertTo<>']),
MockFile('some/cpp/ok/file.cc',
['CreateDataPipe();']),
MockFile('some/cpp/ok/file2.cc',
['mojo::DataPipeDrainer();']),
MockFile('third_party/blink/ok/file3.cc',
['mojo::ConvertTo<>']),
MockFile('content/renderer/ok/file3.cc',
@ -2385,11 +2379,8 @@ class BannedTypeCheckTest(unittest.TestCase):
results = PRESUBMIT.CheckNoBannedFunctions(input_api, MockOutputApi())
# warnings are results[0], errors are results[1]
self.assertEqual(2, len(results))
self.assertTrue('some/cpp/problematic/file.cc' in results[1].message)
self.assertEqual(1, len(results))
self.assertTrue('some/cpp/problematic/file2.cc' in results[0].message)
self.assertTrue('some/cpp/ok/file.cc' not in results[1].message)
self.assertTrue('some/cpp/ok/file2.cc' not in results[1].message)
self.assertTrue('third_party/blink/ok/file3.cc' not in results[0].message)
self.assertTrue('content/renderer/ok/file3.cc' not in results[0].message)

@ -9,7 +9,6 @@ component("system") {
"buffer.cc",
"buffer.h",
"core.h",
"data_pipe.cc",
"data_pipe.h",
"data_pipe_drainer.cc",
"data_pipe_drainer.h",

@ -1,56 +0,0 @@
// Copyright 2019 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/data_pipe.h"
#include "base/logging.h"
namespace mojo {
namespace {
NOINLINE void CrashMojoResourceExhausted() {
LOG(FATAL)
<< "Failed to create data pipe due to MOJO_RESULT_RESOURCE_EXHAUSTED.";
}
void CrashIfResultNotOk(MojoResult result) {
if (LIKELY(result == MOJO_RESULT_OK))
return;
// Include some extra information for resource exhausted failures.
if (result == MOJO_RESULT_RESOURCE_EXHAUSTED)
CrashMojoResourceExhausted();
LOG(FATAL) << "Failed to create data pipe; result=" << result;
}
} // namespace
DataPipe::DataPipe() {
MojoResult result =
CreateDataPipe(nullptr, &producer_handle, &consumer_handle);
CrashIfResultNotOk(result);
}
DataPipe::DataPipe(uint32_t capacity_num_bytes) {
MojoCreateDataPipeOptions options;
options.struct_size = sizeof(MojoCreateDataPipeOptions);
options.flags = MOJO_CREATE_DATA_PIPE_FLAG_NONE;
options.element_num_bytes = 1;
options.capacity_num_bytes = capacity_num_bytes;
MojoResult result =
CreateDataPipe(&options, &producer_handle, &consumer_handle);
CrashIfResultNotOk(result);
}
DataPipe::DataPipe(const MojoCreateDataPipeOptions& options) {
MojoResult result =
CreateDataPipe(&options, &producer_handle, &consumer_handle);
CrashIfResultNotOk(result);
}
DataPipe::~DataPipe() {}
} // namespace mojo

@ -153,23 +153,6 @@ inline MojoResult CreateDataPipe(
return CreateDataPipe(options, *data_pipe_producer, *data_pipe_consumer);
}
// DEPRECATED: use |CreateDataPipe| instead.
//
// This class is not safe to use in production code as there is no way for it to
// report failure while creating the pipe and it will CHECK in case of failures.
//
// A wrapper class that automatically creates a data pipe and owns both handles.
class MOJO_CPP_SYSTEM_EXPORT DataPipe {
public:
DataPipe();
explicit DataPipe(uint32_t capacity_num_bytes);
explicit DataPipe(const MojoCreateDataPipeOptions& options);
~DataPipe();
ScopedDataPipeProducerHandle producer_handle;
ScopedDataPipeConsumerHandle consumer_handle;
};
} // namespace mojo
#endif // MOJO_PUBLIC_CPP_SYSTEM_DATA_PIPE_H_