Chromium Code Reviews| Index: chrome/browser/ui/ash/chrome_shell_content_state.cc |
| diff --git a/chrome/browser/ui/ash/chrome_shell_content_state.cc b/chrome/browser/ui/ash/chrome_shell_content_state.cc |
| index 4de2fe820ffdc90203871ca1d4423510ff36cd99..1900dc243ed805f8c49adbac0d741c6c775106ef 100644 |
| --- a/chrome/browser/ui/ash/chrome_shell_content_state.cc |
| +++ b/chrome/browser/ui/ash/chrome_shell_content_state.cc |
| @@ -9,8 +9,35 @@ |
| #include "components/user_manager/user_manager.h" |
| #include "content/public/browser/browser_context.h" |
| -ChromeShellContentState::ChromeShellContentState() {} |
| -ChromeShellContentState::~ChromeShellContentState() {} |
| +// static |
| +ChromeShellContentState* ChromeShellContentState::instance_ = nullptr; |
| + |
| +// static |
| +void ChromeShellContentState::SetInstance(ChromeShellContentState* instance) { |
| + DCHECK(!instance_); |
| + instance_ = instance; |
| +} |
| + |
| +// static |
| +ChromeShellContentState* ChromeShellContentState::GetInstance() { |
| + DCHECK(instance_); |
| + return instance_; |
| +} |
| + |
| +// static |
| +void ChromeShellContentState::DestroyInstance() { |
| + DCHECK(instance_); |
| + delete instance_; |
| + instance_ = nullptr; |
| +} |
| + |
| +ChromeShellContentState::ChromeShellContentState() { |
| + SetInstance(this); |
| +} |
| + |
| +ChromeShellContentState::~ChromeShellContentState() { |
| + DestroyInstance(); |
|
James Cook
2017/01/09 21:07:19
optional: I like to do this:
DCHECK_EQ(this, g_in
riajiang
2017/01/09 23:46:51
Done.
|
| +} |
| content::BrowserContext* ChromeShellContentState::GetActiveBrowserContext() { |
| DCHECK(user_manager::UserManager::Get()->GetLoggedInUsers().size()); |