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

Side by Side Diff: chrome/test/reliability/page_load_test.cc

Issue 16392011: Move FileEnumerator to its own file, do some refactoring. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix incorrect includes Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « chrome/test/reliability/automated_ui_tests.cc ('k') | chrome/test/ui/ui_test.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // This file provides reliablity test which runs under UI test framework. The 5 // This file provides reliablity test which runs under UI test framework. The
6 // test is intended to run within QEMU environment. 6 // test is intended to run within QEMU environment.
7 // 7 //
8 // Usage 1: reliability_test 8 // Usage 1: reliability_test
9 // Upon invocation, it visits a hard coded list of sample URLs. This is mainly 9 // Upon invocation, it visits a hard coded list of sample URLs. This is mainly
10 // used by buildbot, to verify reliability_test itself runs ok. 10 // used by buildbot, to verify reliability_test itself runs ok.
(...skipping 23 matching lines...) Expand all
34 // --searchdumpsbypid: Look for crash dumps by browser process id. 34 // --searchdumpsbypid: Look for crash dumps by browser process id.
35 // "crash_dir/pid/" 35 // "crash_dir/pid/"
36 36
37 #include <fstream> 37 #include <fstream>
38 #include <vector> 38 #include <vector>
39 39
40 #include "base/command_line.h" 40 #include "base/command_line.h"
41 #include "base/environment.h" 41 #include "base/environment.h"
42 #include "base/file_util.h" 42 #include "base/file_util.h"
43 #include "base/file_version_info.h" 43 #include "base/file_version_info.h"
44 #include "base/files/file_enumerator.h"
44 #include "base/files/file_path.h" 45 #include "base/files/file_path.h"
45 #include "base/i18n/time_formatting.h" 46 #include "base/i18n/time_formatting.h"
46 #include "base/memory/scoped_ptr.h" 47 #include "base/memory/scoped_ptr.h"
47 #include "base/path_service.h" 48 #include "base/path_service.h"
48 #include "base/prefs/json_pref_store.h" 49 #include "base/prefs/json_pref_store.h"
49 #include "base/prefs/pref_registry_simple.h" 50 #include "base/prefs/pref_registry_simple.h"
50 #include "base/prefs/pref_service.h" 51 #include "base/prefs/pref_service.h"
51 #include "base/string_util.h" 52 #include "base/string_util.h"
52 #include "base/strings/string_number_conversions.h" 53 #include "base/strings/string_number_conversions.h"
53 #include "base/test/test_file_util.h" 54 #include "base/test/test_file_util.h"
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 // If 'BREAKPAD_DUMP_LOCATION' environment variable is set, use it instead. 630 // If 'BREAKPAD_DUMP_LOCATION' environment variable is set, use it instead.
630 scoped_ptr<base::Environment> env(base::Environment::Create()); 631 scoped_ptr<base::Environment> env(base::Environment::Create());
631 std::string alternate_minidump_location; 632 std::string alternate_minidump_location;
632 if (env->GetVar("BREAKPAD_DUMP_LOCATION", &alternate_minidump_location)) { 633 if (env->GetVar("BREAKPAD_DUMP_LOCATION", &alternate_minidump_location)) {
633 crash_dumps_dir_path_ = base::FilePath::FromUTF8Unsafe( 634 crash_dumps_dir_path_ = base::FilePath::FromUTF8Unsafe(
634 alternate_minidump_location); 635 alternate_minidump_location);
635 } else { 636 } else {
636 PathService::Get(chrome::DIR_CRASH_DUMPS, &crash_dumps_dir_path_); 637 PathService::Get(chrome::DIR_CRASH_DUMPS, &crash_dumps_dir_path_);
637 } 638 }
638 639
639 file_util::FileEnumerator enumerator(crash_dumps_dir_path_, 640 base::FileEnumerator enumerator(crash_dumps_dir_path_,
640 false, // not recursive 641 false, // not recursive
641 file_util::FileEnumerator::FILES); 642 base::FileEnumerator::FILES);
642 for (base::FilePath path = enumerator.Next(); !path.value().empty(); 643 for (base::FilePath path = enumerator.Next(); !path.value().empty();
643 path = enumerator.Next()) { 644 path = enumerator.Next()) {
644 if (path.MatchesExtension(FILE_PATH_LITERAL(".dmp"))) 645 if (path.MatchesExtension(FILE_PATH_LITERAL(".dmp")))
645 crash_dumps_[path.BaseName()] = true; 646 crash_dumps_[path.BaseName()] = true;
646 } 647 }
647 } 648 }
648 649
649 base::FilePath ConstructSavedDebugLogPath( 650 base::FilePath ConstructSavedDebugLogPath(
650 const base::FilePath& debug_log_path, 651 const base::FilePath& debug_log_path,
651 int index) { 652 int index) {
(...skipping 28 matching lines...) Expand all
680 base::FilePath crash_dump_file_path(crash_dumps_dir_path_); 681 base::FilePath crash_dump_file_path(crash_dumps_dir_path_);
681 crash_dump_file_path = crash_dump_file_path.Append(crash_dump_file_name); 682 crash_dump_file_path = crash_dump_file_path.Append(crash_dump_file_name);
682 base::FilePath crash_text_file_path = 683 base::FilePath crash_text_file_path =
683 crash_dump_file_path.ReplaceExtension(FILE_PATH_LITERAL("txt")); 684 crash_dump_file_path.ReplaceExtension(FILE_PATH_LITERAL("txt"));
684 685
685 ASSERT_TRUE(file_util::DieFileDie(crash_dump_file_path, false)); 686 ASSERT_TRUE(file_util::DieFileDie(crash_dump_file_path, false));
686 ASSERT_TRUE(file_util::DieFileDie(crash_text_file_path, false)); 687 ASSERT_TRUE(file_util::DieFileDie(crash_text_file_path, false));
687 } 688 }
688 689
689 bool HasNewCrashDumps() { 690 bool HasNewCrashDumps() {
690 file_util::FileEnumerator enumerator(crash_dumps_dir_path_, 691 base::FileEnumerator enumerator(crash_dumps_dir_path_,
691 false, // not recursive 692 false, // not recursive
692 file_util::FileEnumerator::FILES); 693 base::FileEnumerator::FILES);
693 for (base::FilePath path = enumerator.Next(); !path.value().empty(); 694 for (base::FilePath path = enumerator.Next(); !path.value().empty();
694 path = enumerator.Next()) { 695 path = enumerator.Next()) {
695 if (path.MatchesExtension(FILE_PATH_LITERAL(".dmp")) && 696 if (path.MatchesExtension(FILE_PATH_LITERAL(".dmp")) &&
696 !crash_dumps_[path.BaseName()]) { 697 !crash_dumps_[path.BaseName()]) {
697 return true; 698 return true;
698 } 699 }
699 } 700 }
700 701
701 return false; 702 return false;
702 } 703 }
703 704
704 // Check whether there are new .dmp files. Return the list and optionally 705 // Check whether there are new .dmp files. Return the list and optionally
705 // delete them afterwards. 706 // delete them afterwards.
706 void CollectNewCrashDumps(std::vector<base::FilePath>& new_crash_dumps, 707 void CollectNewCrashDumps(std::vector<base::FilePath>& new_crash_dumps,
707 NavigationMetrics* metrics, 708 NavigationMetrics* metrics,
708 bool delete_dumps) { 709 bool delete_dumps) {
709 int num_dumps = 0; 710 int num_dumps = 0;
710 file_util::FileEnumerator enumerator(crash_dumps_dir_path_, 711 base::FileEnumerator enumerator(crash_dumps_dir_path_,
711 false, // not recursive 712 false, // not recursive
712 file_util::FileEnumerator::FILES); 713 base::FileEnumerator::FILES);
713 for (base::FilePath path = enumerator.Next(); !path.value().empty(); 714 for (base::FilePath path = enumerator.Next(); !path.value().empty();
714 path = enumerator.Next()) { 715 path = enumerator.Next()) {
715 if (path.MatchesExtension(FILE_PATH_LITERAL(".dmp")) && 716 if (path.MatchesExtension(FILE_PATH_LITERAL(".dmp")) &&
716 !crash_dumps_[path.BaseName()]) { 717 !crash_dumps_[path.BaseName()]) {
717 crash_dumps_[path.BaseName()] = true; 718 crash_dumps_[path.BaseName()] = true;
718 base::FilePath crash_dump_file_path(crash_dumps_dir_path_); 719 base::FilePath crash_dump_file_path(crash_dumps_dir_path_);
719 crash_dump_file_path = crash_dump_file_path.Append(path.BaseName()); 720 crash_dump_file_path = crash_dump_file_path.Append(path.BaseName());
720 new_crash_dumps.push_back(crash_dump_file_path); 721 new_crash_dumps.push_back(crash_dump_file_path);
721 if (delete_dumps) 722 if (delete_dumps)
722 DeleteCrashDump(path.BaseName()); 723 DeleteCrashDump(path.BaseName());
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
810 if (!g_end_url.empty()) { 811 if (!g_end_url.empty()) {
811 NavigateToURLLogResult( 812 NavigateToURLLogResult(
812 g_end_url, log_file, NULL, g_continuous_load, false); 813 g_end_url, log_file, NULL, g_continuous_load, false);
813 } 814 }
814 815
815 log_file.close(); 816 log_file.close();
816 } 817 }
817 818
818 } // namespace 819 } // namespace
819 820
OLDNEW
« no previous file with comments | « chrome/test/reliability/automated_ui_tests.cc ('k') | chrome/test/ui/ui_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698