| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/filesystem/file_system_impl.h" | 5 #include "components/filesystem/file_system_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 FileSystemImpl::~FileSystemImpl() { | 33 FileSystemImpl::~FileSystemImpl() { |
| 34 } | 34 } |
| 35 | 35 |
| 36 void FileSystemImpl::OpenTempDirectory( | 36 void FileSystemImpl::OpenTempDirectory( |
| 37 mojom::DirectoryRequest directory, | 37 mojom::DirectoryRequest directory, |
| 38 const OpenTempDirectoryCallback& callback) { | 38 const OpenTempDirectoryCallback& callback) { |
| 39 // Set only if the |DirectoryImpl| will own a temporary directory. | 39 // Set only if the |DirectoryImpl| will own a temporary directory. |
| 40 std::unique_ptr<base::ScopedTempDir> temp_dir(new base::ScopedTempDir); | 40 std::unique_ptr<base::ScopedTempDir> temp_dir(new base::ScopedTempDir); |
| 41 CHECK(temp_dir->CreateUniqueTempDir()); | 41 CHECK(temp_dir->CreateUniqueTempDir()); |
| 42 | 42 |
| 43 base::FilePath path = temp_dir->path(); | 43 base::FilePath path = temp_dir->GetPath(); |
| 44 scoped_refptr<SharedTempDir> shared_temp_dir = | 44 scoped_refptr<SharedTempDir> shared_temp_dir = |
| 45 new SharedTempDir(std::move(temp_dir)); | 45 new SharedTempDir(std::move(temp_dir)); |
| 46 mojo::MakeStrongBinding(base::MakeUnique<DirectoryImpl>( | 46 mojo::MakeStrongBinding(base::MakeUnique<DirectoryImpl>( |
| 47 path, std::move(shared_temp_dir), lock_table_), | 47 path, std::move(shared_temp_dir), lock_table_), |
| 48 std::move(directory)); | 48 std::move(directory)); |
| 49 callback.Run(mojom::FileError::OK); | 49 callback.Run(mojom::FileError::OK); |
| 50 } | 50 } |
| 51 | 51 |
| 52 void FileSystemImpl::OpenPersistentFileSystem( | 52 void FileSystemImpl::OpenPersistentFileSystem( |
| 53 mojo::InterfaceRequest<mojom::Directory> directory, | 53 mojo::InterfaceRequest<mojom::Directory> directory, |
| 54 const OpenPersistentFileSystemCallback& callback) { | 54 const OpenPersistentFileSystemCallback& callback) { |
| 55 std::unique_ptr<base::ScopedTempDir> temp_dir; | 55 std::unique_ptr<base::ScopedTempDir> temp_dir; |
| 56 base::FilePath path = persistent_dir_; | 56 base::FilePath path = persistent_dir_; |
| 57 if (!base::PathExists(path)) | 57 if (!base::PathExists(path)) |
| 58 base::CreateDirectory(path); | 58 base::CreateDirectory(path); |
| 59 | 59 |
| 60 scoped_refptr<SharedTempDir> shared_temp_dir = | 60 scoped_refptr<SharedTempDir> shared_temp_dir = |
| 61 new SharedTempDir(std::move(temp_dir)); | 61 new SharedTempDir(std::move(temp_dir)); |
| 62 | 62 |
| 63 mojo::MakeStrongBinding(base::MakeUnique<DirectoryImpl>( | 63 mojo::MakeStrongBinding(base::MakeUnique<DirectoryImpl>( |
| 64 path, std::move(shared_temp_dir), lock_table_), | 64 path, std::move(shared_temp_dir), lock_table_), |
| 65 std::move(directory)); | 65 std::move(directory)); |
| 66 callback.Run(mojom::FileError::OK); | 66 callback.Run(mojom::FileError::OK); |
| 67 } | 67 } |
| 68 | 68 |
| 69 } // namespace filesystem | 69 } // namespace filesystem |
| OLD | NEW |