| // Copyright 2017 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 "net/socket/socket_tag.h" |
| #include "base/logging.h" |
| #include "net/android/network_library.h" |
| // Expose UNSET_UID to Java. |
| // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.net |
| // Java generator needs explicit integer, verify equality here. |
| static_assert(UNSET == SocketTag::UNSET_UID, |
| "TrafficStatsUid does not match SocketTag::UNSET_UID"); |
| bool SocketTag::operator<(const SocketTag& other) const { |
| return std::tie(uid_, traffic_stats_tag_) < |
| std::tie(other.uid_, other.traffic_stats_tag_); |
| bool SocketTag::operator==(const SocketTag& other) const { |
| return std::tie(uid_, traffic_stats_tag_) == |
| std::tie(other.uid_, other.traffic_stats_tag_); |
| void SocketTag::Apply(SocketDescriptor socket) const { |
| net::android::TagSocket(socket, uid_, traffic_stats_tag_); |