| Index: components/profile_service/profile_service_impl.cc
|
| diff --git a/components/profile_service/profile_service_impl.cc b/components/profile_service/profile_service_impl.cc
|
| index b6239dd706459860cd7bc7d52bf90d00d965cbfe..d5ee319f8d4520be38fcb377a65fd6ebc58093e6 100644
|
| --- a/components/profile_service/profile_service_impl.cc
|
| +++ b/components/profile_service/profile_service_impl.cc
|
| @@ -4,36 +4,67 @@
|
|
|
| #include "components/profile_service/profile_service_impl.h"
|
|
|
| +#include "base/files/file.h"
|
| #include "base/files/file_path.h"
|
| #include "base/files/file_util.h"
|
| #include "base/files/scoped_temp_dir.h"
|
| +#include "base/strings/utf_string_conversions.h"
|
| #include "components/filesystem/directory_impl.h"
|
| #include "components/filesystem/lock_table.h"
|
| +#include "components/filesystem/public/interfaces/types.mojom.h"
|
| #include "mojo/shell/public/cpp/connection.h"
|
| +#include "mojo/shell/public/cpp/message_loop_ref.h"
|
|
|
| namespace profile {
|
|
|
| ProfileServiceImpl::ProfileServiceImpl(
|
| mojo::Connection* connection,
|
| mojo::InterfaceRequest<ProfileService> request,
|
| - base::FilePath base_profile_dir,
|
| + scoped_ptr<mojo::MessageLoopRef> ref,
|
| + const base::FilePath& base_profile_dir,
|
| filesystem::LockTable* lock_table)
|
| - : binding_(this, std::move(request)),
|
| + : message_loop_ref_(std::move(ref)),
|
| + binding_(this, std::move(request)),
|
| lock_table_(lock_table),
|
| path_(base_profile_dir) {
|
| - if (!base::PathExists(path_))
|
| - base::CreateDirectory(path_);
|
| + base::CreateDirectory(path_);
|
| }
|
|
|
| -ProfileServiceImpl::~ProfileServiceImpl() {
|
| -}
|
| +ProfileServiceImpl::~ProfileServiceImpl() {}
|
|
|
| void ProfileServiceImpl::GetDirectory(
|
| - mojo::InterfaceRequest<filesystem::Directory> request) {
|
| + mojo::InterfaceRequest<filesystem::Directory> request,
|
| + const GetDirectoryCallback& callback) {
|
| new filesystem::DirectoryImpl(std::move(request),
|
| path_,
|
| scoped_ptr<base::ScopedTempDir>(),
|
| lock_table_);
|
| + callback.Run();
|
| +}
|
| +
|
| +void ProfileServiceImpl::GetSubDirectory(
|
| + const mojo::String& dir_name,
|
| + mojo::InterfaceRequest<filesystem::Directory> request,
|
| + const GetSubDirectoryCallback& callback) {
|
| + // Ensure that we've made |subdirectory| recursively under our profile.
|
| + base::FilePath subdir =
|
| + path_.Append(
|
| +#if defined(OS_WIN)
|
| + base::UTF8ToWide(dir_name.To<std::string>()));
|
| +#else
|
| + dir_name.To<std::string>());
|
| +#endif
|
| + base::File::Error error;
|
| + if (!base::CreateDirectoryAndGetError(subdir, &error)) {
|
| + callback.Run(static_cast<filesystem::FileError>(error));
|
| + return;
|
| + }
|
| +
|
| + new filesystem::DirectoryImpl(std::move(request),
|
| + subdir,
|
| + scoped_ptr<base::ScopedTempDir>(),
|
| + lock_table_);
|
| + callback.Run(filesystem::FileError::OK);
|
| }
|
|
|
| } // namespace profile
|
|
|