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

Side by Side Diff: chrome/browser/chromeos/login/login_utils.cc

Issue 344883002: Collect UMA statistics on which chrome://flags lead to chrome restart on ChromeOS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove "enable-accessibility-script-injection" from about_flags.cc Created 6 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
« no previous file with comments | « chrome/browser/about_flags_unittest.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/login/login_utils.h" 5 #include "chrome/browser/chromeos/login/login_utils.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/base_paths.h" 11 #include "base/base_paths.h"
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
15 #include "base/file_util.h" 15 #include "base/file_util.h"
16 #include "base/files/file_path.h" 16 #include "base/files/file_path.h"
17 #include "base/location.h" 17 #include "base/location.h"
18 #include "base/memory/ref_counted.h" 18 #include "base/memory/ref_counted.h"
19 #include "base/memory/scoped_ptr.h" 19 #include "base/memory/scoped_ptr.h"
20 #include "base/memory/singleton.h" 20 #include "base/memory/singleton.h"
21 #include "base/memory/weak_ptr.h" 21 #include "base/memory/weak_ptr.h"
22 #include "base/metrics/sparse_histogram.h"
22 #include "base/prefs/pref_member.h" 23 #include "base/prefs/pref_member.h"
23 #include "base/prefs/pref_service.h" 24 #include "base/prefs/pref_service.h"
24 #include "base/strings/string_util.h" 25 #include "base/strings/string_util.h"
25 #include "base/strings/utf_string_conversions.h" 26 #include "base/strings/utf_string_conversions.h"
26 #include "base/synchronization/lock.h" 27 #include "base/synchronization/lock.h"
27 #include "base/sys_info.h" 28 #include "base/sys_info.h"
28 #include "base/task_runner_util.h" 29 #include "base/task_runner_util.h"
29 #include "base/threading/worker_pool.h" 30 #include "base/threading/worker_pool.h"
30 #include "base/time/time.h" 31 #include "base/time/time.h"
31 #include "chrome/browser/about_flags.h" 32 #include "chrome/browser/about_flags.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 #include "components/signin/core/browser/signin_manager.h" 79 #include "components/signin/core/browser/signin_manager.h"
79 #include "content/public/browser/browser_thread.h" 80 #include "content/public/browser/browser_thread.h"
80 #include "content/public/browser/notification_service.h" 81 #include "content/public/browser/notification_service.h"
81 #include "google_apis/gaia/gaia_auth_consumer.h" 82 #include "google_apis/gaia/gaia_auth_consumer.h"
82 #include "net/base/network_change_notifier.h" 83 #include "net/base/network_change_notifier.h"
83 #include "net/url_request/url_request_context.h" 84 #include "net/url_request/url_request_context.h"
84 #include "net/url_request/url_request_context_getter.h" 85 #include "net/url_request/url_request_context_getter.h"
85 #include "url/gurl.h" 86 #include "url/gurl.h"
86 87
87 using content::BrowserThread; 88 using content::BrowserThread;
88
89 namespace chromeos { 89 namespace chromeos {
90 90
91 struct DoBrowserLaunchOnLocaleLoadedData; 91 struct DoBrowserLaunchOnLocaleLoadedData;
92 92
93 namespace {
94
95 void ReportCustomFlags(const std::set<std::string>& command_line_difference) {
96 const about_flags::SwitchesHistogramIDs& switch_histogram_id_map =
97 about_flags::GetSwitchesHistogramIds();
98 for (std::set<std::string>::const_iterator it =
99 command_line_difference.begin();
100 it != command_line_difference.end();
101 ++it) {
102 int uma_id = about_flags::UMA_HISTOGRAM_ID_UNKNOWN_FLAG;
103 if (it->size() > 2) {
104 // skip '--' before switch name
105 std::string switch_name(it->substr(2));
106
107 // kill value, if any
108 const size_t value_pos = switch_name.find('=');
109 if (value_pos != std::string::npos)
110 switch_name.resize(value_pos);
111
112 const about_flags::SwitchesHistogramIDs::const_iterator pos =
113 switch_histogram_id_map.find(switch_name);
114 if (pos != switch_histogram_id_map.end()) {
115 uma_id = pos->second;
116 } else {
117 uma_id = about_flags::UMA_HISTOGRAM_ID_UNKNOWN_FLAG;
118 LOG(ERROR) << "ReportCustomFlags(): flag '" << *it << "' ('"
119 << switch_name << "') is unknown.";
120 }
121 } else {
122 uma_id = about_flags::UMA_HISTOGRAM_ID_BAD_FLAG_FORMAT;
123 LOG(ERROR) << "ReportCustomFlags(): flag '" << *it
124 << "' has incorrect format.";
125 }
126 VLOG(1) << "ReportCustomFlags(): '" << *it << "', uma_id=" << uma_id;
127 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
128 }
129 }
130
131 } // namespace
132
93 class LoginUtilsImpl 133 class LoginUtilsImpl
94 : public LoginUtils, 134 : public LoginUtils,
95 public base::SupportsWeakPtr<LoginUtilsImpl>, 135 public base::SupportsWeakPtr<LoginUtilsImpl>,
96 public SessionManager::Delegate { 136 public SessionManager::Delegate {
97 public: 137 public:
98 LoginUtilsImpl() 138 LoginUtilsImpl()
99 : delegate_(NULL) { 139 : delegate_(NULL) {
100 } 140 }
101 141
102 virtual ~LoginUtilsImpl() { 142 virtual ~LoginUtilsImpl() {
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 LoginDisplayHost* login_host) { 249 LoginDisplayHost* login_host) {
210 if (!UserManager::Get()->GetCurrentUserFlow()->ShouldLaunchBrowser()) { 250 if (!UserManager::Get()->GetCurrentUserFlow()->ShouldLaunchBrowser()) {
211 UserManager::Get()->GetCurrentUserFlow()->LaunchExtraSteps(profile); 251 UserManager::Get()->GetCurrentUserFlow()->LaunchExtraSteps(profile);
212 return; 252 return;
213 } 253 }
214 254
215 CommandLine user_flags(CommandLine::NO_PROGRAM); 255 CommandLine user_flags(CommandLine::NO_PROGRAM);
216 about_flags::PrefServiceFlagsStorage flags_storage_(profile->GetPrefs()); 256 about_flags::PrefServiceFlagsStorage flags_storage_(profile->GetPrefs());
217 about_flags::ConvertFlagsToSwitches(&flags_storage_, &user_flags, 257 about_flags::ConvertFlagsToSwitches(&flags_storage_, &user_flags,
218 about_flags::kAddSentinels); 258 about_flags::kAddSentinels);
259
260 std::set<CommandLine::StringType> command_line_difference;
261
219 // Only restart if needed and if not going into managed mode. 262 // Only restart if needed and if not going into managed mode.
220 // Don't restart browser if it is not first profile in session. 263 // Don't restart browser if it is not first profile in session.
221 if (UserManager::Get()->GetLoggedInUsers().size() == 1 && 264 if (UserManager::Get()->GetLoggedInUsers().size() == 1 &&
222 !UserManager::Get()->IsLoggedInAsLocallyManagedUser() && 265 !UserManager::Get()->IsLoggedInAsLocallyManagedUser() &&
223 !about_flags::AreSwitchesIdenticalToCurrentCommandLine( 266 !about_flags::AreSwitchesIdenticalToCurrentCommandLine(
224 user_flags, *CommandLine::ForCurrentProcess())) { 267 user_flags,
268 *CommandLine::ForCurrentProcess(),
269 &command_line_difference)) {
225 CommandLine::StringVector flags; 270 CommandLine::StringVector flags;
226 // argv[0] is the program name |CommandLine::NO_PROGRAM|. 271 // argv[0] is the program name |CommandLine::NO_PROGRAM|.
227 flags.assign(user_flags.argv().begin() + 1, user_flags.argv().end()); 272 flags.assign(user_flags.argv().begin() + 1, user_flags.argv().end());
228 VLOG(1) << "Restarting to apply per-session flags..."; 273 VLOG(1) << "Restarting to apply per-session flags...";
274
275 ReportCustomFlags(command_line_difference);
276
229 DBusThreadManager::Get()->GetSessionManagerClient()->SetFlagsForUser( 277 DBusThreadManager::Get()->GetSessionManagerClient()->SetFlagsForUser(
230 UserManager::Get()->GetActiveUser()->email(), flags); 278 UserManager::Get()->GetActiveUser()->email(), flags);
231 AttemptRestart(profile); 279 AttemptRestart(profile);
232 return; 280 return;
233 } 281 }
234 282
235 if (login_host) { 283 if (login_host) {
236 login_host->SetStatusAreaVisible(true); 284 login_host->SetStatusAreaVisible(true);
237 login_host->BeforeSessionStart(); 285 login_host->BeforeSessionStart();
238 } 286 }
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 CrosSettings* cros_settings = CrosSettings::Get(); 448 CrosSettings* cros_settings = CrosSettings::Get();
401 bool allow_new_user = false; 449 bool allow_new_user = false;
402 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); 450 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user);
403 if (allow_new_user) 451 if (allow_new_user)
404 return true; 452 return true;
405 return cros_settings->FindEmailInList( 453 return cros_settings->FindEmailInList(
406 kAccountsPrefUsers, username, wildcard_match); 454 kAccountsPrefUsers, username, wildcard_match);
407 } 455 }
408 456
409 } // namespace chromeos 457 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/about_flags_unittest.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698