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

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

Issue 2003001: Add time for when chrome's main() is called. (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
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/file_util.h"
sky 2010/05/05 23:32:22 before message_loop.
13 #include "base/process_util.h" 14 #include "base/process_util.h"
14 #include "base/string_util.h" 15 #include "base/string_util.h"
15 #include "base/thread.h" 16 #include "base/thread.h"
16 #include "chrome/browser/browser_process.h" 17 #include "chrome/browser/browser_process.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
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 return false; 94 return false;
94 } 95 }
95 96
96 void BootTimesLoader::Backend::GetBootTimes( 97 void BootTimesLoader::Backend::GetBootTimes(
97 scoped_refptr<GetBootTimesRequest> request) { 98 scoped_refptr<GetBootTimesRequest> request) {
98 const char* kInitialTSCCommand = "dmesg | grep 'Initial TSC value:'"; 99 const char* kInitialTSCCommand = "dmesg | grep 'Initial TSC value:'";
99 const char* kInitialTSCPrefix = "TSC value: "; 100 const char* kInitialTSCPrefix = "TSC value: ";
100 const char* kClockSpeedCommand = "dmesg | grep -e 'Detected.*processor'"; 101 const char* kClockSpeedCommand = "dmesg | grep -e 'Detected.*processor'";
101 const char* kClockSpeedPrefix = "Detected "; 102 const char* kClockSpeedPrefix = "Detected ";
102 const char* kPreStartup = "uptime-pre-startup"; 103 const char* kPreStartup = "uptime-pre-startup";
104 const char* kChromeExec = "uptime-chrome-exec";
105 const char* kChromeMain = "uptime-chrome-main";
103 const char* kXStarted = "uptime-x-started"; 106 const char* kXStarted = "uptime-x-started";
104 const char* kLoginPromptReady = "uptime-login-prompt-ready"; 107 const char* kLoginPromptReady = "uptime-login-prompt-ready";
105 108
106 if (request->canceled()) 109 if (request->canceled())
107 return; 110 return;
108 111
112 // Wait until login_prompt_ready is output.
113 FilePath log_dir(kLogPath);
114 FilePath log_file = log_dir.Append(kLoginPromptReady);
115 while (!file_util::PathExists(log_file)) {
116 usleep(500000);
117 }
118
109 BootTimes boot_times; 119 BootTimes boot_times;
110 std::string tsc_value = ExecuteInShell(kInitialTSCCommand, kInitialTSCPrefix); 120 std::string tsc_value = ExecuteInShell(kInitialTSCCommand, kInitialTSCPrefix);
111 std::string speed_value = 121 std::string speed_value =
112 ExecuteInShell(kClockSpeedCommand, kClockSpeedPrefix); 122 ExecuteInShell(kClockSpeedCommand, kClockSpeedPrefix);
113 boot_times.firmware = 0; 123 boot_times.firmware = 0;
114 if (!tsc_value.empty() && !speed_value.empty()) { 124 if (!tsc_value.empty() && !speed_value.empty()) {
115 int64 tsc = 0; 125 int64 tsc = 0;
116 double speed = 0; 126 double speed = 0;
117 if (StringToInt64(tsc_value, &tsc) && 127 if (StringToInt64(tsc_value, &tsc) &&
118 StringToDouble(speed_value, &speed) && 128 StringToDouble(speed_value, &speed) &&
119 speed > 0) { 129 speed > 0) {
120 boot_times.firmware = static_cast<double>(tsc) / (speed * 1000000); 130 boot_times.firmware = static_cast<double>(tsc) / (speed * 1000000);
121 } 131 }
122 } 132 }
123 GetUptime(kPreStartup, &boot_times.pre_startup); 133 GetUptime(kPreStartup, &boot_times.pre_startup);
124 GetUptime(kXStarted, &boot_times.x_started); 134 GetUptime(kXStarted, &boot_times.x_started);
135 GetUptime(kChromeExec, &boot_times.chrome_exec);
136 GetUptime(kChromeMain, &boot_times.chrome_main);
125 GetUptime(kLoginPromptReady, &boot_times.login_prompt_ready); 137 GetUptime(kLoginPromptReady, &boot_times.login_prompt_ready);
126 138
127 request->ForwardResult( 139 request->ForwardResult(
128 GetBootTimesCallback::TupleType(request->handle(), boot_times)); 140 GetBootTimesCallback::TupleType(request->handle(), boot_times));
129 } 141 }
130 142
131 } // namespace chromeos 143 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/boot_times_loader.h ('k') | chrome/browser/chromeos/login/background_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698