OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
13 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
15 #include "base/process_util.h" | 15 #include "base/process_util.h" |
16 #include "base/string_number_conversions.h" | 16 #include "base/string_number_conversions.h" |
17 #include "base/string_util.h" | 17 #include "base/string_util.h" |
18 #include "base/stringprintf.h" | 18 #include "base/stringprintf.h" |
19 #include "base/threading/thread.h" | 19 #include "base/threading/thread.h" |
20 #include "base/threading/thread_restrictions.h" | 20 #include "base/threading/thread_restrictions.h" |
21 #include "base/time.h" | 21 #include "base/time.h" |
22 #include "chrome/browser/browser_process.h" | 22 #include "chrome/browser/browser_process.h" |
23 #include "chrome/browser/chromeos/login/authentication_notification_details.h" | 23 #include "chrome/browser/chromeos/login/authentication_notification_details.h" |
24 #include "chrome/browser/chromeos/login/user_manager.h" | 24 #include "chrome/browser/chromeos/login/user_manager.h" |
25 #include "chrome/browser/chromeos/network_state_notifier.h" | 25 #include "chrome/browser/chromeos/network_state_notifier.h" |
| 26 #include "chrome/common/chrome_notification_types.h" |
26 #include "chrome/common/chrome_switches.h" | 27 #include "chrome/common/chrome_switches.h" |
27 #include "content/browser/browser_thread.h" | 28 #include "content/browser/browser_thread.h" |
28 #include "content/common/notification_service.h" | 29 #include "content/common/notification_service.h" |
29 | 30 |
30 namespace chromeos { | 31 namespace chromeos { |
31 | 32 |
32 #define FPL(value) FILE_PATH_LITERAL(value) | 33 #define FPL(value) FILE_PATH_LITERAL(value) |
33 | 34 |
34 // File uptime logs are located in. | 35 // File uptime logs are located in. |
35 static const FilePath::CharType kLogPath[] = FPL("/tmp"); | 36 static const FilePath::CharType kLogPath[] = FPL("/tmp"); |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 | 336 |
336 void BootTimesLoader::RecordChromeMainStats() { | 337 void BootTimesLoader::RecordChromeMainStats() { |
337 RecordStats(kChromeMain, chrome_main_stats_); | 338 RecordStats(kChromeMain, chrome_main_stats_); |
338 } | 339 } |
339 | 340 |
340 void BootTimesLoader::RecordLoginAttempted() { | 341 void BootTimesLoader::RecordLoginAttempted() { |
341 login_time_markers_.clear(); | 342 login_time_markers_.clear(); |
342 AddLoginTimeMarker("LoginStarted", false); | 343 AddLoginTimeMarker("LoginStarted", false); |
343 if (!have_registered_) { | 344 if (!have_registered_) { |
344 have_registered_ = true; | 345 have_registered_ = true; |
345 registrar_.Add(this, NotificationType::LOAD_START, | 346 registrar_.Add(this, content::NOTIFICATION_LOAD_START, |
346 NotificationService::AllSources()); | 347 NotificationService::AllSources()); |
347 registrar_.Add(this, NotificationType::LOGIN_AUTHENTICATION, | 348 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_AUTHENTICATION, |
348 NotificationService::AllSources()); | 349 NotificationService::AllSources()); |
349 } | 350 } |
350 } | 351 } |
351 | 352 |
352 void BootTimesLoader::AddLoginTimeMarker( | 353 void BootTimesLoader::AddLoginTimeMarker( |
353 const std::string& marker_name, bool send_to_uma) { | 354 const std::string& marker_name, bool send_to_uma) { |
354 login_time_markers_.push_back(TimeMarker(marker_name, send_to_uma)); | 355 login_time_markers_.push_back(TimeMarker(marker_name, send_to_uma)); |
355 } | 356 } |
356 | 357 |
357 void BootTimesLoader::AddLogoutTimeMarker( | 358 void BootTimesLoader::AddLogoutTimeMarker( |
358 const std::string& marker_name, bool send_to_uma) { | 359 const std::string& marker_name, bool send_to_uma) { |
359 logout_time_markers_.push_back(TimeMarker(marker_name, send_to_uma)); | 360 logout_time_markers_.push_back(TimeMarker(marker_name, send_to_uma)); |
360 } | 361 } |
361 | 362 |
362 void BootTimesLoader::Observe( | 363 void BootTimesLoader::Observe( |
363 NotificationType type, | 364 int type, |
364 const NotificationSource& source, | 365 const NotificationSource& source, |
365 const NotificationDetails& details) { | 366 const NotificationDetails& details) { |
366 if (type == NotificationType::LOGIN_AUTHENTICATION) { | 367 if (type == chrome::NOTIFICATION_LOGIN_AUTHENTICATION) { |
367 Details<AuthenticationNotificationDetails> auth_details(details); | 368 Details<AuthenticationNotificationDetails> auth_details(details); |
368 if (auth_details->success()) { | 369 if (auth_details->success()) { |
369 AddLoginTimeMarker("Authenticate", true); | 370 AddLoginTimeMarker("Authenticate", true); |
370 RecordCurrentStats(kLoginSuccess); | 371 RecordCurrentStats(kLoginSuccess); |
371 registrar_.Remove(this, NotificationType::LOGIN_AUTHENTICATION, | 372 registrar_.Remove(this, chrome::NOTIFICATION_LOGIN_AUTHENTICATION, |
372 NotificationService::AllSources()); | 373 NotificationService::AllSources()); |
373 } | 374 } |
374 } else if (type == NotificationType::LOAD_START) { | 375 } else if (type == content::NOTIFICATION_LOAD_START) { |
375 // Make sure it's not some page load initiated by OOBE/login screen. | 376 // Make sure it's not some page load initiated by OOBE/login screen. |
376 if (!UserManager::Get()->user_is_logged_in()) | 377 if (!UserManager::Get()->user_is_logged_in()) |
377 return; | 378 return; |
378 // Only log for first tab to render. Make sure this is only done once. | 379 // Only log for first tab to render. Make sure this is only done once. |
379 // If the network isn't connected we'll get a second LOAD_START once it is | 380 // If the network isn't connected we'll get a second LOAD_START once it is |
380 // and the page is reloaded. | 381 // and the page is reloaded. |
381 if (NetworkStateNotifier::GetInstance()->is_connected()) { | 382 if (NetworkStateNotifier::GetInstance()->is_connected()) { |
382 // Post difference between first tab and login success time. | 383 // Post difference between first tab and login success time. |
383 AddLoginTimeMarker("LoginDone", true); | 384 AddLoginTimeMarker("LoginDone", true); |
384 RecordCurrentStats(kChromeFirstRender); | 385 RecordCurrentStats(kChromeFirstRender); |
385 // Post chrome first render stat. | 386 // Post chrome first render stat. |
386 registrar_.Remove(this, NotificationType::LOAD_START, | 387 registrar_.Remove(this, content::NOTIFICATION_LOAD_START, |
387 NotificationService::AllSources()); | 388 NotificationService::AllSources()); |
388 // Don't swamp the FILE thread right away. | 389 // Don't swamp the FILE thread right away. |
389 BrowserThread::PostDelayedTask( | 390 BrowserThread::PostDelayedTask( |
390 BrowserThread::FILE, FROM_HERE, | 391 BrowserThread::FILE, FROM_HERE, |
391 // This doesn't compile without std::string(...), as | 392 // This doesn't compile without std::string(...), as |
392 // NewRunnableFunction doesn't accept arrays. | 393 // NewRunnableFunction doesn't accept arrays. |
393 NewRunnableFunction(WriteTimes, | 394 NewRunnableFunction(WriteTimes, |
394 std::string(kLoginTimes), | 395 std::string(kLoginTimes), |
395 std::string(kUmaLogin), | 396 std::string(kUmaLogin), |
396 std::string(kUmaLoginPrefix), | 397 std::string(kUmaLoginPrefix), |
397 login_time_markers_), | 398 login_time_markers_), |
398 kLoginTimeWriteDelayMs); | 399 kLoginTimeWriteDelayMs); |
399 have_registered_ = false; | 400 have_registered_ = false; |
400 } else { | 401 } else { |
401 AddLoginTimeMarker("LoginRenderNoNetwork", false); | 402 AddLoginTimeMarker("LoginRenderNoNetwork", false); |
402 } | 403 } |
403 } | 404 } |
404 } | 405 } |
405 | 406 |
406 } // namespace chromeos | 407 } // namespace chromeos |
OLD | NEW |