Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(337)

Side by Side Diff: services/user/user_service.cc

Issue 1879233002: Move components\profile_service to services\user (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move3
Patch Set: . Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « services/user/user_service.h ('k') | services/user/user_shell_client.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "components/profile_service/profile_service_impl.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 #include "services/shell/public/cpp/message_loop_ref.h" 16 #include "services/shell/public/cpp/message_loop_ref.h"
17 17
18 namespace profile { 18 namespace user_service {
19 19
20 ProfileServiceImpl::ProfileServiceImpl( 20 UserService::UserService(const base::FilePath& base_user_dir,
21 const base::FilePath& base_profile_dir, 21 const scoped_refptr<filesystem::LockTable>& lock_table)
22 const scoped_refptr<filesystem::LockTable>& lock_table) 22 : lock_table_(lock_table), path_(base_user_dir) {
23 : lock_table_(lock_table), path_(base_profile_dir) {
24 base::CreateDirectory(path_); 23 base::CreateDirectory(path_);
25 } 24 }
26 25
27 ProfileServiceImpl::~ProfileServiceImpl() {} 26 UserService::~UserService() {}
28 27
29 void ProfileServiceImpl::GetDirectory(filesystem::DirectoryRequest request, 28 void UserService::GetDirectory(filesystem::DirectoryRequest request,
30 const GetDirectoryCallback& callback) { 29 const GetDirectoryCallback& callback) {
31 new filesystem::DirectoryImpl(std::move(request), 30 new filesystem::DirectoryImpl(std::move(request),
32 path_, 31 path_,
33 scoped_ptr<base::ScopedTempDir>(), 32 scoped_ptr<base::ScopedTempDir>(),
34 lock_table_); 33 lock_table_);
35 callback.Run(); 34 callback.Run();
36 } 35 }
37 36
38 void ProfileServiceImpl::GetSubDirectory( 37 void UserService::GetSubDirectory(const mojo::String& sub_directory_path,
39 const mojo::String& sub_directory_path, 38 filesystem::DirectoryRequest request,
40 filesystem::DirectoryRequest request, 39 const GetSubDirectoryCallback& callback) {
41 const GetSubDirectoryCallback& callback) { 40 // Ensure that we've made |subdirectory| recursively under our user dir.
42 // Ensure that we've made |subdirectory| recursively under our profile.
43 base::FilePath subdir = path_.Append( 41 base::FilePath subdir = path_.Append(
44 #if defined(OS_WIN) 42 #if defined(OS_WIN)
45 base::UTF8ToWide(sub_directory_path.To<std::string>())); 43 base::UTF8ToWide(sub_directory_path.To<std::string>()));
46 #else 44 #else
47 sub_directory_path.To<std::string>()); 45 sub_directory_path.To<std::string>());
48 #endif 46 #endif
49 base::File::Error error; 47 base::File::Error error;
50 if (!base::CreateDirectoryAndGetError(subdir, &error)) { 48 if (!base::CreateDirectoryAndGetError(subdir, &error)) {
51 callback.Run(static_cast<filesystem::FileError>(error)); 49 callback.Run(static_cast<filesystem::FileError>(error));
52 return; 50 return;
53 } 51 }
54 52
55 new filesystem::DirectoryImpl(std::move(request), subdir, 53 new filesystem::DirectoryImpl(std::move(request), subdir,
56 scoped_ptr<base::ScopedTempDir>(), lock_table_); 54 scoped_ptr<base::ScopedTempDir>(), lock_table_);
57 callback.Run(filesystem::FileError::OK); 55 callback.Run(filesystem::FileError::OK);
58 } 56 }
59 57
60 } // namespace profile 58 } // namespace user_service
OLDNEW
« no previous file with comments | « services/user/user_service.h ('k') | services/user/user_shell_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698