Created
July 2, 2019 09:11
-
-
Save oyiptong/b2c43907bab0af0280ddd6eab0128d75 to your computer and use it in GitHub Desktop.
Curring a lambda
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// -- snip -- | |
manager()->CreateSwapFileForURL( | |
url(), | |
base::BindOnce([](CreateFileWriterCallback callback) { | |
base::File::Error result, | |
const storage::FileSystemURL& swap_url) { | |
// Canned answer for now. | |
std::move(callback).Run( | |
NativeFileSystemError::New(base::File::FILE_OK), | |
nullptr); | |
}, std::move(callback))); | |
// -- snip -- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// -- snip -- | |
template <typename CallbackArgType> | |
void NativeFileSystemManagerImpl::CreateSwapFileForURL( | |
const storage::FileSystemURL& url, | |
base::OnceCallback<void(CallbackArgType)> callback) { | |
base::FilePath swap_path = base::GetUniquePath( | |
base::FilePath(url.path()).AddExtensionASCII(".crswap")); | |
auto url_and_handle = CreateFileSystemURLFromPath(url.origin(), swap_path); | |
auto swap_url = url_and_handle.url; | |
operation_runner()->CreateFile( | |
swap_url, | |
/*exclusive*/true, | |
base::BindOnce(&NativeFileSystemManagerImpl::DidCreateSwapFile, | |
weak_factory_.GetWeakPtr(), | |
std::move(swap_url), | |
std::move(callback))); | |
} | |
template <typename CallbackArgType> | |
void NativeFileSystemManagerImpl::DidCreateSwapFile( | |
const storage::FileSystemURL& swap_url, | |
base::OnceCallback<void(CallbackArgType)> callback, | |
base::File::Error result) { | |
std::move(callback).Run(std::move(result), std::move(swap_url)); | |
} | |
// -- snip -- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment