0

Reland: Deprecate mojo::DataPipe

This is the first step in eliminating mojo::DataPipe. Marking it as
deprecated with a comment and adding a DLOG (that only logs once per
process launch) will hopefully stop it from being used in new code.

Previous change was reverted due to log spam.

Bug: 944990
Change-Id: I492f7ac2038db31ce4af6a31a0b1a80570c46aef
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1544798
Auto-Submit: Carlos Knippschild <carlosk@chromium.org>
Reviewed-by: Andrew Grieve <agrieve@chromium.org>
Reviewed-by: Ken Rockot <rockot@google.com>
Commit-Queue: Ken Rockot <rockot@google.com>
Cr-Commit-Position: refs/heads/master@{#648821}
This commit is contained in:
Carlos Knippschild
2019-04-08 20:02:38 +00:00
committed by Commit Bot
parent 4870264e41
commit ab192b8cf9
3 changed files with 27 additions and 9 deletions

@ -710,6 +710,14 @@ _BANNED_CPP_FUNCTIONS = (
r'^third_party/blink/renderer/.*\.(cc|h)$',
),
),
(
'mojo::DataPipe',
(
'mojo::DataPipe is deprecated. Use mojo::CreateDataPipe instead.',
),
True,
(),
),
)

@ -1772,6 +1772,20 @@ class BannedFunctionCheckTest(unittest.TestCase):
self.assertTrue('another/ios_file.mm' in errors[0].message)
self.assertTrue('some/mac/file.mm' not in errors[0].message)
def testBannedMojoFunctions(self):
input_api = MockInputApi()
input_api.files = [
MockFile('some/cpp/problematic/file.cc',
['mojo::DataPipe();']),
MockFile('some/cpp/ok/file.cc',
['CreateDataPipe();']),
]
errors = PRESUBMIT._CheckNoBannedFunctions(input_api, MockOutputApi())
self.assertEqual(1, len(errors))
self.assertTrue('some/cpp/problematic/file.cc' in errors[0].message)
self.assertTrue('some/cpp/ok/file.cc' not in errors[0].message)
class NoProductionCodeUsingTestOnlyFunctionsTest(unittest.TestCase):
def testTruePositives(self):

@ -131,16 +131,12 @@ inline MojoResult CreateDataPipe(
return rv;
}
// 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.
//
// Note that this class is not safe to use in production code, as there is no
// way for it to report failure while creating the pipe, while in practice
// creating a new data pipe does fail every now and then. Instead just call
// CreateDataPipe directly and check its return value.
//
// TODO(vtl): Make an even more friendly version? (Maybe templatized for a
// particular type instead of some "element"? Maybe functions that take
// vectors?)
class MOJO_CPP_SYSTEM_EXPORT DataPipe {
public:
DataPipe();