Skip to content

Commit

Permalink
crash_keys: Convert keys in //chromecast to the new API.
Browse files Browse the repository at this point in the history
Bug: 598854
Change-Id: Id79de5ef8f24b0dced2ac17cfd5bc1fbe196121e
Reviewed-on: https://chromium-review.googlesource.com/820894
Reviewed-by: Luke Halliwell <halliwell@chromium.org>
Commit-Queue: Robert Sesek <rsesek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#523836}
  • Loading branch information
rsesek authored and Commit Bot committed Dec 13, 2017
1 parent 5fc3b9d commit ef1fb55
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 20 deletions.
12 changes: 6 additions & 6 deletions chromecast/crash/app_state_tracker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "base/lazy_instance.h"
#include "chromecast/crash/cast_crash_keys.h"
#include "components/crash/core/common/crash_key.h"

namespace {

Expand Down Expand Up @@ -45,9 +46,7 @@ std::string AppStateTracker::GetPreviousApp() {
void AppStateTracker::SetLastLaunchedApp(const std::string& app_id) {
GetAppState()->last_launched_app = app_id;

// TODO(slan): Currently SetCrashKeyValue is a no-op on chromecast until
// we add call to InitCrashKeys
base::debug::SetCrashKeyValue(crash_keys::kLastApp, app_id);
crash_keys::last_app.Set(app_id);
}

// static
Expand All @@ -56,9 +55,10 @@ void AppStateTracker::SetCurrentApp(const std::string& app_id) {
app_state->previous_app = app_state->current_app;
app_state->current_app = app_id;

base::debug::SetCrashKeyValue(crash_keys::kCurrentApp, app_id);
base::debug::SetCrashKeyValue(crash_keys::kPreviousApp,
app_state->previous_app);
static crash_reporter::CrashKeyString<64> current_app("current_app");
current_app.Set(app_id);

crash_keys::previous_app.Set(app_state->previous_app);
}

} // namespace chromecast
13 changes: 5 additions & 8 deletions chromecast/crash/cast_crash_keys.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,14 @@

#include "chromecast/crash/cast_crash_keys.h"

#include "base/debug/crash_logging.h"
#include "components/crash/core/common/crash_keys.h"

namespace chromecast {
namespace crash_keys {

const char kLastApp[] = "last_app";
const char kCurrentApp[] = "current_app";
const char kPreviousApp[] = "previous_app";

size_t RegisterCastCrashKeys() {
const base::debug::CrashKey fixed_keys[] = {
{kLastApp, ::crash_keys::kSmallSize},
{kCurrentApp, ::crash_keys::kSmallSize},
{kPreviousApp, ::crash_keys::kSmallSize},

// TODO(sanfin): The following crash keys are copied from
// chrome/common/crash_keys.cc. When http://crbug.com/598854 is fixed,
// remove these and refactor as necessary.
Expand Down Expand Up @@ -48,5 +41,9 @@ size_t RegisterCastCrashKeys() {
::crash_keys::kChunkMaxLength);
}

crash_reporter::CrashKeyString<64> last_app("last_app");

crash_reporter::CrashKeyString<64> previous_app("previous_app");

} // namespace crash_keys
} // namespace chromecast
8 changes: 4 additions & 4 deletions chromecast/crash/cast_crash_keys.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@

#include <stddef.h>

#include "base/debug/crash_logging.h"
#include "components/crash/core/common/crash_key.h"

namespace chromecast {
namespace crash_keys {

size_t RegisterCastCrashKeys();

extern const char kCurrentApp[];
extern const char kLastApp[];
extern const char kPreviousApp[];
extern crash_reporter::CrashKeyString<64> last_app;

extern crash_reporter::CrashKeyString<64> previous_app;

} // namespace chromecast
} // namespace crash_keys
Expand Down
4 changes: 2 additions & 2 deletions chromecast/renderer/cast_content_renderer_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@ void CastContentRendererClient::RenderThreadStarted() {
std::string last_launched_app =
command_line->GetSwitchValueNative(switches::kLastLaunchedApp);
if (!last_launched_app.empty())
base::debug::SetCrashKeyValue(crash_keys::kLastApp, last_launched_app);
crash_keys::last_app.Set(last_launched_app);

std::string previous_app =
command_line->GetSwitchValueNative(switches::kPreviousApp);
if (!previous_app.empty())
base::debug::SetCrashKeyValue(crash_keys::kPreviousApp, previous_app);
crash_keys::previous_app.Set(previous_app);
#endif // !defined(OS_FUCHSIA)
}

Expand Down

0 comments on commit ef1fb55

Please sign in to comment.