OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_reduction_proxy/core/browser/data_reduction_proxy_metr
ics.h" | 5 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_metr
ics.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/prefs/pref_registry_simple.h" | 11 #include "base/prefs/pref_registry_simple.h" |
12 #include "base/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
13 #include "base/prefs/testing_pref_service.h" | 13 #include "base/prefs/testing_pref_service.h" |
14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
15 #include "base/test/test_simple_task_runner.h" | 15 #include "base/test/test_simple_task_runner.h" |
16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 17 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_comp
ression_stats.h" |
17 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
ig_test_utils.h" | 18 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
ig_test_utils.h" |
18 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_stat
istics_prefs.h" | |
19 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_test
_utils.h" | 19 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_test
_utils.h" |
20 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param
s_test_utils.h" | 20 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param
s_test_utils.h" |
21 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_pref_
names.h" | 21 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_pref_
names.h" |
22 #include "net/base/load_flags.h" | 22 #include "net/base/load_flags.h" |
23 #include "net/base/net_log.h" | 23 #include "net/base/net_log.h" |
24 #include "net/proxy/proxy_server.h" | 24 #include "net/proxy/proxy_server.h" |
25 #include "net/proxy/proxy_service.h" | 25 #include "net/proxy/proxy_service.h" |
26 #include "net/socket/socket_test_util.h" | 26 #include "net/socket/socket_test_util.h" |
27 #include "net/url_request/url_request.h" | 27 #include "net/url_request/url_request.h" |
28 #include "net/url_request/url_request_test_util.h" | 28 #include "net/url_request/url_request_test_util.h" |
(...skipping 16 matching lines...) Expand all Loading... |
45 } // namespace | 45 } // namespace |
46 | 46 |
47 namespace data_reduction_proxy { | 47 namespace data_reduction_proxy { |
48 | 48 |
49 // Test UpdateContentLengthPrefs. | 49 // Test UpdateContentLengthPrefs. |
50 class ChromeNetworkDataSavingMetricsTest : public testing::Test { | 50 class ChromeNetworkDataSavingMetricsTest : public testing::Test { |
51 protected: | 51 protected: |
52 ChromeNetworkDataSavingMetricsTest() {} | 52 ChromeNetworkDataSavingMetricsTest() {} |
53 | 53 |
54 void SetUp() override { | 54 void SetUp() override { |
55 statistics_prefs_.reset(new DataReductionProxyStatisticsPrefs( | 55 compression_stats_.reset(new DataReductionProxyCompressionStats( |
56 &pref_service_, | 56 &pref_service_, |
57 scoped_refptr<base::TestSimpleTaskRunner>( | 57 scoped_refptr<base::TestSimpleTaskRunner>( |
58 new base::TestSimpleTaskRunner()), | 58 new base::TestSimpleTaskRunner()), |
59 base::TimeDelta())); | 59 base::TimeDelta())); |
60 PrefRegistrySimple* registry = pref_service_.registry(); | 60 PrefRegistrySimple* registry = pref_service_.registry(); |
61 registry->RegisterInt64Pref( | 61 registry->RegisterInt64Pref( |
62 data_reduction_proxy::prefs::kHttpReceivedContentLength, 0); | 62 data_reduction_proxy::prefs::kHttpReceivedContentLength, 0); |
63 registry->RegisterInt64Pref( | 63 registry->RegisterInt64Pref( |
64 data_reduction_proxy::prefs::kHttpOriginalContentLength, 0); | 64 data_reduction_proxy::prefs::kHttpOriginalContentLength, 0); |
65 | 65 |
(...skipping 26 matching lines...) Expand all Loading... |
92 data_reduction_proxy::prefs:: | 92 data_reduction_proxy::prefs:: |
93 kDailyContentLengthViaDataReductionProxy); | 93 kDailyContentLengthViaDataReductionProxy); |
94 registry->RegisterInt64Pref( | 94 registry->RegisterInt64Pref( |
95 data_reduction_proxy::prefs:: | 95 data_reduction_proxy::prefs:: |
96 kDailyHttpContentLengthLastUpdateDate, 0L); | 96 kDailyHttpContentLengthLastUpdateDate, 0L); |
97 registry->RegisterBooleanPref( | 97 registry->RegisterBooleanPref( |
98 data_reduction_proxy::prefs::kDataReductionProxyEnabled, false); | 98 data_reduction_proxy::prefs::kDataReductionProxyEnabled, false); |
99 } | 99 } |
100 | 100 |
101 TestingPrefServiceSimple pref_service_; | 101 TestingPrefServiceSimple pref_service_; |
102 scoped_ptr<DataReductionProxyStatisticsPrefs> statistics_prefs_; | 102 scoped_ptr<DataReductionProxyCompressionStats> compression_stats_; |
103 }; | 103 }; |
104 | 104 |
105 // The initial last update time used in test. There is no leap second a few | 105 // The initial last update time used in test. There is no leap second a few |
106 // days around this time used in the test. | 106 // days around this time used in the test. |
107 // Note: No time zone is specified. Local time will be assumed by | 107 // Note: No time zone is specified. Local time will be assumed by |
108 // base::Time::FromString below. | 108 // base::Time::FromString below. |
109 const char kLastUpdateTime[] = "Wed, 18 Sep 2013 03:45:26"; | 109 const char kLastUpdateTime[] = "Wed, 18 Sep 2013 03:45:26"; |
110 | 110 |
111 class ChromeNetworkDailyDataSavingMetricsTest | 111 class ChromeNetworkDailyDataSavingMetricsTest |
112 : public ChromeNetworkDataSavingMetricsTest { | 112 : public ChromeNetworkDataSavingMetricsTest { |
(...skipping 19 matching lines...) Expand all Loading... |
132 void SetFakeTimeDeltaInHours(int hours) { | 132 void SetFakeTimeDeltaInHours(int hours) { |
133 now_delta_ = base::TimeDelta::FromHours(hours); | 133 now_delta_ = base::TimeDelta::FromHours(hours); |
134 } | 134 } |
135 | 135 |
136 void AddFakeTimeDeltaInHours(int hours) { | 136 void AddFakeTimeDeltaInHours(int hours) { |
137 now_delta_ += base::TimeDelta::FromHours(hours); | 137 now_delta_ += base::TimeDelta::FromHours(hours); |
138 } | 138 } |
139 | 139 |
140 // Create daily pref list of |kNumDaysInHistory| zero values. | 140 // Create daily pref list of |kNumDaysInHistory| zero values. |
141 void CreatePrefList(const char* pref) { | 141 void CreatePrefList(const char* pref) { |
142 base::ListValue* update = statistics_prefs_->GetList(pref); | 142 base::ListValue* update = compression_stats_->GetList(pref); |
143 update->Clear(); | 143 update->Clear(); |
144 for (size_t i = 0; i < kNumDaysInHistory; ++i) { | 144 for (size_t i = 0; i < kNumDaysInHistory; ++i) { |
145 update->Insert(0, new base::StringValue(base::Int64ToString(0))); | 145 update->Insert(0, new base::StringValue(base::Int64ToString(0))); |
146 } | 146 } |
147 } | 147 } |
148 | 148 |
149 // Verify the pref list values are equal to the given values. | 149 // Verify the pref list values are equal to the given values. |
150 // If the count of values is less than kNumDaysInHistory, zeros are assumed | 150 // If the count of values is less than kNumDaysInHistory, zeros are assumed |
151 // at the beginning. | 151 // at the beginning. |
152 void VerifyPrefList(const char* pref, const int64* values, size_t count) { | 152 void VerifyPrefList(const char* pref, const int64* values, size_t count) { |
153 ASSERT_GE(kNumDaysInHistory, count); | 153 ASSERT_GE(kNumDaysInHistory, count); |
154 base::ListValue* update = statistics_prefs_->GetList(pref); | 154 base::ListValue* update = compression_stats_->GetList(pref); |
155 ASSERT_EQ(kNumDaysInHistory, update->GetSize()) << "Pref: " << pref; | 155 ASSERT_EQ(kNumDaysInHistory, update->GetSize()) << "Pref: " << pref; |
156 | 156 |
157 for (size_t i = 0; i < count; ++i) { | 157 for (size_t i = 0; i < count; ++i) { |
158 EXPECT_EQ( | 158 EXPECT_EQ( |
159 values[i], | 159 values[i], |
160 GetListPrefInt64Value(*update, kNumDaysInHistory - count + i)) | 160 GetListPrefInt64Value(*update, kNumDaysInHistory - count + i)) |
161 << "index=" << (kNumDaysInHistory - count + i); | 161 << "index=" << (kNumDaysInHistory - count + i); |
162 } | 162 } |
163 for (size_t i = 0; i < kNumDaysInHistory - count; ++i) { | 163 for (size_t i = 0; i < kNumDaysInHistory - count; ++i) { |
164 EXPECT_EQ(0, GetListPrefInt64Value(*update, i)) << "index=" << i; | 164 EXPECT_EQ(0, GetListPrefInt64Value(*update, i)) << "index=" << i; |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 | 262 |
263 TEST_F(ChromeNetworkDailyDataSavingMetricsTest, OneResponse) { | 263 TEST_F(ChromeNetworkDailyDataSavingMetricsTest, OneResponse) { |
264 const int64 kOriginalLength = 200; | 264 const int64 kOriginalLength = 200; |
265 const int64 kReceivedLength = 100; | 265 const int64 kReceivedLength = 100; |
266 int64 original[] = {kOriginalLength}; | 266 int64 original[] = {kOriginalLength}; |
267 int64 received[] = {kReceivedLength}; | 267 int64 received[] = {kReceivedLength}; |
268 | 268 |
269 UpdateContentLengthPrefsForDataReductionProxy( | 269 UpdateContentLengthPrefsForDataReductionProxy( |
270 kReceivedLength, kOriginalLength, | 270 kReceivedLength, kOriginalLength, |
271 true, VIA_DATA_REDUCTION_PROXY, | 271 true, VIA_DATA_REDUCTION_PROXY, |
272 FakeNow(), statistics_prefs_.get()); | 272 FakeNow(), compression_stats_.get()); |
273 VerifyDailyDataSavingContentLengthPrefLists( | 273 VerifyDailyDataSavingContentLengthPrefLists( |
274 original, 1, received, 1, | 274 original, 1, received, 1, |
275 original, 1, received, 1, | 275 original, 1, received, 1, |
276 original, 1, received, 1); | 276 original, 1, received, 1); |
277 } | 277 } |
278 | 278 |
279 TEST_F(ChromeNetworkDailyDataSavingMetricsTest, MultipleResponses) { | 279 TEST_F(ChromeNetworkDailyDataSavingMetricsTest, MultipleResponses) { |
280 const int64 kOriginalLength = 150; | 280 const int64 kOriginalLength = 150; |
281 const int64 kReceivedLength = 100; | 281 const int64 kReceivedLength = 100; |
282 int64 original[] = {kOriginalLength}; | 282 int64 original[] = {kOriginalLength}; |
283 int64 received[] = {kReceivedLength}; | 283 int64 received[] = {kReceivedLength}; |
284 UpdateContentLengthPrefsForDataReductionProxy( | 284 UpdateContentLengthPrefsForDataReductionProxy( |
285 kReceivedLength, kOriginalLength, | 285 kReceivedLength, kOriginalLength, |
286 false, UNKNOWN_TYPE, | 286 false, UNKNOWN_TYPE, |
287 FakeNow(), statistics_prefs_.get()); | 287 FakeNow(), compression_stats_.get()); |
288 VerifyDailyDataSavingContentLengthPrefLists( | 288 VerifyDailyDataSavingContentLengthPrefLists( |
289 original, 1, received, 1, | 289 original, 1, received, 1, |
290 NULL, 0, NULL, 0, NULL, 0, NULL, 0); | 290 NULL, 0, NULL, 0, NULL, 0, NULL, 0); |
291 | 291 |
292 UpdateContentLengthPrefsForDataReductionProxy( | 292 UpdateContentLengthPrefsForDataReductionProxy( |
293 kReceivedLength, kOriginalLength, | 293 kReceivedLength, kOriginalLength, |
294 true, UNKNOWN_TYPE, | 294 true, UNKNOWN_TYPE, |
295 FakeNow(), statistics_prefs_.get()); | 295 FakeNow(), compression_stats_.get()); |
296 original[0] += kOriginalLength; | 296 original[0] += kOriginalLength; |
297 received[0] += kReceivedLength; | 297 received[0] += kReceivedLength; |
298 int64 original_proxy_enabled[] = {kOriginalLength}; | 298 int64 original_proxy_enabled[] = {kOriginalLength}; |
299 int64 received_proxy_enabled[] = {kReceivedLength}; | 299 int64 received_proxy_enabled[] = {kReceivedLength}; |
300 VerifyDailyDataSavingContentLengthPrefLists( | 300 VerifyDailyDataSavingContentLengthPrefLists( |
301 original, 1, received, 1, | 301 original, 1, received, 1, |
302 original_proxy_enabled, 1, received_proxy_enabled, 1, | 302 original_proxy_enabled, 1, received_proxy_enabled, 1, |
303 NULL, 0, NULL, 0); | 303 NULL, 0, NULL, 0); |
304 | 304 |
305 UpdateContentLengthPrefsForDataReductionProxy( | 305 UpdateContentLengthPrefsForDataReductionProxy( |
306 kReceivedLength, kOriginalLength, | 306 kReceivedLength, kOriginalLength, |
307 true, VIA_DATA_REDUCTION_PROXY, | 307 true, VIA_DATA_REDUCTION_PROXY, |
308 FakeNow(), statistics_prefs_.get()); | 308 FakeNow(), compression_stats_.get()); |
309 original[0] += kOriginalLength; | 309 original[0] += kOriginalLength; |
310 received[0] += kReceivedLength; | 310 received[0] += kReceivedLength; |
311 original_proxy_enabled[0] += kOriginalLength; | 311 original_proxy_enabled[0] += kOriginalLength; |
312 received_proxy_enabled[0] += kReceivedLength; | 312 received_proxy_enabled[0] += kReceivedLength; |
313 int64 original_via_proxy[] = {kOriginalLength}; | 313 int64 original_via_proxy[] = {kOriginalLength}; |
314 int64 received_via_proxy[] = {kReceivedLength}; | 314 int64 received_via_proxy[] = {kReceivedLength}; |
315 VerifyDailyDataSavingContentLengthPrefLists( | 315 VerifyDailyDataSavingContentLengthPrefLists( |
316 original, 1, received, 1, | 316 original, 1, received, 1, |
317 original_proxy_enabled, 1, received_proxy_enabled, 1, | 317 original_proxy_enabled, 1, received_proxy_enabled, 1, |
318 original_via_proxy, 1, received_via_proxy, 1); | 318 original_via_proxy, 1, received_via_proxy, 1); |
319 | 319 |
320 UpdateContentLengthPrefsForDataReductionProxy( | 320 UpdateContentLengthPrefsForDataReductionProxy( |
321 kReceivedLength, kOriginalLength, | 321 kReceivedLength, kOriginalLength, |
322 true, UNKNOWN_TYPE, FakeNow(), statistics_prefs_.get()); | 322 true, UNKNOWN_TYPE, FakeNow(), compression_stats_.get()); |
323 original[0] += kOriginalLength; | 323 original[0] += kOriginalLength; |
324 received[0] += kReceivedLength; | 324 received[0] += kReceivedLength; |
325 original_proxy_enabled[0] += kOriginalLength; | 325 original_proxy_enabled[0] += kOriginalLength; |
326 received_proxy_enabled[0] += kReceivedLength; | 326 received_proxy_enabled[0] += kReceivedLength; |
327 VerifyDailyDataSavingContentLengthPrefLists( | 327 VerifyDailyDataSavingContentLengthPrefLists( |
328 original, 1, received, 1, | 328 original, 1, received, 1, |
329 original_proxy_enabled, 1, received_proxy_enabled, 1, | 329 original_proxy_enabled, 1, received_proxy_enabled, 1, |
330 original_via_proxy, 1, received_via_proxy, 1); | 330 original_via_proxy, 1, received_via_proxy, 1); |
331 | 331 |
332 UpdateContentLengthPrefsForDataReductionProxy( | 332 UpdateContentLengthPrefsForDataReductionProxy( |
333 kReceivedLength, kOriginalLength, | 333 kReceivedLength, kOriginalLength, |
334 false, UNKNOWN_TYPE, FakeNow(), statistics_prefs_.get()); | 334 false, UNKNOWN_TYPE, FakeNow(), compression_stats_.get()); |
335 original[0] += kOriginalLength; | 335 original[0] += kOriginalLength; |
336 received[0] += kReceivedLength; | 336 received[0] += kReceivedLength; |
337 VerifyDailyDataSavingContentLengthPrefLists( | 337 VerifyDailyDataSavingContentLengthPrefLists( |
338 original, 1, received, 1, | 338 original, 1, received, 1, |
339 original_proxy_enabled, 1, received_proxy_enabled, 1, | 339 original_proxy_enabled, 1, received_proxy_enabled, 1, |
340 original_via_proxy, 1, received_via_proxy, 1); | 340 original_via_proxy, 1, received_via_proxy, 1); |
341 } | 341 } |
342 | 342 |
343 TEST_F(ChromeNetworkDailyDataSavingMetricsTest, RequestType) { | 343 TEST_F(ChromeNetworkDailyDataSavingMetricsTest, RequestType) { |
344 const int64 kContentLength = 200; | 344 const int64 kContentLength = 200; |
345 int64 received[] = {0}; | 345 int64 received[] = {0}; |
346 int64 https_received[] = {0}; | 346 int64 https_received[] = {0}; |
347 int64 total_received[] = {0}; | 347 int64 total_received[] = {0}; |
348 int64 proxy_enabled_received[] = {0}; | 348 int64 proxy_enabled_received[] = {0}; |
349 | 349 |
350 UpdateContentLengthPrefsForDataReductionProxy( | 350 UpdateContentLengthPrefsForDataReductionProxy( |
351 kContentLength, kContentLength, | 351 kContentLength, kContentLength, |
352 true, HTTPS, | 352 true, HTTPS, |
353 FakeNow(), statistics_prefs_.get()); | 353 FakeNow(), compression_stats_.get()); |
354 total_received[0] += kContentLength; | 354 total_received[0] += kContentLength; |
355 proxy_enabled_received[0] += kContentLength; | 355 proxy_enabled_received[0] += kContentLength; |
356 https_received[0] += kContentLength; | 356 https_received[0] += kContentLength; |
357 VerifyDailyRequestTypeContentLengthPrefLists( | 357 VerifyDailyRequestTypeContentLengthPrefLists( |
358 total_received, 1, total_received, 1, | 358 total_received, 1, total_received, 1, |
359 proxy_enabled_received, 1, proxy_enabled_received, 1, | 359 proxy_enabled_received, 1, proxy_enabled_received, 1, |
360 https_received, 1, | 360 https_received, 1, |
361 received, 0, // short bypass | 361 received, 0, // short bypass |
362 received, 0, // long bypass | 362 received, 0, // long bypass |
363 received, 0); // unknown | 363 received, 0); // unknown |
364 | 364 |
365 // Data reduction proxy is not enabled. | 365 // Data reduction proxy is not enabled. |
366 UpdateContentLengthPrefsForDataReductionProxy( | 366 UpdateContentLengthPrefsForDataReductionProxy( |
367 kContentLength, kContentLength, | 367 kContentLength, kContentLength, |
368 false, HTTPS, | 368 false, HTTPS, |
369 FakeNow(), statistics_prefs_.get()); | 369 FakeNow(), compression_stats_.get()); |
370 total_received[0] += kContentLength; | 370 total_received[0] += kContentLength; |
371 VerifyDailyRequestTypeContentLengthPrefLists( | 371 VerifyDailyRequestTypeContentLengthPrefLists( |
372 total_received, 1, total_received, 1, | 372 total_received, 1, total_received, 1, |
373 proxy_enabled_received, 1, proxy_enabled_received, 1, | 373 proxy_enabled_received, 1, proxy_enabled_received, 1, |
374 https_received, 1, | 374 https_received, 1, |
375 received, 0, // short bypass | 375 received, 0, // short bypass |
376 received, 0, // long bypass | 376 received, 0, // long bypass |
377 received, 0); // unknown | 377 received, 0); // unknown |
378 | 378 |
379 UpdateContentLengthPrefsForDataReductionProxy( | 379 UpdateContentLengthPrefsForDataReductionProxy( |
380 kContentLength, kContentLength, | 380 kContentLength, kContentLength, |
381 true, HTTPS, | 381 true, HTTPS, |
382 FakeNow(), statistics_prefs_.get()); | 382 FakeNow(), compression_stats_.get()); |
383 total_received[0] += kContentLength; | 383 total_received[0] += kContentLength; |
384 proxy_enabled_received[0] += kContentLength; | 384 proxy_enabled_received[0] += kContentLength; |
385 https_received[0] += kContentLength; | 385 https_received[0] += kContentLength; |
386 VerifyDailyRequestTypeContentLengthPrefLists( | 386 VerifyDailyRequestTypeContentLengthPrefLists( |
387 total_received, 1, total_received, 1, | 387 total_received, 1, total_received, 1, |
388 proxy_enabled_received, 1, proxy_enabled_received, 1, | 388 proxy_enabled_received, 1, proxy_enabled_received, 1, |
389 https_received, 1, | 389 https_received, 1, |
390 received, 0, // short bypass | 390 received, 0, // short bypass |
391 received, 0, // long bypass | 391 received, 0, // long bypass |
392 received, 0); // unknown | 392 received, 0); // unknown |
393 | 393 |
394 UpdateContentLengthPrefsForDataReductionProxy( | 394 UpdateContentLengthPrefsForDataReductionProxy( |
395 kContentLength, kContentLength, | 395 kContentLength, kContentLength, |
396 true, SHORT_BYPASS, | 396 true, SHORT_BYPASS, |
397 FakeNow(), statistics_prefs_.get()); | 397 FakeNow(), compression_stats_.get()); |
398 total_received[0] += kContentLength; | 398 total_received[0] += kContentLength; |
399 proxy_enabled_received[0] += kContentLength; | 399 proxy_enabled_received[0] += kContentLength; |
400 received[0] += kContentLength; | 400 received[0] += kContentLength; |
401 VerifyDailyRequestTypeContentLengthPrefLists( | 401 VerifyDailyRequestTypeContentLengthPrefLists( |
402 total_received, 1, total_received, 1, | 402 total_received, 1, total_received, 1, |
403 proxy_enabled_received, 1, proxy_enabled_received, 1, | 403 proxy_enabled_received, 1, proxy_enabled_received, 1, |
404 https_received, 1, | 404 https_received, 1, |
405 received, 1, // short bypass | 405 received, 1, // short bypass |
406 received, 0, // long bypass | 406 received, 0, // long bypass |
407 received, 0); // unknown | 407 received, 0); // unknown |
408 | 408 |
409 UpdateContentLengthPrefsForDataReductionProxy( | 409 UpdateContentLengthPrefsForDataReductionProxy( |
410 kContentLength, kContentLength, | 410 kContentLength, kContentLength, |
411 true, LONG_BYPASS, | 411 true, LONG_BYPASS, |
412 FakeNow(), statistics_prefs_.get()); | 412 FakeNow(), compression_stats_.get()); |
413 total_received[0] += kContentLength; | 413 total_received[0] += kContentLength; |
414 proxy_enabled_received[0] += kContentLength; | 414 proxy_enabled_received[0] += kContentLength; |
415 VerifyDailyRequestTypeContentLengthPrefLists( | 415 VerifyDailyRequestTypeContentLengthPrefLists( |
416 total_received, 1, total_received, 1, // total | 416 total_received, 1, total_received, 1, // total |
417 proxy_enabled_received, 1, proxy_enabled_received, 1, | 417 proxy_enabled_received, 1, proxy_enabled_received, 1, |
418 https_received, 1, | 418 https_received, 1, |
419 received, 1, // short bypass | 419 received, 1, // short bypass |
420 received, 1, // long bypass | 420 received, 1, // long bypass |
421 received, 0); // unknown | 421 received, 0); // unknown |
422 | 422 |
423 UpdateContentLengthPrefsForDataReductionProxy( | 423 UpdateContentLengthPrefsForDataReductionProxy( |
424 kContentLength, kContentLength, | 424 kContentLength, kContentLength, |
425 true, UNKNOWN_TYPE, | 425 true, UNKNOWN_TYPE, |
426 FakeNow(), statistics_prefs_.get()); | 426 FakeNow(), compression_stats_.get()); |
427 total_received[0] += kContentLength; | 427 total_received[0] += kContentLength; |
428 proxy_enabled_received[0] += kContentLength; | 428 proxy_enabled_received[0] += kContentLength; |
429 VerifyDailyRequestTypeContentLengthPrefLists( | 429 VerifyDailyRequestTypeContentLengthPrefLists( |
430 total_received, 1, total_received, 1, | 430 total_received, 1, total_received, 1, |
431 proxy_enabled_received, 1, proxy_enabled_received, 1, | 431 proxy_enabled_received, 1, proxy_enabled_received, 1, |
432 https_received, 1, | 432 https_received, 1, |
433 received, 1, // short bypass | 433 received, 1, // short bypass |
434 received, 1, // long bypass | 434 received, 1, // long bypass |
435 received, 1); // unknown | 435 received, 1); // unknown |
436 } | 436 } |
437 | 437 |
438 TEST_F(ChromeNetworkDailyDataSavingMetricsTest, ForwardOneDay) { | 438 TEST_F(ChromeNetworkDailyDataSavingMetricsTest, ForwardOneDay) { |
439 const int64 kOriginalLength = 200; | 439 const int64 kOriginalLength = 200; |
440 const int64 kReceivedLength = 100; | 440 const int64 kReceivedLength = 100; |
441 | 441 |
442 UpdateContentLengthPrefsForDataReductionProxy( | 442 UpdateContentLengthPrefsForDataReductionProxy( |
443 kReceivedLength, kOriginalLength, | 443 kReceivedLength, kOriginalLength, |
444 true, VIA_DATA_REDUCTION_PROXY, | 444 true, VIA_DATA_REDUCTION_PROXY, |
445 FakeNow(), statistics_prefs_.get()); | 445 FakeNow(), compression_stats_.get()); |
446 | 446 |
447 // Forward one day. | 447 // Forward one day. |
448 SetFakeTimeDeltaInHours(24); | 448 SetFakeTimeDeltaInHours(24); |
449 | 449 |
450 // Proxy not enabled. Not via proxy. | 450 // Proxy not enabled. Not via proxy. |
451 UpdateContentLengthPrefsForDataReductionProxy( | 451 UpdateContentLengthPrefsForDataReductionProxy( |
452 kReceivedLength, kOriginalLength, | 452 kReceivedLength, kOriginalLength, |
453 false, UNKNOWN_TYPE, FakeNow(), statistics_prefs_.get()); | 453 false, UNKNOWN_TYPE, FakeNow(), compression_stats_.get()); |
454 | 454 |
455 int64 original[] = {kOriginalLength, kOriginalLength}; | 455 int64 original[] = {kOriginalLength, kOriginalLength}; |
456 int64 received[] = {kReceivedLength, kReceivedLength}; | 456 int64 received[] = {kReceivedLength, kReceivedLength}; |
457 int64 original_with_data_reduction_proxy_enabled[] = {kOriginalLength, 0}; | 457 int64 original_with_data_reduction_proxy_enabled[] = {kOriginalLength, 0}; |
458 int64 received_with_data_reduction_proxy_enabled[] = {kReceivedLength, 0}; | 458 int64 received_with_data_reduction_proxy_enabled[] = {kReceivedLength, 0}; |
459 int64 original_via_data_reduction_proxy[] = {kOriginalLength, 0}; | 459 int64 original_via_data_reduction_proxy[] = {kOriginalLength, 0}; |
460 int64 received_via_data_reduction_proxy[] = {kReceivedLength, 0}; | 460 int64 received_via_data_reduction_proxy[] = {kReceivedLength, 0}; |
461 VerifyDailyDataSavingContentLengthPrefLists( | 461 VerifyDailyDataSavingContentLengthPrefLists( |
462 original, 2, | 462 original, 2, |
463 received, 2, | 463 received, 2, |
464 original_with_data_reduction_proxy_enabled, 2, | 464 original_with_data_reduction_proxy_enabled, 2, |
465 received_with_data_reduction_proxy_enabled, 2, | 465 received_with_data_reduction_proxy_enabled, 2, |
466 original_via_data_reduction_proxy, 2, | 466 original_via_data_reduction_proxy, 2, |
467 received_via_data_reduction_proxy, 2); | 467 received_via_data_reduction_proxy, 2); |
468 | 468 |
469 // Proxy enabled. Not via proxy. | 469 // Proxy enabled. Not via proxy. |
470 UpdateContentLengthPrefsForDataReductionProxy( | 470 UpdateContentLengthPrefsForDataReductionProxy( |
471 kReceivedLength, kOriginalLength, | 471 kReceivedLength, kOriginalLength, |
472 true, UNKNOWN_TYPE, FakeNow(), statistics_prefs_.get()); | 472 true, UNKNOWN_TYPE, FakeNow(), compression_stats_.get()); |
473 original[1] += kOriginalLength; | 473 original[1] += kOriginalLength; |
474 received[1] += kReceivedLength; | 474 received[1] += kReceivedLength; |
475 original_with_data_reduction_proxy_enabled[1] += kOriginalLength; | 475 original_with_data_reduction_proxy_enabled[1] += kOriginalLength; |
476 received_with_data_reduction_proxy_enabled[1] += kReceivedLength; | 476 received_with_data_reduction_proxy_enabled[1] += kReceivedLength; |
477 VerifyDailyDataSavingContentLengthPrefLists( | 477 VerifyDailyDataSavingContentLengthPrefLists( |
478 original, 2, | 478 original, 2, |
479 received, 2, | 479 received, 2, |
480 original_with_data_reduction_proxy_enabled, 2, | 480 original_with_data_reduction_proxy_enabled, 2, |
481 received_with_data_reduction_proxy_enabled, 2, | 481 received_with_data_reduction_proxy_enabled, 2, |
482 original_via_data_reduction_proxy, 2, | 482 original_via_data_reduction_proxy, 2, |
483 received_via_data_reduction_proxy, 2); | 483 received_via_data_reduction_proxy, 2); |
484 | 484 |
485 // Proxy enabled and via proxy. | 485 // Proxy enabled and via proxy. |
486 UpdateContentLengthPrefsForDataReductionProxy( | 486 UpdateContentLengthPrefsForDataReductionProxy( |
487 kReceivedLength, kOriginalLength, | 487 kReceivedLength, kOriginalLength, |
488 true, VIA_DATA_REDUCTION_PROXY, | 488 true, VIA_DATA_REDUCTION_PROXY, |
489 FakeNow(), statistics_prefs_.get()); | 489 FakeNow(), compression_stats_.get()); |
490 original[1] += kOriginalLength; | 490 original[1] += kOriginalLength; |
491 received[1] += kReceivedLength; | 491 received[1] += kReceivedLength; |
492 original_with_data_reduction_proxy_enabled[1] += kOriginalLength; | 492 original_with_data_reduction_proxy_enabled[1] += kOriginalLength; |
493 received_with_data_reduction_proxy_enabled[1] += kReceivedLength; | 493 received_with_data_reduction_proxy_enabled[1] += kReceivedLength; |
494 original_via_data_reduction_proxy[1] += kOriginalLength; | 494 original_via_data_reduction_proxy[1] += kOriginalLength; |
495 received_via_data_reduction_proxy[1] += kReceivedLength; | 495 received_via_data_reduction_proxy[1] += kReceivedLength; |
496 VerifyDailyDataSavingContentLengthPrefLists( | 496 VerifyDailyDataSavingContentLengthPrefLists( |
497 original, 2, | 497 original, 2, |
498 received, 2, | 498 received, 2, |
499 original_with_data_reduction_proxy_enabled, 2, | 499 original_with_data_reduction_proxy_enabled, 2, |
500 received_with_data_reduction_proxy_enabled, 2, | 500 received_with_data_reduction_proxy_enabled, 2, |
501 original_via_data_reduction_proxy, 2, | 501 original_via_data_reduction_proxy, 2, |
502 received_via_data_reduction_proxy, 2); | 502 received_via_data_reduction_proxy, 2); |
503 } | 503 } |
504 | 504 |
505 TEST_F(ChromeNetworkDailyDataSavingMetricsTest, PartialDayTimeChange) { | 505 TEST_F(ChromeNetworkDailyDataSavingMetricsTest, PartialDayTimeChange) { |
506 const int64 kOriginalLength = 200; | 506 const int64 kOriginalLength = 200; |
507 const int64 kReceivedLength = 100; | 507 const int64 kReceivedLength = 100; |
508 int64 original[] = {0, kOriginalLength}; | 508 int64 original[] = {0, kOriginalLength}; |
509 int64 received[] = {0, kReceivedLength}; | 509 int64 received[] = {0, kReceivedLength}; |
510 | 510 |
511 UpdateContentLengthPrefsForDataReductionProxy( | 511 UpdateContentLengthPrefsForDataReductionProxy( |
512 kReceivedLength, kOriginalLength, | 512 kReceivedLength, kOriginalLength, |
513 true, VIA_DATA_REDUCTION_PROXY, | 513 true, VIA_DATA_REDUCTION_PROXY, |
514 FakeNow(), statistics_prefs_.get()); | 514 FakeNow(), compression_stats_.get()); |
515 VerifyDailyDataSavingContentLengthPrefLists( | 515 VerifyDailyDataSavingContentLengthPrefLists( |
516 original, 2, received, 2, | 516 original, 2, received, 2, |
517 original, 2, received, 2, | 517 original, 2, received, 2, |
518 original, 2, received, 2); | 518 original, 2, received, 2); |
519 | 519 |
520 // Forward 10 hours, stay in the same day. | 520 // Forward 10 hours, stay in the same day. |
521 // See kLastUpdateTime: "Now" in test is 03:45am. | 521 // See kLastUpdateTime: "Now" in test is 03:45am. |
522 SetFakeTimeDeltaInHours(10); | 522 SetFakeTimeDeltaInHours(10); |
523 UpdateContentLengthPrefsForDataReductionProxy( | 523 UpdateContentLengthPrefsForDataReductionProxy( |
524 kReceivedLength, kOriginalLength, | 524 kReceivedLength, kOriginalLength, |
525 true, VIA_DATA_REDUCTION_PROXY, | 525 true, VIA_DATA_REDUCTION_PROXY, |
526 FakeNow(), statistics_prefs_.get()); | 526 FakeNow(), compression_stats_.get()); |
527 original[1] += kOriginalLength; | 527 original[1] += kOriginalLength; |
528 received[1] += kReceivedLength; | 528 received[1] += kReceivedLength; |
529 VerifyDailyDataSavingContentLengthPrefLists( | 529 VerifyDailyDataSavingContentLengthPrefLists( |
530 original, 2, received, 2, | 530 original, 2, received, 2, |
531 original, 2, received, 2, | 531 original, 2, received, 2, |
532 original, 2, received, 2); | 532 original, 2, received, 2); |
533 | 533 |
534 // Forward 11 more hours, comes to tomorrow. | 534 // Forward 11 more hours, comes to tomorrow. |
535 AddFakeTimeDeltaInHours(11); | 535 AddFakeTimeDeltaInHours(11); |
536 UpdateContentLengthPrefsForDataReductionProxy( | 536 UpdateContentLengthPrefsForDataReductionProxy( |
537 kReceivedLength, kOriginalLength, | 537 kReceivedLength, kOriginalLength, |
538 true, VIA_DATA_REDUCTION_PROXY, | 538 true, VIA_DATA_REDUCTION_PROXY, |
539 FakeNow(), statistics_prefs_.get()); | 539 FakeNow(), compression_stats_.get()); |
540 int64 original2[] = {kOriginalLength * 2, kOriginalLength}; | 540 int64 original2[] = {kOriginalLength * 2, kOriginalLength}; |
541 int64 received2[] = {kReceivedLength * 2, kReceivedLength}; | 541 int64 received2[] = {kReceivedLength * 2, kReceivedLength}; |
542 VerifyDailyDataSavingContentLengthPrefLists( | 542 VerifyDailyDataSavingContentLengthPrefLists( |
543 original2, 2, received2, 2, | 543 original2, 2, received2, 2, |
544 original2, 2, received2, 2, | 544 original2, 2, received2, 2, |
545 original2, 2, received2, 2); | 545 original2, 2, received2, 2); |
546 } | 546 } |
547 | 547 |
548 TEST_F(ChromeNetworkDailyDataSavingMetricsTest, ForwardMultipleDays) { | 548 TEST_F(ChromeNetworkDailyDataSavingMetricsTest, ForwardMultipleDays) { |
549 const int64 kOriginalLength = 200; | 549 const int64 kOriginalLength = 200; |
550 const int64 kReceivedLength = 100; | 550 const int64 kReceivedLength = 100; |
551 UpdateContentLengthPrefsForDataReductionProxy( | 551 UpdateContentLengthPrefsForDataReductionProxy( |
552 kReceivedLength, kOriginalLength, | 552 kReceivedLength, kOriginalLength, |
553 true, VIA_DATA_REDUCTION_PROXY, | 553 true, VIA_DATA_REDUCTION_PROXY, |
554 FakeNow(), statistics_prefs_.get()); | 554 FakeNow(), compression_stats_.get()); |
555 | 555 |
556 // Forward three days. | 556 // Forward three days. |
557 SetFakeTimeDeltaInHours(3 * 24); | 557 SetFakeTimeDeltaInHours(3 * 24); |
558 | 558 |
559 UpdateContentLengthPrefsForDataReductionProxy( | 559 UpdateContentLengthPrefsForDataReductionProxy( |
560 kReceivedLength, kOriginalLength, | 560 kReceivedLength, kOriginalLength, |
561 true, VIA_DATA_REDUCTION_PROXY, | 561 true, VIA_DATA_REDUCTION_PROXY, |
562 FakeNow(), statistics_prefs_.get()); | 562 FakeNow(), compression_stats_.get()); |
563 | 563 |
564 int64 original[] = {kOriginalLength, 0, 0, kOriginalLength}; | 564 int64 original[] = {kOriginalLength, 0, 0, kOriginalLength}; |
565 int64 received[] = {kReceivedLength, 0, 0, kReceivedLength}; | 565 int64 received[] = {kReceivedLength, 0, 0, kReceivedLength}; |
566 VerifyDailyDataSavingContentLengthPrefLists( | 566 VerifyDailyDataSavingContentLengthPrefLists( |
567 original, 4, received, 4, | 567 original, 4, received, 4, |
568 original, 4, received, 4, | 568 original, 4, received, 4, |
569 original, 4, received, 4); | 569 original, 4, received, 4); |
570 | 570 |
571 // Forward four more days. | 571 // Forward four more days. |
572 AddFakeTimeDeltaInHours(4 * 24); | 572 AddFakeTimeDeltaInHours(4 * 24); |
573 UpdateContentLengthPrefsForDataReductionProxy( | 573 UpdateContentLengthPrefsForDataReductionProxy( |
574 kReceivedLength, kOriginalLength, | 574 kReceivedLength, kOriginalLength, |
575 true, VIA_DATA_REDUCTION_PROXY, | 575 true, VIA_DATA_REDUCTION_PROXY, |
576 FakeNow(), statistics_prefs_.get()); | 576 FakeNow(), compression_stats_.get()); |
577 int64 original2[] = { | 577 int64 original2[] = { |
578 kOriginalLength, 0, 0, kOriginalLength, 0, 0, 0, kOriginalLength, | 578 kOriginalLength, 0, 0, kOriginalLength, 0, 0, 0, kOriginalLength, |
579 }; | 579 }; |
580 int64 received2[] = { | 580 int64 received2[] = { |
581 kReceivedLength, 0, 0, kReceivedLength, 0, 0, 0, kReceivedLength, | 581 kReceivedLength, 0, 0, kReceivedLength, 0, 0, 0, kReceivedLength, |
582 }; | 582 }; |
583 VerifyDailyDataSavingContentLengthPrefLists( | 583 VerifyDailyDataSavingContentLengthPrefLists( |
584 original2, 8, received2, 8, | 584 original2, 8, received2, 8, |
585 original2, 8, received2, 8, | 585 original2, 8, received2, 8, |
586 original2, 8, received2, 8); | 586 original2, 8, received2, 8); |
587 | 587 |
588 // Forward |kNumDaysInHistory| more days. | 588 // Forward |kNumDaysInHistory| more days. |
589 AddFakeTimeDeltaInHours(kNumDaysInHistory * 24); | 589 AddFakeTimeDeltaInHours(kNumDaysInHistory * 24); |
590 UpdateContentLengthPrefsForDataReductionProxy( | 590 UpdateContentLengthPrefsForDataReductionProxy( |
591 kReceivedLength, kOriginalLength, | 591 kReceivedLength, kOriginalLength, |
592 true, VIA_DATA_REDUCTION_PROXY, | 592 true, VIA_DATA_REDUCTION_PROXY, |
593 FakeNow(), statistics_prefs_.get()); | 593 FakeNow(), compression_stats_.get()); |
594 int64 original3[] = {kOriginalLength}; | 594 int64 original3[] = {kOriginalLength}; |
595 int64 received3[] = {kReceivedLength}; | 595 int64 received3[] = {kReceivedLength}; |
596 VerifyDailyDataSavingContentLengthPrefLists( | 596 VerifyDailyDataSavingContentLengthPrefLists( |
597 original3, 1, received3, 1, | 597 original3, 1, received3, 1, |
598 original3, 1, received3, 1, | 598 original3, 1, received3, 1, |
599 original3, 1, received3, 1); | 599 original3, 1, received3, 1); |
600 | 600 |
601 // Forward |kNumDaysInHistory| + 1 more days. | 601 // Forward |kNumDaysInHistory| + 1 more days. |
602 AddFakeTimeDeltaInHours((kNumDaysInHistory + 1)* 24); | 602 AddFakeTimeDeltaInHours((kNumDaysInHistory + 1)* 24); |
603 UpdateContentLengthPrefsForDataReductionProxy( | 603 UpdateContentLengthPrefsForDataReductionProxy( |
604 kReceivedLength, kOriginalLength, | 604 kReceivedLength, kOriginalLength, |
605 true, VIA_DATA_REDUCTION_PROXY, | 605 true, VIA_DATA_REDUCTION_PROXY, |
606 FakeNow(), statistics_prefs_.get()); | 606 FakeNow(), compression_stats_.get()); |
607 VerifyDailyDataSavingContentLengthPrefLists( | 607 VerifyDailyDataSavingContentLengthPrefLists( |
608 original3, 1, received3, 1, | 608 original3, 1, received3, 1, |
609 original3, 1, received3, 1, | 609 original3, 1, received3, 1, |
610 original3, 1, received3, 1); | 610 original3, 1, received3, 1); |
611 } | 611 } |
612 | 612 |
613 TEST_F(ChromeNetworkDailyDataSavingMetricsTest, BackwardAndForwardOneDay) { | 613 TEST_F(ChromeNetworkDailyDataSavingMetricsTest, BackwardAndForwardOneDay) { |
614 const int64 kOriginalLength = 200; | 614 const int64 kOriginalLength = 200; |
615 const int64 kReceivedLength = 100; | 615 const int64 kReceivedLength = 100; |
616 int64 original[] = {kOriginalLength}; | 616 int64 original[] = {kOriginalLength}; |
617 int64 received[] = {kReceivedLength}; | 617 int64 received[] = {kReceivedLength}; |
618 | 618 |
619 UpdateContentLengthPrefsForDataReductionProxy( | 619 UpdateContentLengthPrefsForDataReductionProxy( |
620 kReceivedLength, kOriginalLength, | 620 kReceivedLength, kOriginalLength, |
621 true, VIA_DATA_REDUCTION_PROXY, | 621 true, VIA_DATA_REDUCTION_PROXY, |
622 FakeNow(), statistics_prefs_.get()); | 622 FakeNow(), compression_stats_.get()); |
623 | 623 |
624 // Backward one day. | 624 // Backward one day. |
625 SetFakeTimeDeltaInHours(-24); | 625 SetFakeTimeDeltaInHours(-24); |
626 UpdateContentLengthPrefsForDataReductionProxy( | 626 UpdateContentLengthPrefsForDataReductionProxy( |
627 kReceivedLength, kOriginalLength, | 627 kReceivedLength, kOriginalLength, |
628 true, VIA_DATA_REDUCTION_PROXY, | 628 true, VIA_DATA_REDUCTION_PROXY, |
629 FakeNow(), statistics_prefs_.get()); | 629 FakeNow(), compression_stats_.get()); |
630 original[0] += kOriginalLength; | 630 original[0] += kOriginalLength; |
631 received[0] += kReceivedLength; | 631 received[0] += kReceivedLength; |
632 VerifyDailyDataSavingContentLengthPrefLists( | 632 VerifyDailyDataSavingContentLengthPrefLists( |
633 original, 1, received, 1, | 633 original, 1, received, 1, |
634 original, 1, received, 1, | 634 original, 1, received, 1, |
635 original, 1, received, 1); | 635 original, 1, received, 1); |
636 | 636 |
637 // Then, Forward one day | 637 // Then, Forward one day |
638 AddFakeTimeDeltaInHours(24); | 638 AddFakeTimeDeltaInHours(24); |
639 UpdateContentLengthPrefsForDataReductionProxy( | 639 UpdateContentLengthPrefsForDataReductionProxy( |
640 kReceivedLength, kOriginalLength, | 640 kReceivedLength, kOriginalLength, |
641 true, VIA_DATA_REDUCTION_PROXY, | 641 true, VIA_DATA_REDUCTION_PROXY, |
642 FakeNow(), statistics_prefs_.get()); | 642 FakeNow(), compression_stats_.get()); |
643 int64 original2[] = {kOriginalLength * 2, kOriginalLength}; | 643 int64 original2[] = {kOriginalLength * 2, kOriginalLength}; |
644 int64 received2[] = {kReceivedLength * 2, kReceivedLength}; | 644 int64 received2[] = {kReceivedLength * 2, kReceivedLength}; |
645 VerifyDailyDataSavingContentLengthPrefLists( | 645 VerifyDailyDataSavingContentLengthPrefLists( |
646 original2, 2, received2, 2, | 646 original2, 2, received2, 2, |
647 original2, 2, received2, 2, | 647 original2, 2, received2, 2, |
648 original2, 2, received2, 2); | 648 original2, 2, received2, 2); |
649 } | 649 } |
650 | 650 |
651 TEST_F(ChromeNetworkDailyDataSavingMetricsTest, BackwardTwoDays) { | 651 TEST_F(ChromeNetworkDailyDataSavingMetricsTest, BackwardTwoDays) { |
652 const int64 kOriginalLength = 200; | 652 const int64 kOriginalLength = 200; |
653 const int64 kReceivedLength = 100; | 653 const int64 kReceivedLength = 100; |
654 int64 original[] = {kOriginalLength}; | 654 int64 original[] = {kOriginalLength}; |
655 int64 received[] = {kReceivedLength}; | 655 int64 received[] = {kReceivedLength}; |
656 | 656 |
657 UpdateContentLengthPrefsForDataReductionProxy( | 657 UpdateContentLengthPrefsForDataReductionProxy( |
658 kReceivedLength, kOriginalLength, | 658 kReceivedLength, kOriginalLength, |
659 true, VIA_DATA_REDUCTION_PROXY, | 659 true, VIA_DATA_REDUCTION_PROXY, |
660 FakeNow(), statistics_prefs_.get()); | 660 FakeNow(), compression_stats_.get()); |
661 // Backward two days. | 661 // Backward two days. |
662 SetFakeTimeDeltaInHours(-2 * 24); | 662 SetFakeTimeDeltaInHours(-2 * 24); |
663 UpdateContentLengthPrefsForDataReductionProxy( | 663 UpdateContentLengthPrefsForDataReductionProxy( |
664 kReceivedLength, kOriginalLength, | 664 kReceivedLength, kOriginalLength, |
665 true, VIA_DATA_REDUCTION_PROXY, | 665 true, VIA_DATA_REDUCTION_PROXY, |
666 FakeNow(), statistics_prefs_.get()); | 666 FakeNow(), compression_stats_.get()); |
667 VerifyDailyDataSavingContentLengthPrefLists( | 667 VerifyDailyDataSavingContentLengthPrefLists( |
668 original, 1, received, 1, | 668 original, 1, received, 1, |
669 original, 1, received, 1, | 669 original, 1, received, 1, |
670 original, 1, received, 1); | 670 original, 1, received, 1); |
671 } | 671 } |
672 | 672 |
673 TEST_F(ChromeNetworkDailyDataSavingMetricsTest, | 673 TEST_F(ChromeNetworkDailyDataSavingMetricsTest, |
674 GetDataReductionProxyRequestType) { | 674 GetDataReductionProxyRequestType) { |
675 scoped_ptr<DataReductionProxyTestContext> test_context = | 675 scoped_ptr<DataReductionProxyTestContext> test_context = |
676 DataReductionProxyTestContext::Builder() | 676 DataReductionProxyTestContext::Builder() |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
803 } | 803 } |
804 | 804 |
805 EXPECT_EQ(test_case.expected_request_type, | 805 EXPECT_EQ(test_case.expected_request_type, |
806 GetDataReductionProxyRequestType( | 806 GetDataReductionProxyRequestType( |
807 *request, data_reduction_proxy_config, | 807 *request, data_reduction_proxy_config, |
808 *test_context->config())); | 808 *test_context->config())); |
809 } | 809 } |
810 } | 810 } |
811 | 811 |
812 } // namespace data_reduction_proxy | 812 } // namespace data_reduction_proxy |
OLD | NEW |