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..98803ff2d8b2e02585f1d4ca692ae22df90a5637 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,50 @@ |
#include "url/gurl.h" |
using content::BrowserThread; |
- |
namespace chromeos { |
struct DoBrowserLaunchOnLocaleLoadedData; |
+namespace { |
+ |
+void ReportCustomFlags(const std::set<std::string>& command_line_difference) { |
+ const about_flags::SwitchesHistogramIDs& 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 about_flags::SwitchesHistogramIDs::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."; |
+ } |
+ VLOG(1) << "ReportCustomFlags(): '" << *it << "', uma_id=" << uma_id; |
+ UMA_HISTOGRAM_SPARSE_SLOWLY("Login.CustomFlags", uma_id); |
Alexei Svitkine (slow)
2014/07/02 17:45:40
Wouldn't this histogram be useful on other platfor
Alexander Alekseev
2014/07/02 17:55:03
thestig@: Do you think it is reasonable to create
Lei Zhang
2014/07/02 19:01:04
Would about_flags_report_custom_flags.cc just have
|
+ } |
+} |
+ |
+} // namespace |
+ |
class LoginUtilsImpl |
: public LoginUtils, |
public base::SupportsWeakPtr<LoginUtilsImpl>, |
@@ -216,16 +256,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); |