Chromium Code Reviews| Index: chrome/browser/chromeos/login/login_utils.cc |
| diff --git a/chrome/browser/chromeos/login/login_utils.cc b/chrome/browser/chromeos/login/login_utils.cc |
| index fafe4398fe5abc26626f9aadd4c18c42f612460f..cf2424116914ab2a874c8c7697f46ca33e642dcd 100644 |
| --- a/chrome/browser/chromeos/login/login_utils.cc |
| +++ b/chrome/browser/chromeos/login/login_utils.cc |
| @@ -19,6 +19,7 @@ |
| #include "base/memory/scoped_ptr.h" |
| #include "base/memory/singleton.h" |
| #include "base/memory/weak_ptr.h" |
| +#include "base/metrics/sparse_histogram.h" |
| #include "base/prefs/pref_member.h" |
| #include "base/prefs/pref_service.h" |
| #include "base/strings/string_util.h" |
| @@ -85,11 +86,51 @@ |
| #include "url/gurl.h" |
| using content::BrowserThread; |
| - |
| namespace chromeos { |
| struct DoBrowserLaunchOnLocaleLoadedData; |
| +namespace { |
| + |
| +void ReportCustomFlags(const std::set<std::string>& command_line_difference) { |
| + const std::map<std::string, int>& switch_histogram_id_map = |
| + about_flags::GetSwitchesHistogramIds(); |
| + for (std::set<std::string>::const_iterator it = |
| + command_line_difference.begin(); |
| + it != command_line_difference.end(); |
| + ++it) { |
| + int uma_id = about_flags::UMA_HISTOGRAM_ID_UNKNOWN_FLAG; |
| + if (it->size() > 2) { |
| + // skip '--' before switch name |
| + std::string switch_name(it->substr(2)); |
| + |
| + // kill value, if any |
| + const size_t value_pos = switch_name.find('='); |
| + if (value_pos != std::string::npos) |
| + switch_name.resize(value_pos); |
| + |
| + const std::map<std::string, int>::const_iterator pos = |
| + switch_histogram_id_map.find(switch_name); |
| + if (pos != switch_histogram_id_map.end()) { |
| + uma_id = pos->second; |
| + } else { |
| + uma_id = about_flags::UMA_HISTOGRAM_ID_UNKNOWN_FLAG; |
| + LOG(ERROR) << "ReportCustomFlags(): flag '" << *it << "' ('" |
| + << switch_name << "') is unknown."; |
| + } |
| + } else { |
| + uma_id = about_flags::UMA_HISTOGRAM_ID_BAD_FLAG_FORMAT; |
| + LOG(ERROR) << "ReportCustomFlags(): flag '" << *it |
| + << "' has incorrect format."; |
| + } |
| + LOG(ERROR) << "ReportCustomFlags(): '" << *it << "', uma_id=" << uma_id; |
| + VLOG(1) << "ReportCustomFlags(): '" << *it << "', uma_id=" << uma_id; |
|
Lei Zhang
2014/06/27 19:46:45
Seems unnecessary to have the LOG(ERROR) and VLOG(
Alexander Alekseev
2014/06/30 15:06:01
Done.
It was a debug print. Removed.
|
| + UMA_HISTOGRAM_SPARSE_SLOWLY("Login.CustomFlags", uma_id); |
| + } |
| +} |
| + |
| +} // namespace |
| + |
| class LoginUtilsImpl |
| : public LoginUtils, |
| public base::SupportsWeakPtr<LoginUtilsImpl>, |
| @@ -216,16 +257,24 @@ void LoginUtilsImpl::DoBrowserLaunchOnLocaleLoadedImpl( |
| about_flags::PrefServiceFlagsStorage flags_storage_(profile->GetPrefs()); |
| about_flags::ConvertFlagsToSwitches(&flags_storage_, &user_flags, |
| about_flags::kAddSentinels); |
| + |
| + std::set<CommandLine::StringType> command_line_difference; |
| + |
| // Only restart if needed and if not going into managed mode. |
| // Don't restart browser if it is not first profile in session. |
| if (UserManager::Get()->GetLoggedInUsers().size() == 1 && |
| !UserManager::Get()->IsLoggedInAsLocallyManagedUser() && |
| !about_flags::AreSwitchesIdenticalToCurrentCommandLine( |
| - user_flags, *CommandLine::ForCurrentProcess())) { |
| + user_flags, |
| + *CommandLine::ForCurrentProcess(), |
| + &command_line_difference)) { |
| CommandLine::StringVector flags; |
| // argv[0] is the program name |CommandLine::NO_PROGRAM|. |
| flags.assign(user_flags.argv().begin() + 1, user_flags.argv().end()); |
| VLOG(1) << "Restarting to apply per-session flags..."; |
| + |
| + ReportCustomFlags(command_line_difference); |
| + |
| DBusThreadManager::Get()->GetSessionManagerClient()->SetFlagsForUser( |
| UserManager::Get()->GetActiveUser()->email(), flags); |
| AttemptRestart(profile); |