Skip to content

Commit

Permalink
[CrOS PhoneHub] Correct ConnectionDetails::operator<()
Browse files Browse the repository at this point in the history
Consider ConnectionDetails::connection_medium_ when comparing
ConnectionMedium objects. This fixes an issue in which two
ConnectionDetails objects with the same device ID but different mediums
were compared incorrectly, causing an issue where connection attempts to
the same device with different mediums ended up using the same
underlying connection instead of two separate connections.

Bug: 1150070
Change-Id: I9bb2802676aebf4a0df9a430cc33bff683dcd14e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2545664
Auto-Submit: Kyle Horimoto <khorimoto@chromium.org>
Commit-Queue: James Vecore <vecore@google.com>
Reviewed-by: James Vecore <vecore@google.com>
Cr-Commit-Position: refs/heads/master@{#828456}
  • Loading branch information
Kyle Horimoto authored and Commit Bot committed Nov 17, 2020
1 parent 6a3cf69 commit 1b733b7
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions chromeos/services/secure_channel/connection_details.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "chromeos/services/secure_channel/connection_details.h"

#include <tuple>

#include "base/check.h"
#include "chromeos/components/multidevice/remote_device_ref.h"

Expand All @@ -29,12 +31,8 @@ bool ConnectionDetails::operator!=(const ConnectionDetails& other) const {
}

bool ConnectionDetails::operator<(const ConnectionDetails& other) const {
if (device_id() != other.device_id())
return device_id() < other.device_id();

// Currently, there is only one ConnectionMedium type.
DCHECK(connection_medium() == other.connection_medium());
return false;
return std::tie(device_id_, connection_medium_) <
std::tie(other.device_id_, other.connection_medium_);
}

std::ostream& operator<<(std::ostream& stream,
Expand Down

0 comments on commit 1b733b7

Please sign in to comment.