OLD | NEW |
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 #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/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "base/json/json_reader.h" | 13 #include "base/json/json_reader.h" |
14 #include "base/json/json_writer.h" | 14 #include "base/json/json_writer.h" |
15 #include "base/lazy_instance.h" | 15 #include "base/lazy_instance.h" |
16 #include "base/location.h" | 16 #include "base/location.h" |
17 #include "base/message_loop/message_loop.h" | 17 #include "base/message_loop/message_loop.h" |
18 #include "base/message_loop/message_loop_proxy.h" | 18 #include "base/message_loop/message_loop_proxy.h" |
19 #include "base/metrics/histogram.h" | 19 #include "base/metrics/histogram.h" |
20 #include "base/prefs/pref_service.h" | 20 #include "base/prefs/pref_service.h" |
21 #include "base/strings/string_number_conversions.h" | 21 #include "base/strings/string_number_conversions.h" |
22 #include "base/strings/string_util.h" | 22 #include "base/strings/string_util.h" |
23 #include "base/strings/stringprintf.h" | 23 #include "base/strings/stringprintf.h" |
24 #include "base/threading/thread.h" | 24 #include "base/threading/thread.h" |
25 #include "base/threading/thread_restrictions.h" | 25 #include "base/threading/thread_restrictions.h" |
26 #include "base/time/time.h" | 26 #include "base/time/time.h" |
27 #include "chrome/browser/browser_process.h" | 27 #include "chrome/browser/browser_process.h" |
28 #include "chrome/browser/chrome_notification_types.h" | 28 #include "chrome/browser/chrome_notification_types.h" |
29 #include "chrome/browser/chromeos/login/auth/authentication_notification_details
.h" | |
30 #include "chrome/browser/ui/browser.h" | 29 #include "chrome/browser/ui/browser.h" |
31 #include "chrome/browser/ui/browser_iterator.h" | 30 #include "chrome/browser/ui/browser_iterator.h" |
32 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 31 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
33 #include "chrome/common/chrome_switches.h" | 32 #include "chrome/common/chrome_switches.h" |
34 #include "chrome/common/pref_names.h" | 33 #include "chrome/common/pref_names.h" |
35 #include "components/user_manager/user_manager.h" | 34 #include "components/user_manager/user_manager.h" |
36 #include "content/public/browser/browser_thread.h" | 35 #include "content/public/browser/browser_thread.h" |
37 #include "content/public/browser/navigation_controller.h" | 36 #include "content/public/browser/navigation_controller.h" |
38 #include "content/public/browser/notification_service.h" | 37 #include "content/public/browser/notification_service.h" |
39 #include "content/public/browser/render_widget_host_view.h" | 38 #include "content/public/browser/render_widget_host_view.h" |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 | 420 |
422 void BootTimesLoader::RecordLoginAttempted() { | 421 void BootTimesLoader::RecordLoginAttempted() { |
423 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 422 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
424 if (login_done_) | 423 if (login_done_) |
425 return; | 424 return; |
426 | 425 |
427 login_time_markers_.clear(); | 426 login_time_markers_.clear(); |
428 AddLoginTimeMarker("LoginStarted", false); | 427 AddLoginTimeMarker("LoginStarted", false); |
429 if (!have_registered_) { | 428 if (!have_registered_) { |
430 have_registered_ = true; | 429 have_registered_ = true; |
431 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_AUTHENTICATION, | |
432 content::NotificationService::AllSources()); | |
433 registrar_.Add(this, content::NOTIFICATION_LOAD_START, | 430 registrar_.Add(this, content::NOTIFICATION_LOAD_START, |
434 content::NotificationService::AllSources()); | 431 content::NotificationService::AllSources()); |
435 registrar_.Add(this, content::NOTIFICATION_LOAD_STOP, | 432 registrar_.Add(this, content::NOTIFICATION_LOAD_STOP, |
436 content::NotificationService::AllSources()); | 433 content::NotificationService::AllSources()); |
437 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | 434 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, |
438 content::NotificationService::AllSources()); | 435 content::NotificationService::AllSources()); |
439 registrar_.Add( | 436 registrar_.Add( |
440 this, | 437 this, |
441 content::NOTIFICATION_RENDER_WIDGET_HOST_DID_UPDATE_BACKING_STORE, | 438 content::NOTIFICATION_RENDER_WIDGET_HOST_DID_UPDATE_BACKING_STORE, |
442 content::NotificationService::AllSources()); | 439 content::NotificationService::AllSources()); |
(...skipping 25 matching lines...) Expand all Loading... |
468 // Note that it's safe to use an unretained pointer to the vector because | 465 // Note that it's safe to use an unretained pointer to the vector because |
469 // BootTimesLoader's lifetime exceeds that of the UI thread message loop. | 466 // BootTimesLoader's lifetime exceeds that of the UI thread message loop. |
470 BrowserThread::PostTask( | 467 BrowserThread::PostTask( |
471 BrowserThread::UI, FROM_HERE, | 468 BrowserThread::UI, FROM_HERE, |
472 base::Bind(&BootTimesLoader::AddMarker, | 469 base::Bind(&BootTimesLoader::AddMarker, |
473 base::Unretained(vector), | 470 base::Unretained(vector), |
474 marker)); | 471 marker)); |
475 } | 472 } |
476 } | 473 } |
477 | 474 |
| 475 void BootTimesLoader::RecordAuthenticationSuccess() { |
| 476 AddLoginTimeMarker("Authenticate", true); |
| 477 RecordCurrentStats(kLoginSuccess); |
| 478 } |
| 479 |
| 480 void BootTimesLoader::RecordAuthenticationFailure() { |
| 481 // Do nothing for now. |
| 482 } |
| 483 |
478 void BootTimesLoader::Observe( | 484 void BootTimesLoader::Observe( |
479 int type, | 485 int type, |
480 const content::NotificationSource& source, | 486 const content::NotificationSource& source, |
481 const content::NotificationDetails& details) { | 487 const content::NotificationDetails& details) { |
482 switch (type) { | 488 switch (type) { |
483 case chrome::NOTIFICATION_LOGIN_AUTHENTICATION: { | |
484 content::Details<AuthenticationNotificationDetails> auth_details(details); | |
485 if (auth_details->success()) { | |
486 AddLoginTimeMarker("Authenticate", true); | |
487 RecordCurrentStats(kLoginSuccess); | |
488 registrar_.Remove(this, chrome::NOTIFICATION_LOGIN_AUTHENTICATION, | |
489 content::NotificationService::AllSources()); | |
490 } | |
491 break; | |
492 } | |
493 case content::NOTIFICATION_LOAD_START: { | 489 case content::NOTIFICATION_LOAD_START: { |
494 NavigationController* tab = | 490 NavigationController* tab = |
495 content::Source<NavigationController>(source).ptr(); | 491 content::Source<NavigationController>(source).ptr(); |
496 RenderWidgetHost* rwh = GetRenderWidgetHost(tab); | 492 RenderWidgetHost* rwh = GetRenderWidgetHost(tab); |
497 DCHECK(rwh); | 493 DCHECK(rwh); |
498 AddLoginTimeMarker("TabLoad-Start: " + GetTabUrl(rwh), false); | 494 AddLoginTimeMarker("TabLoad-Start: " + GetTabUrl(rwh), false); |
499 render_widget_hosts_loading_.insert(rwh); | 495 render_widget_hosts_loading_.insert(rwh); |
500 break; | 496 break; |
501 } | 497 } |
502 case content::NOTIFICATION_LOAD_STOP: { | 498 case content::NOTIFICATION_LOAD_STOP: { |
(...skipping 21 matching lines...) Expand all Loading... |
524 GetRenderWidgetHost(&web_contents->GetController()); | 520 GetRenderWidgetHost(&web_contents->GetController()); |
525 render_widget_hosts_loading_.erase(render_widget_host); | 521 render_widget_hosts_loading_.erase(render_widget_host); |
526 break; | 522 break; |
527 } | 523 } |
528 default: | 524 default: |
529 break; | 525 break; |
530 } | 526 } |
531 } | 527 } |
532 | 528 |
533 } // namespace chromeos | 529 } // namespace chromeos |
OLD | NEW |