Skip to content

Commit

Permalink
Add session-type crash keys to Crash Reports
Browse files Browse the repository at this point in the history
If we set a crash key in Ash, but Lacros crashes, the crash key will not
be shown in a crash report. Because of it we need to set session-type
crash key in both Ash and Lacros.

Bug: b/207562010
Change-Id: I6c8cf34407dfc92109807a0fad774252495ec422
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3529211
Reviewed-by: Polina Bondarenko <[email protected]>
Reviewed-by: Roman Sorokin <[email protected]>
Reviewed-by: Roland Bock <[email protected]>
Reviewed-by: Robert Sesek <[email protected]>
Commit-Queue: Irina Fedorova <[email protected]>
Cr-Commit-Position: refs/heads/main@{#983454}
  • Loading branch information
FedorovaIra authored and Chromium LUCI CQ committed Mar 21, 2022
1 parent 06b358a commit b3b2e25
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 1 deletion.
1 change: 1 addition & 0 deletions chromeos/lacros/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ component("lacros") {
"//chromeos/crosapi/mojom",
"//chromeos/process_proxy",
"//chromeos/startup",
"//components/crash/core/common",
"//mojo/public/cpp/bindings",
"//ui/native_theme",
]
Expand Down
1 change: 1 addition & 0 deletions chromeos/lacros/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ include_rules = [
"-content",

"+ui/native_theme",
"+components/crash/core/common",
]
23 changes: 23 additions & 0 deletions chromeos/lacros/lacros_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
#include "chromeos/lacros/system_idle_cache.h"
#include "chromeos/services/machine_learning/public/mojom/machine_learning_service.mojom.h"
#include "chromeos/startup/startup.h"
#include "components/crash/core/common/crash_key.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/platform/platform_channel.h"
#include "mojo/public/cpp/system/invitation.h"
Expand Down Expand Up @@ -112,6 +113,25 @@ crosapi::mojom::BrowserInitParamsPtr ReadStartupBrowserInitParams() {
return result;
}

std::string SessionTypeToString(crosapi::mojom::SessionType session_type) {
switch (session_type) {
case crosapi::mojom::SessionType::kUnknown:
return "unknown";
case crosapi::mojom::SessionType::kRegularSession:
return "regular";
case crosapi::mojom::SessionType::kGuestSession:
return "guest";
case crosapi::mojom::SessionType::kPublicSession:
return "managed-guest-session";
case crosapi::mojom::SessionType::kWebKioskSession:
return "web-kiosk";
case crosapi::mojom::SessionType::kChildSession:
return "child";
case crosapi::mojom::SessionType::kAppKioskSession:
return "chrome-app-kiosk";
}
}

} // namespace

LacrosService::InterfaceEntryBase::InterfaceEntryBase() = default;
Expand Down Expand Up @@ -188,6 +208,9 @@ LacrosService::LacrosService()
weak_factory_.GetWeakPtr()));
}

static crash_reporter::CrashKeyString<32> session_type("session-type");
session_type.Set(SessionTypeToString(init_params_->session_type));

// Short term workaround: if --crosapi-mojo-platform-channel-handle is
// available, close --mojo-platform-channel-handle, and remove it
// from command line. It is for backward compatibility support by
Expand Down
5 changes: 4 additions & 1 deletion components/user_manager/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ component("user_manager") {
"//ui/gfx",
]

deps = [ "//google_apis" ]
deps = [
"//components/crash/core/common",
"//google_apis",
]

defines = [ "USER_MANAGER_IMPLEMENTATION" ]

Expand Down
1 change: 1 addition & 0 deletions components/user_manager/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ include_rules = [
"+ash/constants",
"+components/account_id/account_id.h",
"+components/prefs",
"+components/crash/core/common",
"+google_apis/gaia/gaia_auth_util.h",
"+third_party/skia/include",
"+ui/gfx/codec",
Expand Down
28 changes: 28 additions & 0 deletions components/user_manager/user_manager_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "base/strings/utf_string_conversions.h"
#include "base/task/single_thread_task_runner.h"
#include "base/values.h"
#include "components/crash/core/common/crash_key.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service.h"
#include "components/prefs/scoped_user_pref_update.h"
Expand Down Expand Up @@ -86,6 +87,30 @@ UserType GetStoredUserType(const base::Value* prefs_user_types,
return static_cast<UserType>(int_user_type);
}

std::string UserTypeToString(UserType user_type) {
switch (user_type) {
case USER_TYPE_REGULAR:
return "regular";
case USER_TYPE_CHILD:
return "child";
case USER_TYPE_GUEST:
return "guest";
case USER_TYPE_PUBLIC_ACCOUNT:
return "managed-guest-session";
case USER_TYPE_KIOSK_APP:
return "chrome-app-kiosk";
case USER_TYPE_ARC_KIOSK_APP:
return "arc-kiosk";
case USER_TYPE_WEB_KIOSK_APP:
return "web-kiosk";
case USER_TYPE_ACTIVE_DIRECTORY:
return "active-directory";
case NUM_USER_TYPES:
NOTREACHED();
return "";
}
}

} // namespace

// static
Expand Down Expand Up @@ -235,6 +260,9 @@ void UserManagerBase::UserLoggedIn(const AccountId& account_id,
UMA_HISTOGRAM_ENUMERATION(
"UserManager.LoginUserType", active_user_->GetType(), NUM_USER_TYPES);

static crash_reporter::CrashKeyString<32> session_type("session-type");
session_type.Set(UserTypeToString(active_user_->GetType()));

GetLocalState()->SetString(
kLastLoggedInGaiaUser,
active_user_->HasGaiaAccount() ? account_id.GetUserEmail() : "");
Expand Down

0 comments on commit b3b2e25

Please sign in to comment.