Chromium Code Reviews| Index: chrome/browser/chromeos/login/easy_unlock/short_lived_user_context.cc |
| diff --git a/chrome/browser/chromeos/login/easy_unlock/short_lived_user_context.cc b/chrome/browser/chromeos/login/easy_unlock/short_lived_user_context.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d74e3272ff5d4e2736ab8a2d59ca11c36472ca40 |
| --- /dev/null |
| +++ b/chrome/browser/chromeos/login/easy_unlock/short_lived_user_context.cc |
| @@ -0,0 +1,41 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/chromeos/login/easy_unlock/short_lived_user_context.h" |
| + |
| +#include "base/bind.h" |
| +#include "base/location.h" |
| +#include "base/task_runner.h" |
| +#include "chromeos/login/auth/user_context.h" |
| + |
| +namespace chromeos { |
| + |
| +namespace { |
| + |
| +// The number of minutes that the user context will be stored. |
| +const int64 kUserContextTimeToLiveMin = 10; |
|
tbarzic
2014/10/27 21:44:43
Do you mean Max?
Tim Song
2014/10/31 17:57:37
This should say kUserContextTimeToLiveMinutes.
|
| + |
| +} // namespace |
| + |
| +ShortLivedUserContext::ShortLivedUserContext(const UserContext& user_context, |
| + base::TaskRunner* task_runner) |
| + : user_context_(new UserContext(user_context)), weak_ptr_factory_(this) { |
| + task_runner->PostDelayedTask( |
| + FROM_HERE, |
| + base::Bind(&ShortLivedUserContext::DeleteUserContext, |
| + weak_ptr_factory_.GetWeakPtr()), |
| + base::TimeDelta::FromMinutes(kUserContextTimeToLiveMin)); |
|
tbarzic
2014/10/27 21:44:43
What if the setup exceeds 10 min? Does setup fail
Tim Song
2014/10/31 17:57:37
The UI decision was to show the reauth before the
tbarzic
2014/10/31 18:24:08
Yeah, I was thinking that we may show an error mes
Tim Song
2014/11/01 03:16:52
I can add a check in the app to close the window i
|
| +} |
| + |
| +ShortLivedUserContext::~ShortLivedUserContext() { |
| +} |
| + |
| +void ShortLivedUserContext::DeleteUserContext() { |
| + if (user_context_.get()) { |
| + user_context_->ClearSecrets(); |
| + user_context_.reset(); |
| + } |
| +} |
| + |
| +} // namespace chromeos |