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/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "chrome/browser/chromeos/login/authentication_notification_details.h" | 24 #include "chrome/browser/chromeos/login/authentication_notification_details.h" |
25 #include "chrome/browser/chromeos/login/user_manager.h" | 25 #include "chrome/browser/chromeos/login/user_manager.h" |
26 #include "chrome/browser/ui/browser_list.h" | 26 #include "chrome/browser/ui/browser_list.h" |
27 #include "chrome/browser/ui/browser.h" | 27 #include "chrome/browser/ui/browser.h" |
28 #include "chrome/common/chrome_notification_types.h" | 28 #include "chrome/common/chrome_notification_types.h" |
29 #include "chrome/common/chrome_switches.h" | 29 #include "chrome/common/chrome_switches.h" |
30 #include "content/browser/browser_thread.h" | 30 #include "content/browser/browser_thread.h" |
31 #include "content/browser/renderer_host/render_widget_host_view.h" | 31 #include "content/browser/renderer_host/render_widget_host_view.h" |
32 #include "content/browser/tab_contents/navigation_controller.h" | 32 #include "content/browser/tab_contents/navigation_controller.h" |
33 #include "content/browser/tab_contents/tab_contents.h" | 33 #include "content/browser/tab_contents/tab_contents.h" |
34 #include "content/common/notification_service.h" | 34 #include "content/public/browser/notification_service.h" |
35 | 35 |
36 namespace { | 36 namespace { |
37 | 37 |
38 RenderWidgetHost* GetRenderWidgetHost(NavigationController* tab) { | 38 RenderWidgetHost* GetRenderWidgetHost(NavigationController* tab) { |
39 TabContents* tab_contents = tab->tab_contents(); | 39 TabContents* tab_contents = tab->tab_contents(); |
40 if (tab_contents) { | 40 if (tab_contents) { |
41 RenderWidgetHostView* render_widget_host_view = | 41 RenderWidgetHostView* render_widget_host_view = |
42 tab_contents->GetRenderWidgetHostView(); | 42 tab_contents->GetRenderWidgetHostView(); |
43 if (render_widget_host_view) | 43 if (render_widget_host_view) |
44 return render_widget_host_view->GetRenderWidgetHost(); | 44 return render_widget_host_view->GetRenderWidgetHost(); |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 output += '\n'; | 338 output += '\n'; |
339 | 339 |
340 file_util::WriteFile( | 340 file_util::WriteFile( |
341 log_path.Append(base_name), output.data(), output.size()); | 341 log_path.Append(base_name), output.data(), output.size()); |
342 } | 342 } |
343 | 343 |
344 void BootTimesLoader::LoginDone() { | 344 void BootTimesLoader::LoginDone() { |
345 AddLoginTimeMarker("LoginDone", true); | 345 AddLoginTimeMarker("LoginDone", true); |
346 RecordCurrentStats(kChromeFirstRender); | 346 RecordCurrentStats(kChromeFirstRender); |
347 registrar_.Remove(this, content::NOTIFICATION_LOAD_START, | 347 registrar_.Remove(this, content::NOTIFICATION_LOAD_START, |
348 NotificationService::AllSources()); | 348 content::NotificationService::AllSources()); |
349 registrar_.Remove(this, content::NOTIFICATION_LOAD_STOP, | 349 registrar_.Remove(this, content::NOTIFICATION_LOAD_STOP, |
350 NotificationService::AllSources()); | 350 content::NotificationService::AllSources()); |
351 registrar_.Remove(this, content::NOTIFICATION_TAB_CONTENTS_DESTROYED, | 351 registrar_.Remove(this, content::NOTIFICATION_TAB_CONTENTS_DESTROYED, |
352 NotificationService::AllSources()); | 352 content::NotificationService::AllSources()); |
353 registrar_.Remove(this, content::NOTIFICATION_RENDER_WIDGET_HOST_DID_PAINT, | 353 registrar_.Remove(this, content::NOTIFICATION_RENDER_WIDGET_HOST_DID_PAINT, |
354 NotificationService::AllSources()); | 354 content::NotificationService::AllSources()); |
355 // Don't swamp the FILE thread right away. | 355 // Don't swamp the FILE thread right away. |
356 BrowserThread::PostDelayedTask( | 356 BrowserThread::PostDelayedTask( |
357 BrowserThread::FILE, FROM_HERE, | 357 BrowserThread::FILE, FROM_HERE, |
358 // This doesn't compile without std::string(...), as | 358 // This doesn't compile without std::string(...), as |
359 // NewRunnableFunction doesn't accept arrays. | 359 // NewRunnableFunction doesn't accept arrays. |
360 base::Bind(WriteTimes, | 360 base::Bind(WriteTimes, |
361 std::string(kLoginTimes), | 361 std::string(kLoginTimes), |
362 std::string(kUmaLogin), | 362 std::string(kUmaLogin), |
363 std::string(kUmaLoginPrefix), | 363 std::string(kUmaLoginPrefix), |
364 login_time_markers_), | 364 login_time_markers_), |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 void BootTimesLoader::RecordChromeMainStats() { | 399 void BootTimesLoader::RecordChromeMainStats() { |
400 RecordStats(kChromeMain, chrome_main_stats_); | 400 RecordStats(kChromeMain, chrome_main_stats_); |
401 } | 401 } |
402 | 402 |
403 void BootTimesLoader::RecordLoginAttempted() { | 403 void BootTimesLoader::RecordLoginAttempted() { |
404 login_time_markers_.clear(); | 404 login_time_markers_.clear(); |
405 AddLoginTimeMarker("LoginStarted", false); | 405 AddLoginTimeMarker("LoginStarted", false); |
406 if (!have_registered_) { | 406 if (!have_registered_) { |
407 have_registered_ = true; | 407 have_registered_ = true; |
408 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_AUTHENTICATION, | 408 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_AUTHENTICATION, |
409 NotificationService::AllSources()); | 409 content::NotificationService::AllSources()); |
410 registrar_.Add(this, content::NOTIFICATION_LOAD_START, | 410 registrar_.Add(this, content::NOTIFICATION_LOAD_START, |
411 NotificationService::AllSources()); | 411 content::NotificationService::AllSources()); |
412 registrar_.Add(this, content::NOTIFICATION_LOAD_STOP, | 412 registrar_.Add(this, content::NOTIFICATION_LOAD_STOP, |
413 NotificationService::AllSources()); | 413 content::NotificationService::AllSources()); |
414 registrar_.Add(this, content::NOTIFICATION_TAB_CONTENTS_DESTROYED, | 414 registrar_.Add(this, content::NOTIFICATION_TAB_CONTENTS_DESTROYED, |
415 NotificationService::AllSources()); | 415 content::NotificationService::AllSources()); |
416 registrar_.Add(this, content::NOTIFICATION_RENDER_WIDGET_HOST_DID_PAINT, | 416 registrar_.Add(this, content::NOTIFICATION_RENDER_WIDGET_HOST_DID_PAINT, |
417 NotificationService::AllSources()); | 417 content::NotificationService::AllSources()); |
418 } | 418 } |
419 } | 419 } |
420 | 420 |
421 void BootTimesLoader::AddLoginTimeMarker( | 421 void BootTimesLoader::AddLoginTimeMarker( |
422 const std::string& marker_name, bool send_to_uma) { | 422 const std::string& marker_name, bool send_to_uma) { |
423 login_time_markers_.push_back(TimeMarker(marker_name, send_to_uma)); | 423 login_time_markers_.push_back(TimeMarker(marker_name, send_to_uma)); |
424 } | 424 } |
425 | 425 |
426 void BootTimesLoader::AddLogoutTimeMarker( | 426 void BootTimesLoader::AddLogoutTimeMarker( |
427 const std::string& marker_name, bool send_to_uma) { | 427 const std::string& marker_name, bool send_to_uma) { |
428 logout_time_markers_.push_back(TimeMarker(marker_name, send_to_uma)); | 428 logout_time_markers_.push_back(TimeMarker(marker_name, send_to_uma)); |
429 } | 429 } |
430 | 430 |
431 void BootTimesLoader::Observe( | 431 void BootTimesLoader::Observe( |
432 int type, | 432 int type, |
433 const content::NotificationSource& source, | 433 const content::NotificationSource& source, |
434 const content::NotificationDetails& details) { | 434 const content::NotificationDetails& details) { |
435 switch (type) { | 435 switch (type) { |
436 case chrome::NOTIFICATION_LOGIN_AUTHENTICATION: { | 436 case chrome::NOTIFICATION_LOGIN_AUTHENTICATION: { |
437 content::Details<AuthenticationNotificationDetails> auth_details(details); | 437 content::Details<AuthenticationNotificationDetails> auth_details(details); |
438 if (auth_details->success()) { | 438 if (auth_details->success()) { |
439 AddLoginTimeMarker("Authenticate", true); | 439 AddLoginTimeMarker("Authenticate", true); |
440 RecordCurrentStats(kLoginSuccess); | 440 RecordCurrentStats(kLoginSuccess); |
441 registrar_.Remove(this, chrome::NOTIFICATION_LOGIN_AUTHENTICATION, | 441 registrar_.Remove(this, chrome::NOTIFICATION_LOGIN_AUTHENTICATION, |
442 NotificationService::AllSources()); | 442 content::NotificationService::AllSources()); |
443 } | 443 } |
444 break; | 444 break; |
445 } | 445 } |
446 case content::NOTIFICATION_LOAD_START: { | 446 case content::NOTIFICATION_LOAD_START: { |
447 NavigationController* tab = | 447 NavigationController* tab = |
448 content::Source<NavigationController>(source).ptr(); | 448 content::Source<NavigationController>(source).ptr(); |
449 RenderWidgetHost* rwh = GetRenderWidgetHost(tab); | 449 RenderWidgetHost* rwh = GetRenderWidgetHost(tab); |
450 DCHECK(rwh); | 450 DCHECK(rwh); |
451 AddLoginTimeMarker("TabLoad-Start: " + GetTabUrl(rwh), false); | 451 AddLoginTimeMarker("TabLoad-Start: " + GetTabUrl(rwh), false); |
452 render_widget_hosts_loading_.insert(rwh); | 452 render_widget_hosts_loading_.insert(rwh); |
(...skipping 24 matching lines...) Expand all Loading... |
477 GetRenderWidgetHost(&tab_contents->controller()); | 477 GetRenderWidgetHost(&tab_contents->controller()); |
478 render_widget_hosts_loading_.erase(render_widget_host); | 478 render_widget_hosts_loading_.erase(render_widget_host); |
479 break; | 479 break; |
480 } | 480 } |
481 default: | 481 default: |
482 break; | 482 break; |
483 } | 483 } |
484 } | 484 } |
485 | 485 |
486 } // namespace chromeos | 486 } // namespace chromeos |
OLD | NEW |