1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/security/sandbox/chromium/base/critical_closure.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,37 @@ 1.4 +// Copyright (c) 2012 The Chromium Authors. All rights reserved. 1.5 +// Use of this source code is governed by a BSD-style license that can be 1.6 +// found in the LICENSE file. 1.7 + 1.8 +#ifndef BASE_CRITICAL_CLOSURE_H_ 1.9 +#define BASE_CRITICAL_CLOSURE_H_ 1.10 + 1.11 +#include "base/callback.h" 1.12 + 1.13 +namespace base { 1.14 + 1.15 +// Returns a closure that will continue to run for a period of time when the 1.16 +// application goes to the background if possible on platforms where 1.17 +// applications don't execute while backgrounded, otherwise the original task is 1.18 +// returned. 1.19 +// 1.20 +// Example: 1.21 +// file_message_loop_proxy_->PostTask( 1.22 +// FROM_HERE, 1.23 +// MakeCriticalClosure(base::Bind(&WriteToDiskTask, path_, data))); 1.24 +// 1.25 +// Note new closures might be posted in this closure. If the new closures need 1.26 +// background running time, |MakeCriticalClosure| should be applied on them 1.27 +// before posting. 1.28 +#if defined(OS_IOS) 1.29 +base::Closure MakeCriticalClosure(const base::Closure& closure); 1.30 +#else 1.31 +inline base::Closure MakeCriticalClosure(const base::Closure& closure) { 1.32 + // No-op for platforms where the application does not need to acquire 1.33 + // background time for closures to finish when it goes into the background. 1.34 + return closure; 1.35 +} 1.36 +#endif // !defined(OS_IOS) 1.37 + 1.38 +} // namespace base 1.39 + 1.40 +#endif // BASE_CRITICAL_CLOSURE_H_