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

Side by Side Diff: build/android/pylib/flag_changer.py

Issue 11876021: Support startup performance tests on Galaxy S3 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Run startup tests on S3 - write protected files Created 7 years, 11 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
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 import constants 5 import constants
6 import traceback 6 import traceback
7 import warnings 7 import warnings
8 8
9 9
10 # Location where chrome reads command line flags from 10 # Location where chrome reads command line flags from
11 CHROME_COMMAND_FILE = '/data/local/chrome-command-line' 11 CHROME_COMMAND_FILE = '/data/local/chrome-command-line'
12 CHROME_TEMP_COMMAND_FILE='/sdcard/chrome-command-line-temp'
bulach 2013/01/16 19:11:05 not needed?
aberent 2013/01/17 17:18:06 Done.
12 13
13 class FlagChanger(object): 14 class FlagChanger(object):
14 """Changes the flags Chrome runs with. 15 """Changes the flags Chrome runs with.
15 16
16 There are two different use cases for this file: 17 There are two different use cases for this file:
17 * Flags are permanently set by calling Set(). 18 * Flags are permanently set by calling Set().
18 * Flags can be temporarily set for a particular set of unit tests. These 19 * Flags can be temporarily set for a particular set of unit tests. These
19 tests should call Restore() to revert the flags to their original state 20 tests should call Restore() to revert the flags to their original state
20 once the tests have completed. 21 once the tests have completed.
21 """ 22 """
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 def Restore(self): 83 def Restore(self):
83 """Restores the flags to their original state.""" 84 """Restores the flags to their original state."""
84 self._current_flags = self._TokenizeFlags(self._orig_line) 85 self._current_flags = self._TokenizeFlags(self._orig_line)
85 self._UpdateCommandLineFile() 86 self._UpdateCommandLineFile()
86 87
87 def _UpdateCommandLineFile(self): 88 def _UpdateCommandLineFile(self):
88 """Writes out the command line to the file, or removes it if empty.""" 89 """Writes out the command line to the file, or removes it if empty."""
89 print "Current flags: ", self._current_flags 90 print "Current flags: ", self._current_flags
90 91
91 if self._current_flags: 92 if self._current_flags:
92 self._android_cmd.SetFileContents(CHROME_COMMAND_FILE, 93 self._android_cmd.SetProtectedFileContents(CHROME_COMMAND_FILE,
93 'chrome ' + 94 'chrome ' +
94 ' '.join(self._current_flags)) 95 ' '.join(self._current_flags))
95 else: 96 else:
96 self._android_cmd.RunShellCommand('rm ' + CHROME_COMMAND_FILE) 97 self._android_cmd.RunShellCommand('su -c rm ' + CHROME_COMMAND_FILE)
97 98
98 def _TokenizeFlags(self, line): 99 def _TokenizeFlags(self, line):
99 """Changes the string containing the command line into a list of flags. 100 """Changes the string containing the command line into a list of flags.
100 101
101 Follows similar logic to CommandLine.java::tokenizeQuotedArguments: 102 Follows similar logic to CommandLine.java::tokenizeQuotedArguments:
102 * Flags are split using whitespace, unless the whitespace is within a 103 * Flags are split using whitespace, unless the whitespace is within a
103 pair of quotation marks. 104 pair of quotation marks.
104 * Unlike the Java version, we keep the quotation marks around switch 105 * Unlike the Java version, we keep the quotation marks around switch
105 values since we need them to re-create the file when new flags are 106 values since we need them to re-create the file when new flags are
106 appended. 107 appended.
(...skipping 28 matching lines...) Expand all
135 136
136 # Tack on the last flag. 137 # Tack on the last flag.
137 if not current_flag: 138 if not current_flag:
138 if within_quotations: 139 if within_quotations:
139 warnings.warn("Unterminated quoted string: " + current_flag) 140 warnings.warn("Unterminated quoted string: " + current_flag)
140 else: 141 else:
141 tokenized_flags.append(current_flag) 142 tokenized_flags.append(current_flag)
142 143
143 # Return everything but the program name. 144 # Return everything but the program name.
144 return tokenized_flags[1:] 145 return tokenized_flags[1:]
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698