Skip to content

Commit 8bf9989

Browse files
zetafunctionChromium LUCI CQ
authored and
Chromium LUCI CQ
committed
Trim down functionality in mojo::AssociatedInterfacePtrInfo.
At this point, this is just a helper class for conveying info when binding and unbinding an associated remote endpoint, so remove all other functionality. Bug: 875030, 955171 Change-Id: I7711b97deb306536fe4951f5a575ef1231c2ebec Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3527063 Reviewed-by: Ken Rockot <[email protected]> Commit-Queue: Daniel Cheng <[email protected]> Cr-Commit-Position: refs/heads/main@{#982544}
1 parent 0e5d596 commit 8bf9989

File tree

6 files changed

+4
-191
lines changed

6 files changed

+4
-191
lines changed

PRESUBMIT.py

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,19 +1015,6 @@ class BanRule:
10151015
),
10161016
)
10171017

1018-
# Format: Sequence of tuples containing:
1019-
# * String pattern or, if starting with a slash, a regular expression.
1020-
# * Sequence of strings to show when the pattern matches.
1021-
_DEPRECATED_MOJO_TYPES : Sequence[BanRule] = (
1022-
BanRule(
1023-
r'/\bmojo::AssociatedInterfacePtrInfo\b',
1024-
(
1025-
'mojo::AssociatedInterfacePtrInfo<Interface> is deprecated.',
1026-
'Use mojo::PendingAssociatedRemote<Interface> instead.',
1027-
),
1028-
),
1029-
)
1030-
10311018
_IPC_ENUM_TRAITS_DEPRECATED = (
10321019
'You are using IPC_ENUM_TRAITS() in your code. It has been deprecated.\n'
10331020
'See http://www.chromium.org/Home/chromium-security/education/'
@@ -1733,48 +1720,6 @@ def _CheckAndroidNoBannedImports(input_api, output_api):
17331720
return result
17341721

17351722

1736-
def CheckNoDeprecatedMojoTypes(input_api, output_api):
1737-
"""Make sure that old Mojo types are not used."""
1738-
warnings = []
1739-
errors = []
1740-
1741-
# For any path that is not an "ok" or an "error" path, a warning will be
1742-
# raised if deprecated mojo types are found.
1743-
ok_paths = ['components/arc']
1744-
error_paths = ['third_party/blink', 'content']
1745-
1746-
file_filter = lambda f: f.LocalPath().endswith(('.cc', '.mm', '.h'))
1747-
for f in input_api.AffectedFiles(file_filter=file_filter):
1748-
# Don't check //components/arc, not yet migrated (see crrev.com/c/1868870).
1749-
if any(map(lambda path: f.LocalPath().startswith(path), ok_paths)):
1750-
continue
1751-
1752-
for line_num, line in f.ChangedContents():
1753-
for ban_rule in _DEPRECATED_MOJO_TYPES:
1754-
problems = _GetMessageForMatchingType(input_api, f, line_num,
1755-
line, ban_rule)
1756-
1757-
if problems:
1758-
# Raise errors inside |error_paths| and warnings everywhere else.
1759-
if any(
1760-
map(lambda path: f.LocalPath().startswith(path),
1761-
error_paths)):
1762-
errors.extend(problems)
1763-
else:
1764-
warnings.extend(problems)
1765-
1766-
result = []
1767-
if (warnings):
1768-
result.append(
1769-
output_api.PresubmitPromptWarning(
1770-
'Banned Mojo types were used.\n' + '\n'.join(warnings)))
1771-
if (errors):
1772-
result.append(
1773-
output_api.PresubmitError('Banned Mojo types were used.\n' +
1774-
'\n'.join(errors)))
1775-
return result
1776-
1777-
17781723
def CheckNoPragmaOnce(input_api, output_api):
17791724
"""Make sure that banned functions are not used."""
17801725
files = []

PRESUBMIT_test.py

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -2613,74 +2613,6 @@ def testBannedMojomPatterns(self):
26132613
self.assertTrue('bad.mojom' in results[0].message)
26142614
self.assertTrue('good.mojom' not in results[0].message)
26152615

2616-
def testDeprecatedMojoTypes(self):
2617-
ok_paths = ['components/arc']
2618-
warning_paths = ['some/cpp']
2619-
error_paths = ['third_party/blink', 'content']
2620-
test_cases = [
2621-
{
2622-
'type': 'mojo::AssociatedInterfacePtrInfo<>',
2623-
'file': 'file4.cc'
2624-
},
2625-
{
2626-
'type': 'mojo::AssociatedInterfaceRequest<>',
2627-
'file': 'file5.cc'
2628-
},
2629-
{
2630-
'type': 'mojo::InterfacePtr<>',
2631-
'file': 'file8.cc'
2632-
},
2633-
{
2634-
'type': 'mojo::InterfacePtrInfo<>',
2635-
'file': 'file9.cc'
2636-
},
2637-
{
2638-
'type': 'mojo::InterfaceRequest<>',
2639-
'file': 'file10.cc'
2640-
},
2641-
{
2642-
'type': 'mojo::MakeRequest()',
2643-
'file': 'file11.cc'
2644-
},
2645-
]
2646-
2647-
# Build the list of MockFiles considering paths that should trigger warnings
2648-
# as well as paths that should trigger errors.
2649-
input_api = MockInputApi()
2650-
input_api.files = []
2651-
for test_case in test_cases:
2652-
for path in ok_paths:
2653-
input_api.files.append(MockFile(os.path.join(path, test_case['file']),
2654-
[test_case['type']]))
2655-
for path in warning_paths:
2656-
input_api.files.append(MockFile(os.path.join(path, test_case['file']),
2657-
[test_case['type']]))
2658-
for path in error_paths:
2659-
input_api.files.append(MockFile(os.path.join(path, test_case['file']),
2660-
[test_case['type']]))
2661-
2662-
results = PRESUBMIT.CheckNoDeprecatedMojoTypes(input_api, MockOutputApi())
2663-
2664-
# warnings are results[0], errors are results[1]
2665-
self.assertEqual(2, len(results))
2666-
2667-
for test_case in test_cases:
2668-
# Check that no warnings nor errors have been triggered for these paths.
2669-
for path in ok_paths:
2670-
self.assertFalse(path in results[0].message)
2671-
self.assertFalse(path in results[1].message)
2672-
2673-
# Check warnings have been triggered for these paths.
2674-
for path in warning_paths:
2675-
self.assertTrue(path in results[0].message)
2676-
self.assertFalse(path in results[1].message)
2677-
2678-
# Check errors have been triggered for these paths.
2679-
for path in error_paths:
2680-
self.assertFalse(path in results[0].message)
2681-
self.assertTrue(path in results[1].message)
2682-
2683-
26842616
class NoProductionCodeUsingTestOnlyFunctionsTest(unittest.TestCase):
26852617
def testTruePositives(self):
26862618
mock_input_api = MockInputApi()

mojo/public/cpp/bindings/associated_interface_ptr_info.h

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,9 @@ namespace mojo {
2424
template <typename Interface>
2525
class AssociatedInterfacePtrInfo {
2626
public:
27-
AssociatedInterfacePtrInfo() : version_(0u) {}
28-
AssociatedInterfacePtrInfo(std::nullptr_t) : version_(0u) {}
29-
3027
AssociatedInterfacePtrInfo(AssociatedInterfacePtrInfo&& other)
31-
: handle_(std::move(other.handle_)), version_(other.version_) {
32-
other.version_ = 0u;
33-
}
28+
: handle_(std::move(other.handle_)),
29+
version_(std::exchange(other.version_, 0u)) {}
3430

3531
AssociatedInterfacePtrInfo(ScopedInterfaceEndpointHandle handle,
3632
uint32_t version)
@@ -45,36 +41,16 @@ class AssociatedInterfacePtrInfo {
4541
AssociatedInterfacePtrInfo& operator=(AssociatedInterfacePtrInfo&& other) {
4642
if (this != &other) {
4743
handle_ = std::move(other.handle_);
48-
version_ = other.version_;
49-
other.version_ = 0u;
44+
version_ = std::exchange(other.version_, 0u);
5045
}
5146

5247
return *this;
5348
}
5449

5550
bool is_valid() const { return handle_.is_valid(); }
5651

57-
explicit operator bool() const { return handle_.is_valid(); }
58-
59-
ScopedInterfaceEndpointHandle PassHandle() {
60-
return std::move(handle_);
61-
}
62-
const ScopedInterfaceEndpointHandle& handle() const { return handle_; }
63-
void set_handle(ScopedInterfaceEndpointHandle handle) {
64-
handle_ = std::move(handle);
65-
}
66-
52+
ScopedInterfaceEndpointHandle PassHandle() { return std::move(handle_); }
6753
uint32_t version() const { return version_; }
68-
void set_version(uint32_t version) { version_ = version; }
69-
70-
bool Equals(const AssociatedInterfacePtrInfo& other) const {
71-
if (this == &other)
72-
return true;
73-
74-
// Now that the two refer to different objects, they are equivalent if
75-
// and only if they are both invalid.
76-
return !is_valid() && !other.is_valid();
77-
}
7854

7955
private:
8056
ScopedInterfaceEndpointHandle handle_;

mojo/public/cpp/bindings/deprecated_interface_types_forward.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// Forward declarations which foo.mojom-forward.h requires.
99
namespace mojo {
1010

11-
template <typename Interface>
12-
class InterfacePtrInfo;
1311
template <typename Interface>
1412
class AssociatedInterfacePtrInfo;
1513

mojo/public/cpp/bindings/lib/interface_serialization.h

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -26,33 +26,6 @@ class Message;
2626

2727
namespace internal {
2828

29-
template <typename Base, typename T>
30-
struct Serializer<AssociatedInterfacePtrInfoDataView<Base>,
31-
AssociatedInterfacePtrInfo<T>> {
32-
static_assert(std::is_base_of<Base, T>::value, "Interface type mismatch.");
33-
34-
static void Serialize(AssociatedInterfacePtrInfo<T>& input,
35-
AssociatedInterface_Data* output,
36-
Message* message) {
37-
DCHECK(!input.handle().is_valid() || input.handle().pending_association());
38-
SerializeAssociatedInterfaceInfo(input.PassHandle(), input.version(),
39-
*message, *output);
40-
}
41-
42-
static bool Deserialize(AssociatedInterface_Data* input,
43-
AssociatedInterfacePtrInfo<T>* output,
44-
Message* message) {
45-
auto handle = DeserializeAssociatedEndpointHandle(input->handle, *message);
46-
if (!handle.is_valid()) {
47-
*output = AssociatedInterfacePtrInfo<T>();
48-
} else {
49-
output->set_handle(std::move(handle));
50-
output->set_version(input->version);
51-
}
52-
return true;
53-
}
54-
};
55-
5629
template <typename Base, typename T>
5730
struct Serializer<AssociatedInterfacePtrInfoDataView<Base>,
5831
PendingAssociatedRemote<T>> {

mojo/public/cpp/bindings/pending_associated_remote.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,6 @@ class PendingAssociatedRemote {
3737
uint32_t version)
3838
: handle_(std::move(handle)), version_(version) {}
3939

40-
// Temporary helper for transitioning away from old types. Intentionally an
41-
// implicit constructor.
42-
PendingAssociatedRemote(AssociatedInterfacePtrInfo<Interface>&& ptr_info)
43-
: PendingAssociatedRemote(ptr_info.PassHandle(), ptr_info.version()) {}
44-
4540
// Disabled on NaCl since it crashes old version of clang.
4641
#if !BUILDFLAG(IS_NACL)
4742
// Move conversion operator for custom remote types. Only participates in
@@ -74,12 +69,6 @@ class PendingAssociatedRemote {
7469

7570
void reset() { handle_.reset(); }
7671

77-
// Temporary helper for transitioning away from old bindings types. This is
78-
// intentionally an implicit conversion.
79-
operator AssociatedInterfacePtrInfo<Interface>() {
80-
return AssociatedInterfacePtrInfo<Interface>(PassHandle(), version());
81-
}
82-
8372
ScopedInterfaceEndpointHandle PassHandle() { return std::move(handle_); }
8473
const ScopedInterfaceEndpointHandle& handle() const { return handle_; }
8574
void set_handle(ScopedInterfaceEndpointHandle handle) {

0 commit comments

Comments
 (0)