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

Side by Side Diff: chrome/browser/chromeos/boot_times_loader.cc

Issue 1995005: Allows browser tests to run with recent change (Closed)
Patch Set: Created 10 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
« no previous file with comments | « chrome/app/chrome_dll_main.cc ('k') | no next file » | 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/browser/chromeos/boot_times_loader.h" 5 #include "chrome/browser/chromeos/boot_times_loader.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/message_loop.h" 12 #include "base/message_loop.h"
13 #include "base/process_util.h" 13 #include "base/process_util.h"
14 #include "base/string_util.h" 14 #include "base/string_util.h"
15 #include "base/thread.h" 15 #include "base/thread.h"
16 #include "chrome/browser/browser_process.h" 16 #include "chrome/browser/browser_process.h"
17 #include "chrome/common/chrome_switches.h"
17 18
18 namespace chromeos { 19 namespace chromeos {
19 20
20 // Beginning of line we look for that gives version number. 21 // Beginning of line we look for that gives version number.
21 static const char kPrefix[] = "CHROMEOS_RELEASE_DESCRIPTION="; 22 static const char kPrefix[] = "CHROMEOS_RELEASE_DESCRIPTION=";
22 23
23 // File to look for version number in. 24 // File to look for version number in.
24 static const char kVersionPath[] = "/etc/lsb-release"; 25 static const char kVersionPath[] = "/etc/lsb-release";
25 26
26 // File uptime logs are located in. 27 // File uptime logs are located in.
27 static const char kLogPath[] = "/tmp"; 28 static const char kLogPath[] = "/tmp";
28 29
29 BootTimesLoader::BootTimesLoader() : backend_(new Backend()) { 30 BootTimesLoader::BootTimesLoader() : backend_(new Backend()) {
30 } 31 }
31 32
32 BootTimesLoader::Handle BootTimesLoader::GetBootTimes( 33 BootTimesLoader::Handle BootTimesLoader::GetBootTimes(
33 CancelableRequestConsumerBase* consumer, 34 CancelableRequestConsumerBase* consumer,
34 BootTimesLoader::GetBootTimesCallback* callback) { 35 BootTimesLoader::GetBootTimesCallback* callback) {
35 if (!g_browser_process->file_thread()) { 36 if (!g_browser_process->file_thread()) {
36 // This should only happen if Chrome is shutting down, so we don't do 37 // This should only happen if Chrome is shutting down, so we don't do
37 // anything. 38 // anything.
38 return 0; 39 return 0;
39 } 40 }
40 41
42 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
43 if (command_line.HasSwitch(switches::kTestType)) {
44 // TODO(davemoore) This avoids boottimes for tests. This needs to be
45 // replaced with a mock of BootTimesLoader.
46 return 0;
47 }
48
41 scoped_refptr<CancelableRequest<GetBootTimesCallback> > request( 49 scoped_refptr<CancelableRequest<GetBootTimesCallback> > request(
42 new CancelableRequest<GetBootTimesCallback>(callback)); 50 new CancelableRequest<GetBootTimesCallback>(callback));
43 AddRequest(request, consumer); 51 AddRequest(request, consumer);
44 52
45 g_browser_process->file_thread()->message_loop()->PostTask( 53 g_browser_process->file_thread()->message_loop()->PostTask(
46 FROM_HERE, 54 FROM_HERE,
47 NewRunnableMethod(backend_.get(), &Backend::GetBootTimes, request)); 55 NewRunnableMethod(backend_.get(), &Backend::GetBootTimes, request));
48 return request->handle(); 56 return request->handle();
49 } 57 }
50 58
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 GetUptime(kXStarted, &boot_times.x_started); 141 GetUptime(kXStarted, &boot_times.x_started);
134 GetUptime(kChromeExec, &boot_times.chrome_exec); 142 GetUptime(kChromeExec, &boot_times.chrome_exec);
135 GetUptime(kChromeMain, &boot_times.chrome_main); 143 GetUptime(kChromeMain, &boot_times.chrome_main);
136 GetUptime(kLoginPromptReady, &boot_times.login_prompt_ready); 144 GetUptime(kLoginPromptReady, &boot_times.login_prompt_ready);
137 145
138 request->ForwardResult( 146 request->ForwardResult(
139 GetBootTimesCallback::TupleType(request->handle(), boot_times)); 147 GetBootTimesCallback::TupleType(request->handle(), boot_times));
140 } 148 }
141 149
142 } // namespace chromeos 150 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/app/chrome_dll_main.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698