OLD | NEW |
(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 |
| 24 } // namespace |
| 25 |
| 26 namespace chromecast { |
| 27 |
| 28 // static |
| 29 std::string AppStateTracker::GetLastLaunchedApp() { |
| 30 return GetAppState()->last_launched_app; |
| 31 } |
| 32 |
| 33 // static |
| 34 std::string AppStateTracker::GetCurrentApp() { |
| 35 return GetAppState()->current_app; |
| 36 } |
| 37 |
| 38 // static |
| 39 std::string AppStateTracker::GetPreviousApp() { |
| 40 return GetAppState()->previous_app; |
| 41 } |
| 42 |
| 43 // static |
| 44 void AppStateTracker::SetLastLaunchedApp(const std::string& app_id) { |
| 45 GetAppState()->last_launched_app = app_id; |
| 46 |
| 47 // TODO(slan): Currently SetCrashKeyValue is a no-op on chromecast until |
| 48 // we add call to InitCrashKeys |
| 49 base::debug::SetCrashKeyValue(crash_keys::kLastApp, app_id); |
| 50 } |
| 51 |
| 52 // static |
| 53 void AppStateTracker::SetCurrentApp(const std::string& app_id) { |
| 54 CurrentAppState* app_state = GetAppState(); |
| 55 app_state->previous_app = app_state->current_app; |
| 56 app_state->current_app = app_id; |
| 57 |
| 58 base::debug::SetCrashKeyValue(crash_keys::kCurrentApp, app_id); |
| 59 base::debug::SetCrashKeyValue(crash_keys::kPreviousApp, |
| 60 app_state->previous_app); |
| 61 } |
| 62 |
| 63 } // namespace chromecast |
OLD | NEW |