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.
5 #ifndef CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_SCOPED_FILE_OPENER_H_
6 #define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_SCOPED_FILE_OPENER_H_
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_interface.h"
17 namespace file_system_provider
{
19 // Opens files and guarantees that they will be closed when the object gets out
20 // of scope. Use instead of manually calling OpenFile and CloseFile, as aborting
21 // of the OpenFile operation is racey and the operation may or may not be
23 class ScopedFileOpener
{
26 ProvidedFileSystemInterface
* file_system
,
27 const base::FilePath
& file_path
,
29 const ProvidedFileSystemInterface::OpenFileCallback
& callback
);
34 scoped_refptr
<Runner
> runner_
;
37 } // namespace file_system_provider
38 } // namespace chromeos
40 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_SCOPED_FILE_OPENER_H_