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 "base/memory/memory_pressure_listener.h" | 5 #include "base/memory/memory_pressure_listener.h" |
6 #include "base/prefs/testing_pref_store.h" | 6 #include "base/prefs/testing_pref_store.h" |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "base/test/histogram_tester.h" |
9 #include "base/test/simple_test_clock.h" | 10 #include "base/test/simple_test_clock.h" |
10 #include "base/values.h" | 11 #include "base/values.h" |
11 #include "net/base/net_log.h" | 12 #include "net/base/net_log.h" |
12 #include "net/base/sdch_manager.h" | 13 #include "net/base/sdch_manager.h" |
13 #include "net/sdch/sdch_owner.h" | 14 #include "net/sdch/sdch_owner.h" |
14 #include "net/url_request/url_request.h" | 15 #include "net/url_request/url_request.h" |
15 #include "net/url_request/url_request_context.h" | 16 #include "net/url_request/url_request_context.h" |
16 #include "net/url_request/url_request_error_job.h" | 17 #include "net/url_request/url_request_error_job.h" |
17 #include "net/url_request/url_request_job.h" | 18 #include "net/url_request/url_request_job.h" |
18 #include "net/url_request/url_request_job_factory.h" | 19 #include "net/url_request/url_request_job_factory.h" |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 base::Time stale(base::Time::Now() - base::TimeDelta::FromHours(25)); | 411 base::Time stale(base::Time::Now() - base::TimeDelta::FromHours(25)); |
411 | 412 |
412 EXPECT_TRUE( | 413 EXPECT_TRUE( |
413 CreateAndAddDictionary(kMaxSizeForTesting / 2, &server_hash_d1, fresh)); | 414 CreateAndAddDictionary(kMaxSizeForTesting / 2, &server_hash_d1, fresh)); |
414 EXPECT_TRUE( | 415 EXPECT_TRUE( |
415 CreateAndAddDictionary(kMaxSizeForTesting / 2, &server_hash_d2, stale)); | 416 CreateAndAddDictionary(kMaxSizeForTesting / 2, &server_hash_d2, stale)); |
416 | 417 |
417 EXPECT_TRUE(DictionaryPresentInManager(server_hash_d1)); | 418 EXPECT_TRUE(DictionaryPresentInManager(server_hash_d1)); |
418 EXPECT_TRUE(DictionaryPresentInManager(server_hash_d2)); | 419 EXPECT_TRUE(DictionaryPresentInManager(server_hash_d2)); |
419 | 420 |
| 421 base::HistogramTester tester; |
| 422 |
420 EXPECT_TRUE( | 423 EXPECT_TRUE( |
421 CreateAndAddDictionary(kMaxSizeForTesting / 2, &server_hash_d3, fresh)); | 424 CreateAndAddDictionary(kMaxSizeForTesting / 2, &server_hash_d3, fresh)); |
422 EXPECT_TRUE(DictionaryPresentInManager(server_hash_d1)); | 425 EXPECT_TRUE(DictionaryPresentInManager(server_hash_d1)); |
423 EXPECT_FALSE(DictionaryPresentInManager(server_hash_d2)); | 426 EXPECT_FALSE(DictionaryPresentInManager(server_hash_d2)); |
424 EXPECT_TRUE(DictionaryPresentInManager(server_hash_d3)); | 427 EXPECT_TRUE(DictionaryPresentInManager(server_hash_d3)); |
| 428 |
| 429 tester.ExpectTotalCount("Sdch3.TimeWeightedMemoryUse", 1); |
425 } | 430 } |
426 | 431 |
427 // Confirm auto-eviction happens if space is needed, with a more complicated | 432 // Confirm auto-eviction happens if space is needed, with a more complicated |
428 // situation | 433 // situation |
429 TEST_F(SdchOwnerTest, ConfirmAutoEviction_2) { | 434 TEST_F(SdchOwnerTest, ConfirmAutoEviction_2) { |
430 std::string server_hash_d1; | 435 std::string server_hash_d1; |
431 std::string server_hash_d2; | 436 std::string server_hash_d2; |
432 std::string server_hash_d3; | 437 std::string server_hash_d3; |
433 | 438 |
434 // Add dictionaries, one recent, two more than a day in the past that | 439 // Add dictionaries, one recent, two more than a day in the past that |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
847 | 852 |
848 ResetOwner(true); | 853 ResetOwner(true); |
849 InsertDictionaryForURL(url0, "0"); | 854 InsertDictionaryForURL(url0, "0"); |
850 EXPECT_EQ(1, owner_->GetDictionaryCountForTesting()); | 855 EXPECT_EQ(1, owner_->GetDictionaryCountForTesting()); |
851 owner_->EnablePersistentStorage(pref_store_.get()); | 856 owner_->EnablePersistentStorage(pref_store_.get()); |
852 ASSERT_TRUE(CompleteLoadFromURL(url1, "1")); | 857 ASSERT_TRUE(CompleteLoadFromURL(url1, "1")); |
853 EXPECT_EQ(2, owner_->GetDictionaryCountForTesting()); | 858 EXPECT_EQ(2, owner_->GetDictionaryCountForTesting()); |
854 } | 859 } |
855 | 860 |
856 } // namespace net | 861 } // namespace net |
OLD | NEW |