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

Side by Side Diff: chrome/test/automation/proxy_launcher.cc

Issue 13165005: Move FileEnumerator to its own file, do some refactoring. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge, fixes Created 7 years, 7 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/installer/util/shell_util_unittest.cc ('k') | chrome/test/chromedriver/chrome/zip.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 #include "chrome/test/automation/proxy_launcher.h" 5 #include "chrome/test/automation/proxy_launcher.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/environment.h" 9 #include "base/environment.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 #include "base/files/file_enumerator.h"
11 #include "base/stringprintf.h" 12 #include "base/stringprintf.h"
12 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/string_split.h" 14 #include "base/strings/string_split.h"
14 #include "base/test/test_file_util.h" 15 #include "base/test/test_file_util.h"
15 #include "base/test/test_timeouts.h" 16 #include "base/test/test_timeouts.h"
16 #include "base/utf_string_conversions.h" 17 #include "base/utf_string_conversions.h"
17 #include "chrome/app/chrome_command_ids.h" 18 #include "chrome/app/chrome_command_ids.h"
18 #include "chrome/common/automation_constants.h" 19 #include "chrome/common/automation_constants.h"
19 #include "chrome/common/chrome_constants.h" 20 #include "chrome/common/chrome_constants.h"
20 #include "chrome/common/chrome_switches.h" 21 #include "chrome/common/chrome_switches.h"
(...skipping 21 matching lines...) Expand all
42 // Copies the contents of the given source directory to the given dest 43 // Copies the contents of the given source directory to the given dest
43 // directory. This is somewhat different than CopyDirectory in base which will 44 // directory. This is somewhat different than CopyDirectory in base which will
44 // copies "source/" to "dest/source/". This version will copy "source/*" to 45 // copies "source/" to "dest/source/". This version will copy "source/*" to
45 // "dest/*", overwriting existing files as necessary. 46 // "dest/*", overwriting existing files as necessary.
46 // 47 //
47 // This also kicks the files out of the memory cache for the startup tests. 48 // This also kicks the files out of the memory cache for the startup tests.
48 // TODO(brettw) bug 237904: This is the wrong place for this code. It means all 49 // TODO(brettw) bug 237904: This is the wrong place for this code. It means all
49 // startup tests other than the "cold" ones run more slowly than necessary. 50 // startup tests other than the "cold" ones run more slowly than necessary.
50 bool CopyDirectoryContentsNoCache(const base::FilePath& source, 51 bool CopyDirectoryContentsNoCache(const base::FilePath& source,
51 const base::FilePath& dest) { 52 const base::FilePath& dest) {
52 file_util::FileEnumerator en(source, false, 53 base::FileEnumerator en(source, false,
53 file_util::FileEnumerator::FILES | 54 base::FileEnumerator::FILES | base::FileEnumerator::DIRECTORIES);
54 file_util::FileEnumerator::DIRECTORIES);
55 for (base::FilePath cur = en.Next(); !cur.empty(); cur = en.Next()) { 55 for (base::FilePath cur = en.Next(); !cur.empty(); cur = en.Next()) {
56 file_util::FileEnumerator::FindInfo info; 56 base::FileEnumerator::FileInfo info = en.GetInfo();
57 en.GetFindInfo(&info); 57 if (info.IsDirectory()) {
58 if (file_util::FileEnumerator::IsDirectory(info)) {
59 if (!file_util::CopyDirectory(cur, dest, true)) 58 if (!file_util::CopyDirectory(cur, dest, true))
60 return false; 59 return false;
61 } else { 60 } else {
62 if (!file_util::CopyFile(cur, dest.Append(cur.BaseName()))) 61 if (!file_util::CopyFile(cur, dest.Append(cur.BaseName())))
63 return false; 62 return false;
64 } 63 }
65 } 64 }
66 65
67 // Kick out the profile files, this must happen after SetUp which creates the 66 // Kick out the profile files, this must happen after SetUp which creates the
68 // profile. It might be nicer to use EvictFileFromSystemCacheWrapper from 67 // profile. It might be nicer to use EvictFileFromSystemCacheWrapper from
69 // UITest which will retry on failure. 68 // UITest which will retry on failure.
70 file_util::FileEnumerator kickout(dest, true, 69 base::FileEnumerator kickout(dest, true, base::FileEnumerator::FILES);
71 file_util::FileEnumerator::FILES);
72 for (base::FilePath cur = kickout.Next(); !cur.empty(); cur = kickout.Next()) 70 for (base::FilePath cur = kickout.Next(); !cur.empty(); cur = kickout.Next())
73 base::EvictFileFromSystemCacheWithRetry(cur); 71 base::EvictFileFromSystemCacheWithRetry(cur);
74 return true; 72 return true;
75 } 73 }
76 74
77 // We want to have a current history database when we start the browser so 75 // We want to have a current history database when we start the browser so
78 // things like the NTP will have thumbnails. This method updates the dates 76 // things like the NTP will have thumbnails. This method updates the dates
79 // in the history to be more recent. 77 // in the history to be more recent.
80 void UpdateHistoryDates(const base::FilePath& user_data_dir) { 78 void UpdateHistoryDates(const base::FilePath& user_data_dir) {
81 // Migrate the times in the segment_usage table to yesterday so we get 79 // Migrate the times in the segment_usage table to yesterday so we get
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 return LaunchBrowserAndServer(state, wait_for_initial_loads); 628 return LaunchBrowserAndServer(state, wait_for_initial_loads);
631 } 629 }
632 630
633 void AnonymousProxyLauncher::TerminateConnection() { 631 void AnonymousProxyLauncher::TerminateConnection() {
634 CloseBrowserAndServer(); 632 CloseBrowserAndServer();
635 } 633 }
636 634
637 std::string AnonymousProxyLauncher::PrefixedChannelID() const { 635 std::string AnonymousProxyLauncher::PrefixedChannelID() const {
638 return channel_id_; 636 return channel_id_;
639 } 637 }
OLDNEW
« no previous file with comments | « chrome/installer/util/shell_util_unittest.cc ('k') | chrome/test/chromedriver/chrome/zip.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698