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

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

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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 | Annotate | Revision Log
OLDNEW
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"
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 335
336 void BootTimesLoader::RecordChromeMainStats() { 336 void BootTimesLoader::RecordChromeMainStats() {
337 RecordStats(kChromeMain, chrome_main_stats_); 337 RecordStats(kChromeMain, chrome_main_stats_);
338 } 338 }
339 339
340 void BootTimesLoader::RecordLoginAttempted() { 340 void BootTimesLoader::RecordLoginAttempted() {
341 login_time_markers_.clear(); 341 login_time_markers_.clear();
342 AddLoginTimeMarker("LoginStarted", false); 342 AddLoginTimeMarker("LoginStarted", false);
343 if (!have_registered_) { 343 if (!have_registered_) {
344 have_registered_ = true; 344 have_registered_ = true;
345 registrar_.Add(this, NotificationType::LOAD_START, 345 registrar_.Add(this, chrome::LOAD_START,
346 NotificationService::AllSources()); 346 NotificationService::AllSources());
347 registrar_.Add(this, NotificationType::LOGIN_AUTHENTICATION, 347 registrar_.Add(this, chrome::LOGIN_AUTHENTICATION,
348 NotificationService::AllSources()); 348 NotificationService::AllSources());
349 } 349 }
350 } 350 }
351 351
352 void BootTimesLoader::AddLoginTimeMarker( 352 void BootTimesLoader::AddLoginTimeMarker(
353 const std::string& marker_name, bool send_to_uma) { 353 const std::string& marker_name, bool send_to_uma) {
354 login_time_markers_.push_back(TimeMarker(marker_name, send_to_uma)); 354 login_time_markers_.push_back(TimeMarker(marker_name, send_to_uma));
355 } 355 }
356 356
357 void BootTimesLoader::AddLogoutTimeMarker( 357 void BootTimesLoader::AddLogoutTimeMarker(
358 const std::string& marker_name, bool send_to_uma) { 358 const std::string& marker_name, bool send_to_uma) {
359 logout_time_markers_.push_back(TimeMarker(marker_name, send_to_uma)); 359 logout_time_markers_.push_back(TimeMarker(marker_name, send_to_uma));
360 } 360 }
361 361
362 void BootTimesLoader::Observe( 362 void BootTimesLoader::Observe(
363 NotificationType type, 363 int type,
364 const NotificationSource& source, 364 const NotificationSource& source,
365 const NotificationDetails& details) { 365 const NotificationDetails& details) {
366 if (type == NotificationType::LOGIN_AUTHENTICATION) { 366 if (type == chrome::LOGIN_AUTHENTICATION) {
367 Details<AuthenticationNotificationDetails> auth_details(details); 367 Details<AuthenticationNotificationDetails> auth_details(details);
368 if (auth_details->success()) { 368 if (auth_details->success()) {
369 AddLoginTimeMarker("Authenticate", true); 369 AddLoginTimeMarker("Authenticate", true);
370 RecordCurrentStats(kLoginSuccess); 370 RecordCurrentStats(kLoginSuccess);
371 registrar_.Remove(this, NotificationType::LOGIN_AUTHENTICATION, 371 registrar_.Remove(this, chrome::LOGIN_AUTHENTICATION,
372 NotificationService::AllSources()); 372 NotificationService::AllSources());
373 } 373 }
374 } else if (type == NotificationType::LOAD_START) { 374 } else if (type == chrome::LOAD_START) {
375 // Make sure it's not some page load initiated by OOBE/login screen. 375 // Make sure it's not some page load initiated by OOBE/login screen.
376 if (!UserManager::Get()->user_is_logged_in()) 376 if (!UserManager::Get()->user_is_logged_in())
377 return; 377 return;
378 // Only log for first tab to render. Make sure this is only done once. 378 // 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 379 // If the network isn't connected we'll get a second LOAD_START once it is
380 // and the page is reloaded. 380 // and the page is reloaded.
381 if (NetworkStateNotifier::GetInstance()->is_connected()) { 381 if (NetworkStateNotifier::GetInstance()->is_connected()) {
382 // Post difference between first tab and login success time. 382 // Post difference between first tab and login success time.
383 AddLoginTimeMarker("LoginDone", true); 383 AddLoginTimeMarker("LoginDone", true);
384 RecordCurrentStats(kChromeFirstRender); 384 RecordCurrentStats(kChromeFirstRender);
385 // Post chrome first render stat. 385 // Post chrome first render stat.
386 registrar_.Remove(this, NotificationType::LOAD_START, 386 registrar_.Remove(this, chrome::LOAD_START,
387 NotificationService::AllSources()); 387 NotificationService::AllSources());
388 // Don't swamp the FILE thread right away. 388 // Don't swamp the FILE thread right away.
389 BrowserThread::PostDelayedTask( 389 BrowserThread::PostDelayedTask(
390 BrowserThread::FILE, FROM_HERE, 390 BrowserThread::FILE, FROM_HERE,
391 // This doesn't compile without std::string(...), as 391 // This doesn't compile without std::string(...), as
392 // NewRunnableFunction doesn't accept arrays. 392 // NewRunnableFunction doesn't accept arrays.
393 NewRunnableFunction(WriteTimes, 393 NewRunnableFunction(WriteTimes,
394 std::string(kLoginTimes), 394 std::string(kLoginTimes),
395 std::string(kUmaLogin), 395 std::string(kUmaLogin),
396 std::string(kUmaLoginPrefix), 396 std::string(kUmaLoginPrefix),
397 login_time_markers_), 397 login_time_markers_),
398 kLoginTimeWriteDelayMs); 398 kLoginTimeWriteDelayMs);
399 have_registered_ = false; 399 have_registered_ = false;
400 } else { 400 } else {
401 AddLoginTimeMarker("LoginRenderNoNetwork", false); 401 AddLoginTimeMarker("LoginRenderNoNetwork", false);
402 } 402 }
403 } 403 }
404 } 404 }
405 405
406 } // namespace chromeos 406 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698