Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(319)

Unified Diff: components/data_usage/core/data_use.cc

Issue 1421983002: Include tab IDs when reporting data use accounting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@data_use_scoped_vector
Patch Set: Moved tab ID determination logic into data_usage codebase. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/data_usage/core/data_use.cc
diff --git a/components/data_usage/core/data_use.cc b/components/data_usage/core/data_use.cc
index 94daab76c0b15862b4dd5f4bf137610fce7c9cf0..f073dba1e4f5463c6818c0f5337e13ae73092d67 100644
--- a/components/data_usage/core/data_use.cc
+++ b/components/data_usage/core/data_use.cc
@@ -6,6 +6,21 @@
namespace data_usage {
+namespace {
+
+bool AreNonByteCountFieldsEqual(const DataUse& a, const DataUse& b) {
+ return a.url == b.url && a.request_start == b.request_start &&
+ a.first_party_for_cookies == b.first_party_for_cookies &&
+ a.tab_id == b.tab_id && a.connection_type == b.connection_type &&
+ a.mcc_mnc == b.mcc_mnc;
+}
+
+bool AreByteCountFieldsEqual(const DataUse& a, const DataUse& b) {
+ return a.tx_bytes == b.tx_bytes && a.rx_bytes == b.rx_bytes;
+}
+
+} // namespace
+
DataUse::DataUse(const GURL& url,
const base::TimeTicks& request_start,
const GURL& first_party_for_cookies,
@@ -25,11 +40,13 @@ DataUse::DataUse(const GURL& url,
DataUse::~DataUse() {}
+bool DataUse::operator==(const DataUse& other) const {
+ return AreNonByteCountFieldsEqual(*this, other) &&
+ AreByteCountFieldsEqual(*this, other);
+}
+
bool DataUse::CanCombineWith(const DataUse& other) const {
- return url == other.url && request_start == other.request_start &&
- first_party_for_cookies == other.first_party_for_cookies &&
- tab_id == other.tab_id && connection_type == other.connection_type &&
- mcc_mnc == other.mcc_mnc;
+ return AreNonByteCountFieldsEqual(*this, other);
}
} // namespace data_usage

Powered by Google App Engine
This is Rietveld 408576698