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

Side by Side Diff: components/profile_service/profile_service_impl.cc

Issue 1737933002: mojo leveldb: Get profile and leveldb connected to DOMStorageContext. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove stray mark. Created 4 years, 9 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
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 "components/profile_service/profile_service_impl.h"
6 6
7 #include "base/files/file.h"
7 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
8 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
9 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
11 #include "base/strings/utf_string_conversions.h"
10 #include "components/filesystem/directory_impl.h" 12 #include "components/filesystem/directory_impl.h"
11 #include "components/filesystem/lock_table.h" 13 #include "components/filesystem/lock_table.h"
14 #include "components/filesystem/public/interfaces/types.mojom.h"
12 #include "mojo/shell/public/cpp/connection.h" 15 #include "mojo/shell/public/cpp/connection.h"
16 #include "mojo/shell/public/cpp/message_loop_ref.h"
13 17
14 namespace profile { 18 namespace profile {
15 19
16 ProfileServiceImpl::ProfileServiceImpl( 20 ProfileServiceImpl::ProfileServiceImpl(
17 mojo::Connection* connection, 21 const base::FilePath& base_profile_dir,
18 mojo::InterfaceRequest<ProfileService> request, 22 const scoped_refptr<filesystem::LockTable>& lock_table)
19 base::FilePath base_profile_dir, 23 : lock_table_(lock_table), path_(base_profile_dir) {
20 filesystem::LockTable* lock_table) 24 base::CreateDirectory(path_);
21 : binding_(this, std::move(request)),
22 lock_table_(lock_table),
23 path_(base_profile_dir) {
24 if (!base::PathExists(path_))
25 base::CreateDirectory(path_);
26 } 25 }
27 26
28 ProfileServiceImpl::~ProfileServiceImpl() { 27 ProfileServiceImpl::~ProfileServiceImpl() {}
29 }
30 28
31 void ProfileServiceImpl::GetDirectory( 29 void ProfileServiceImpl::GetDirectory(filesystem::DirectoryRequest request,
32 mojo::InterfaceRequest<filesystem::Directory> request) { 30 const GetDirectoryCallback& callback) {
33 new filesystem::DirectoryImpl(std::move(request), 31 new filesystem::DirectoryImpl(std::move(request),
34 path_, 32 path_,
35 scoped_ptr<base::ScopedTempDir>(), 33 scoped_ptr<base::ScopedTempDir>(),
36 lock_table_); 34 lock_table_);
35 callback.Run();
36 }
37
38 void ProfileServiceImpl::GetSubDirectory(
39 const mojo::String& sub_directory_path,
40 filesystem::DirectoryRequest request,
41 const GetSubDirectoryCallback& callback) {
42 // Ensure that we've made |subdirectory| recursively under our profile.
43 base::FilePath subdir = path_.Append(
44 #if defined(OS_WIN)
45 base::UTF8ToWide(sub_directory_path.To<std::string>()));
46 #else
47 sub_directory_path.To<std::string>());
48 #endif
49 base::File::Error error;
50 if (!base::CreateDirectoryAndGetError(subdir, &error)) {
51 callback.Run(static_cast<filesystem::FileError>(error));
52 return;
53 }
54
55 new filesystem::DirectoryImpl(std::move(request), subdir,
56 scoped_ptr<base::ScopedTempDir>(), lock_table_);
57 callback.Run(filesystem::FileError::OK);
37 } 58 }
38 59
39 } // namespace profile 60 } // namespace profile
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698