OLD | NEW |
---|---|
1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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 """Controller objects that control the context in which chrome runs. | 5 """Controller objects that control the context in which chrome runs. |
6 | 6 |
7 This is responsible for the setup necessary for launching chrome, and for | 7 This is responsible for the setup necessary for launching chrome, and for |
8 creating a DevToolsConnection. There are remote device and local | 8 creating a DevToolsConnection. There are remote device and local |
9 desktop-specific versions. | 9 desktop-specific versions. |
10 """ | 10 """ |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
310 headless: true if the chrome instance should be headless. | 310 headless: true if the chrome instance should be headless. |
311 """ | 311 """ |
312 self._headless = headless | 312 self._headless = headless |
313 | 313 |
314 @contextlib.contextmanager | 314 @contextlib.contextmanager |
315 def OpenWithRedirection(self, stdout, stderr): | 315 def OpenWithRedirection(self, stdout, stderr): |
316 """Override for connection context. stdout and stderr are passed to the | 316 """Override for connection context. stdout and stderr are passed to the |
317 child processes used to run Chrome and XVFB.""" | 317 child processes used to run Chrome and XVFB.""" |
318 chrome_cmd = [OPTIONS.local_binary] | 318 chrome_cmd = [OPTIONS.local_binary] |
319 chrome_cmd.extend(self._GetChromeArguments()) | 319 chrome_cmd.extend(self._GetChromeArguments()) |
320 # Force use of simple cache. | |
321 # TODO(gabadie): Should we do a SetSimpleCacheBackend(True/False)? | |
mattcary
2016/04/28 09:20:25
Unless there's going to be a reason to switch betw
gabadie
2016/04/28 11:44:07
Done.
| |
322 chrome_cmd.append('--use-simple-cache-backend=on') | |
320 chrome_cmd.append('--user-data-dir=%s' % self._profile_dir) | 323 chrome_cmd.append('--user-data-dir=%s' % self._profile_dir) |
321 chrome_cmd.extend(['--enable-logging=stderr', '--v=1']) | 324 chrome_cmd.extend(['--enable-logging=stderr', '--v=1']) |
322 # Navigates to about:blank for couples of reasons: | 325 # Navigates to about:blank for couples of reasons: |
323 # - To find the correct target descriptor at devtool connection; | 326 # - To find the correct target descriptor at devtool connection; |
324 # - To avoid cache and WPR pollution by the NTP. | 327 # - To avoid cache and WPR pollution by the NTP. |
325 chrome_cmd.append('about:blank') | 328 chrome_cmd.append('about:blank') |
326 | 329 |
327 chrome_env_override = {} | 330 chrome_env_override = {} |
328 if self._wpr_attributes: | 331 if self._wpr_attributes: |
329 chrome_env_override.update(self._wpr_attributes.chrome_env_override) | 332 chrome_env_override.update(self._wpr_attributes.chrome_env_override) |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
420 os.listdir(self._profile_dir) == []): | 423 os.listdir(self._profile_dir) == []): |
421 # Launch chrome so that it populates the profile directory. | 424 # Launch chrome so that it populates the profile directory. |
422 with self.Open(): | 425 with self.Open(): |
423 pass | 426 pass |
424 print os.listdir(self._profile_dir + '/Default') | 427 print os.listdir(self._profile_dir + '/Default') |
425 assert os.path.isdir(self._profile_dir) | 428 assert os.path.isdir(self._profile_dir) |
426 assert os.path.isdir(os.path.dirname(self._GetCacheDirectoryPath())) | 429 assert os.path.isdir(os.path.dirname(self._GetCacheDirectoryPath())) |
427 | 430 |
428 def _GetCacheDirectoryPath(self): | 431 def _GetCacheDirectoryPath(self): |
429 return os.path.join(self._profile_dir, 'Default', 'Cache') | 432 return os.path.join(self._profile_dir, 'Default', 'Cache') |
OLD | NEW |