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

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

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

Powered by Google App Engine
This is Rietveld 408576698