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

Side by Side Diff: chromecast/crash/app_state_tracker.cc

Issue 1154383006: Adding crash utilities to chromecast/crash. (Closed) Base URL: https://eureka-internal.googlesource.com/chromium/src@master
Patch Set: Lots of formatting changes and BUILD.gn updates. Created 5 years, 6 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
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chromecast/crash/app_state_tracker.h"
6
7 #include "base/lazy_instance.h"
8 #include "chromecast/crash/cast_crash_keys.h"
9
10 namespace {
11
12 struct CurrentAppState {
13 std::string previous_app;
14 std::string current_app;
15 std::string last_launched_app;
16 };
17
18 base::LazyInstance<CurrentAppState> g_app_state = LAZY_INSTANCE_INITIALIZER;
19
20 CurrentAppState* GetAppState() {
21 return g_app_state.Pointer();
22 }
23 }
gunsch 2015/06/10 16:33:30 // namespace
24
25 namespace chromecast {
26
27 // static
28 std::string AppStateTracker::GetLastLaunchedApp() {
29 return GetAppState()->last_launched_app;
30 }
31
32 // static
33 std::string AppStateTracker::GetCurrentApp() {
34 return GetAppState()->current_app;
35 }
36
37 // static
38 std::string AppStateTracker::GetPreviousApp() {
39 return GetAppState()->previous_app;
40 }
41
42 // static
43 void AppStateTracker::SetLastLaunchedApp(const std::string& app_id) {
44 GetAppState()->last_launched_app = app_id;
45
46 // TODO(slan): Currently SetCrashKeyValue is a no-op on chromecast until
47 // we add call to InitCrashKeys
48 base::debug::SetCrashKeyValue(crash_keys::kLastApp, app_id);
49 }
50
51 // static
52 void AppStateTracker::SetCurrentApp(const std::string& app_id) {
53 CurrentAppState* app_state = GetAppState();
54 app_state->previous_app = app_state->current_app;
55 app_state->current_app = app_id;
56
57 base::debug::SetCrashKeyValue(crash_keys::kCurrentApp, app_id);
58 base::debug::SetCrashKeyValue(crash_keys::kPreviousApp,
59 app_state->previous_app);
60 }
61
62 } // namespace chromecast
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698