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

Side by Side Diff: components/data_use_measurement/core/data_use.cc

Issue 2947973002: Support moving pending requests from one DataUseRecorder to another (Closed)
Patch Set: Addressed comments Created 3 years, 5 months 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/data_use_measurement/core/data_use.h" 5 #include "components/data_use_measurement/core/data_use.h"
6 6
7 namespace data_use_measurement { 7 namespace data_use_measurement {
8 8
9 DataUse::DataUse(TrafficType traffic_type) 9 DataUse::DataUse(TrafficType traffic_type)
10 : traffic_type_(traffic_type), 10 : traffic_type_(traffic_type),
11 total_bytes_sent_(0), 11 total_bytes_sent_(0),
12 total_bytes_received_(0) {} 12 total_bytes_received_(0) {}
13 13
14 DataUse::~DataUse() {} 14 DataUse::~DataUse() {}
15 15
16 void DataUse::IncrementTotalBytes(int64_t bytes_received, int64_t bytes_sent) { 16 void DataUse::IncrementTotalBytes(int64_t bytes_received, int64_t bytes_sent) {
17 total_bytes_received_ += bytes_received; 17 total_bytes_received_ += bytes_received;
18 total_bytes_sent_ += bytes_sent; 18 total_bytes_sent_ += bytes_sent;
tbansal1 2017/06/26 21:44:28 DCHECK_LE(0, total_bytes_received_); DCHECK_LE(0,
Raj 2017/06/27 02:30:04 Done
19 } 19 }
20 20
21 void DataUse::MergeFrom(const DataUse& other) {
22 // Traffic type need not be same while merging. One of the data use created
23 // when mainframe is created could have UNKNOWN traffic type, and later merged
24 // with the data use created for its mainframe request which could be
25 // USER_TRAFFIC.
26 total_bytes_sent_ += other.total_bytes_sent_;
27 total_bytes_received_ += other.total_bytes_received_;
28 }
29
30 } // namespace data_use_measurement 21 } // namespace data_use_measurement
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698