OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "services/user/user_service.h" | 5 #include "services/user/user_service.h" |
6 | 6 |
7 #include "base/files/file.h" | 7 #include "base/files/file.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "components/filesystem/directory_impl.h" | 12 #include "components/filesystem/directory_impl.h" |
13 #include "components/filesystem/lock_table.h" | 13 #include "components/filesystem/lock_table.h" |
14 #include "components/filesystem/public/interfaces/types.mojom.h" | 14 #include "components/filesystem/public/interfaces/types.mojom.h" |
15 #include "services/shell/public/cpp/connection.h" | 15 #include "services/shell/public/cpp/connection.h" |
16 | 16 |
17 namespace user_service { | 17 namespace user_service { |
18 | 18 |
19 UserService::UserService(const base::FilePath& base_user_dir, | 19 UserService::UserService(const base::FilePath& base_user_dir, |
20 const scoped_refptr<filesystem::LockTable>& lock_table) | 20 const scoped_refptr<filesystem::LockTable>& lock_table) |
21 : lock_table_(lock_table), path_(base_user_dir) { | 21 : lock_table_(lock_table), path_(base_user_dir) { |
22 base::CreateDirectory(path_); | 22 base::CreateDirectory(path_); |
23 } | 23 } |
24 | 24 |
25 UserService::~UserService() {} | 25 UserService::~UserService() {} |
26 | 26 |
27 void UserService::GetDirectory(filesystem::DirectoryRequest request, | 27 void UserService::GetDirectory(filesystem::mojom::DirectoryRequest request, |
28 const GetDirectoryCallback& callback) { | 28 const GetDirectoryCallback& callback) { |
29 new filesystem::DirectoryImpl(std::move(request), path_, | 29 new filesystem::DirectoryImpl(std::move(request), path_, |
30 scoped_refptr<filesystem::SharedTempDir>(), | 30 scoped_refptr<filesystem::SharedTempDir>(), |
31 lock_table_); | 31 lock_table_); |
32 callback.Run(); | 32 callback.Run(); |
33 } | 33 } |
34 | 34 |
35 void UserService::GetSubDirectory(const mojo::String& sub_directory_path, | 35 void UserService::GetSubDirectory(const mojo::String& sub_directory_path, |
36 filesystem::DirectoryRequest request, | 36 filesystem::mojom::DirectoryRequest request, |
37 const GetSubDirectoryCallback& callback) { | 37 const GetSubDirectoryCallback& callback) { |
38 // Ensure that we've made |subdirectory| recursively under our user dir. | 38 // Ensure that we've made |subdirectory| recursively under our user dir. |
39 base::FilePath subdir = path_.Append( | 39 base::FilePath subdir = path_.Append( |
40 #if defined(OS_WIN) | 40 #if defined(OS_WIN) |
41 base::UTF8ToWide(sub_directory_path.To<std::string>())); | 41 base::UTF8ToWide(sub_directory_path.To<std::string>())); |
42 #else | 42 #else |
43 sub_directory_path.To<std::string>()); | 43 sub_directory_path.To<std::string>()); |
44 #endif | 44 #endif |
45 base::File::Error error; | 45 base::File::Error error; |
46 if (!base::CreateDirectoryAndGetError(subdir, &error)) { | 46 if (!base::CreateDirectoryAndGetError(subdir, &error)) { |
47 callback.Run(static_cast<filesystem::FileError>(error)); | 47 callback.Run(static_cast<filesystem::mojom::FileError>(error)); |
48 return; | 48 return; |
49 } | 49 } |
50 | 50 |
51 new filesystem::DirectoryImpl(std::move(request), subdir, | 51 new filesystem::DirectoryImpl(std::move(request), subdir, |
52 scoped_refptr<filesystem::SharedTempDir>(), | 52 scoped_refptr<filesystem::SharedTempDir>(), |
53 lock_table_); | 53 lock_table_); |
54 callback.Run(filesystem::FileError::OK); | 54 callback.Run(filesystem::mojom::FileError::OK); |
55 } | 55 } |
56 | 56 |
57 } // namespace user_service | 57 } // namespace user_service |
OLD | NEW |