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

Side by Side Diff: net/base/sdch_manager_unittest.cc

Issue 2699163002: Whitelist net/ MemoryDumpProvider (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « no previous file | net/spdy/spdy_session_pool_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "net/base/sdch_manager.h" 5 #include "net/base/sdch_manager.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 EXPECT_EQ(target_gurl, observer.last_dictionary_url()); 633 EXPECT_EQ(target_gurl, observer.last_dictionary_url());
634 EXPECT_EQ(server_hash, observer.last_server_hash()); 634 EXPECT_EQ(server_hash, observer.last_server_hash());
635 635
636 EXPECT_EQ(SDCH_OK, sdch_manager()->RemoveSdchDictionary(server_hash)); 636 EXPECT_EQ(SDCH_OK, sdch_manager()->RemoveSdchDictionary(server_hash));
637 EXPECT_EQ(1, observer.dictionary_removed_notifications()); 637 EXPECT_EQ(1, observer.dictionary_removed_notifications());
638 EXPECT_EQ(server_hash, observer.last_server_hash()); 638 EXPECT_EQ(server_hash, observer.last_server_hash());
639 639
640 sdch_manager()->RemoveObserver(&observer); 640 sdch_manager()->RemoveObserver(&observer);
641 } 641 }
642 642
643 TEST_F(SdchManagerTest, DumpMemoryStats) { 643 class SdchManagerMemoryDumpTest
644 : public SdchManagerTest,
645 public testing::WithParamInterface<
646 base::trace_event::MemoryDumpLevelOfDetail> {};
647
648 INSTANTIATE_TEST_CASE_P(
649 /* no prefix */,
650 SdchManagerMemoryDumpTest,
651 ::testing::Values(base::trace_event::MemoryDumpLevelOfDetail::DETAILED,
652 base::trace_event::MemoryDumpLevelOfDetail::BACKGROUND));
653
654 TEST_P(SdchManagerMemoryDumpTest, DumpMemoryStats) {
644 MockSdchObserver observer; 655 MockSdchObserver observer;
645 sdch_manager()->AddObserver(&observer); 656 sdch_manager()->AddObserver(&observer);
646 657
647 std::string dictionary_domain("x.y.z.google.com"); 658 std::string dictionary_domain("x.y.z.google.com");
648 GURL target_gurl("http://" + dictionary_domain); 659 GURL target_gurl("http://" + dictionary_domain);
649 std::string dictionary_text(NewSdchDictionary(dictionary_domain)); 660 std::string dictionary_text(NewSdchDictionary(dictionary_domain));
650 std::string client_hash; 661 std::string client_hash;
651 std::string server_hash; 662 std::string server_hash;
652 SdchManager::GenerateHash(dictionary_text, &client_hash, &server_hash); 663 SdchManager::GenerateHash(dictionary_text, &client_hash, &server_hash);
653 EXPECT_TRUE(AddSdchDictionary(dictionary_text, target_gurl)); 664 EXPECT_TRUE(AddSdchDictionary(dictionary_text, target_gurl));
654 EXPECT_EQ(1, observer.dictionary_added_notifications()); 665 EXPECT_EQ(1, observer.dictionary_added_notifications());
655 EXPECT_EQ(target_gurl, observer.last_dictionary_url()); 666 EXPECT_EQ(target_gurl, observer.last_dictionary_url());
656 EXPECT_EQ(server_hash, observer.last_server_hash()); 667 EXPECT_EQ(server_hash, observer.last_server_hash());
657 668
658 base::trace_event::MemoryDumpArgs dump_args = { 669 base::trace_event::MemoryDumpArgs dump_args = {GetParam()};
xunjieli 2017/02/17 16:50:11 sid: Do I need to set "ProcessMemoryDump::is_black
ssid 2017/02/21 18:07:43 No. This shouldn't be set.
xunjieli 2017/02/23 19:00:22 Done.
659 base::trace_event::MemoryDumpLevelOfDetail::DETAILED};
660 std::unique_ptr<base::trace_event::ProcessMemoryDump> pmd( 670 std::unique_ptr<base::trace_event::ProcessMemoryDump> pmd(
661 new base::trace_event::ProcessMemoryDump(nullptr, dump_args)); 671 new base::trace_event::ProcessMemoryDump(nullptr, dump_args));
662 672
663 base::trace_event::MemoryAllocatorDump* parent = 673 base::trace_event::MemoryAllocatorDump* parent =
664 pmd->CreateAllocatorDump("parent"); 674 pmd->CreateAllocatorDump("parent");
665 sdch_manager()->DumpMemoryStats(pmd.get(), parent->absolute_name()); 675 sdch_manager()->DumpMemoryStats(pmd.get(), parent->absolute_name());
666 676
667 const base::trace_event::MemoryAllocatorDump* sub_dump = 677 const base::trace_event::MemoryAllocatorDump* sub_dump =
668 pmd->GetAllocatorDump("parent/sdch_manager"); 678 pmd->GetAllocatorDump("parent/sdch_manager");
669 ASSERT_NE(nullptr, sub_dump); 679 ASSERT_NE(nullptr, sub_dump);
(...skipping 18 matching lines...) Expand all
688 base::trace_event::MemoryAllocatorDump::kNameObjectCount, &count_attrs)); 698 base::trace_event::MemoryAllocatorDump::kNameObjectCount, &count_attrs));
689 std::string count; 699 std::string count;
690 ASSERT_TRUE(count_attrs->GetString("value", &count)); 700 ASSERT_TRUE(count_attrs->GetString("value", &count));
691 // One dictionary. 701 // One dictionary.
692 EXPECT_EQ("1", count); 702 EXPECT_EQ("1", count);
693 703
694 sdch_manager()->RemoveObserver(&observer); 704 sdch_manager()->RemoveObserver(&observer);
695 } 705 }
696 706
697 } // namespace net 707 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/spdy/spdy_session_pool_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698