User service is actually the file service.
My original thought was that this service could host a lot of user-specific components. However I began to think that this would make this service as monolithic/problematic as Profile, which kind of defeats the purpose. Having a discrete user-scoped file system service seems valuable in and of itself.
Individual profile-specific services should just be their own services - e.g. preferences, which can be run with the profile's service user-id, so you end up with a preferences instance per profile.
[email protected]
Committed: https://crrev.com/23fcb4aca6178fa8d6c125db778f62fce34a7c67
Review-Url: https://codereview.chromium.org/2207663003
Cr-Original-Commit-Position: refs/heads/master@{#411357}
Cr-Commit-Position: refs/heads/master@{#411475}
diff --git a/content/browser/BUILD.gn b/content/browser/BUILD.gn
index 1bb4c8d..6c463c9 100644
--- a/content/browser/BUILD.gn
+++ b/content/browser/BUILD.gn
@@ -84,14 +84,14 @@
"//mojo/public/js",
"//net",
"//net:extras",
+ "//services/file:lib",
+ "//services/file/public/cpp",
+ "//services/file/public/interfaces",
"//services/shell",
"//services/shell/public/cpp",
"//services/shell/public/interfaces",
"//services/shell/runner/common",
"//services/shell/runner/host:lib",
- "//services/user:lib",
- "//services/user/public/cpp",
- "//services/user/public/interfaces",
"//skia",
"//sql",
"//storage/browser",
diff --git a/content/browser/browser_context.cc b/content/browser/browser_context.cc
index 7cbb5f4..6ca86e7 100644
--- a/content/browser/browser_context.cc
+++ b/content/browser/browser_context.cc
@@ -38,12 +38,12 @@
#include "net/ssl/channel_id_store.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_getter.h"
+#include "services/file/file_service.h"
+#include "services/file/public/cpp/constants.h"
+#include "services/file/user_id_map.h"
#include "services/shell/public/cpp/connection.h"
#include "services/shell/public/cpp/connector.h"
#include "services/shell/public/interfaces/service.mojom.h"
-#include "services/user/public/cpp/constants.h"
-#include "services/user/user_id_map.h"
-#include "services/user/user_shell_client.h"
#include "storage/browser/database/database_tracker.h"
#include "storage/browser/fileapi/external_mount_points.h"
@@ -403,8 +403,8 @@
ShellUserIdHolder* holder = static_cast<ShellUserIdHolder*>(
browser_context->GetUserData(kMojoShellUserId));
if (holder)
- user_service::ForgetShellUserIdUserDirAssociation(holder->user_id());
- user_service::AssociateShellUserIdWithUserDir(new_id, path);
+ file::ForgetShellUserIdUserDirAssociation(holder->user_id());
+ file::AssociateShellUserIdWithUserDir(new_id, path);
RemoveBrowserContextFromUserIdMap(browser_context);
g_user_id_to_context.Get()[new_id] = browser_context;
browser_context->SetUserData(kMojoShellUserId,
@@ -443,10 +443,10 @@
switches::kMojoLocalStorage)) {
MojoApplicationInfo info;
info.application_factory =
- base::Bind(&user_service::CreateUserService,
+ base::Bind(&file::CreateFileService,
BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE),
BrowserThread::GetTaskRunnerForThread(BrowserThread::DB));
- connection->AddEmbeddedService(user_service::kUserServiceName, info);
+ connection->AddEmbeddedService(file::kFileServiceName, info);
}
}
}
diff --git a/content/browser/dom_storage/dom_storage_context_wrapper.cc b/content/browser/dom_storage/dom_storage_context_wrapper.cc
index 6c1cef29..9f52d772 100644
--- a/content/browser/dom_storage/dom_storage_context_wrapper.cc
+++ b/content/browser/dom_storage/dom_storage_context_wrapper.cc
@@ -27,10 +27,10 @@
#include "content/public/browser/local_storage_usage_info.h"
#include "content/public/browser/session_storage_usage_info.h"
#include "mojo/common/common_type_converters.h"
+#include "services/file/public/cpp/constants.h"
+#include "services/file/public/interfaces/file_system.mojom.h"
#include "services/shell/public/cpp/connection.h"
#include "services/shell/public/cpp/connector.h"
-#include "services/user/public/cpp/constants.h"
-#include "services/user/public/interfaces/user_service.mojom.h"
namespace content {
namespace {
@@ -100,7 +100,7 @@
void OnUserServiceConnectionComplete() {
CHECK_EQ(shell::mojom::ConnectResult::SUCCEEDED,
- user_service_connection_->GetResult());
+ file_service_connection_->GetResult());
}
void OnUserServiceConnectionError() {
@@ -129,9 +129,9 @@
CONNECTION_FINISHED
} connection_state_;
- std::unique_ptr<shell::Connection> user_service_connection_;
+ std::unique_ptr<shell::Connection> file_service_connection_;
- user_service::mojom::UserServicePtr user_service_;
+ file::mojom::FileSystemPtr file_system_;
filesystem::mojom::DirectoryPtr directory_;
leveldb::mojom::LevelDBServicePtr leveldb_service_;
@@ -149,28 +149,28 @@
// If we don't have a filesystem_connection_, we'll need to establish one.
if (connection_state_ == NO_CONNECTION) {
CHECK(connector_);
- user_service_connection_ =
- connector_->Connect(user_service::kUserServiceName);
+ file_service_connection_ =
+ connector_->Connect(file::kFileServiceName);
connection_state_ = CONNECTION_IN_PROGRESS;
- user_service_connection_->AddConnectionCompletedClosure(
+ file_service_connection_->AddConnectionCompletedClosure(
base::Bind(&MojoState::OnUserServiceConnectionComplete,
weak_ptr_factory_.GetWeakPtr()));
- user_service_connection_->SetConnectionLostClosure(
+ file_service_connection_->SetConnectionLostClosure(
base::Bind(&MojoState::OnUserServiceConnectionError,
weak_ptr_factory_.GetWeakPtr()));
if (!subdirectory_.empty()) {
// We were given a subdirectory to write to. Get it and use a disk backed
// database.
- user_service_connection_->GetInterface(&user_service_);
- user_service_->GetSubDirectory(
+ file_service_connection_->GetInterface(&file_system_);
+ file_system_->GetSubDirectory(
mojo::String::From(subdirectory_.AsUTF8Unsafe()),
GetProxy(&directory_),
base::Bind(&MojoState::OnDirectoryOpened,
weak_ptr_factory_.GetWeakPtr()));
} else {
// We were not given a subdirectory. Use a memory backed database.
- user_service_connection_->GetInterface(&leveldb_service_);
+ file_service_connection_->GetInterface(&leveldb_service_);
leveldb_service_->OpenInMemory(
GetProxy(&database_),
base::Bind(&MojoState::OnDatabaseOpened,
@@ -200,7 +200,7 @@
// Now that we have a directory, connect to the LevelDB service and get our
// database.
- user_service_connection_->GetInterface(&leveldb_service_);
+ file_service_connection_->GetInterface(&leveldb_service_);
leveldb_service_->Open(
std::move(directory_), "leveldb", GetProxy(&database_),
@@ -216,11 +216,10 @@
leveldb_service_.reset();
}
- // We no longer need the user service; we've either transferred
- // |directory_| to the leveldb service, or we got a file error and no more is
- // possible.
+ // We no longer need the file service; we've either transferred |directory_|
+ // to the leveldb service, or we got a file error and no more is possible.
directory_.reset();
- user_service_.reset();
+ file_system_.reset();
// |leveldb_| should be known to either be valid or invalid by now. Run our
// delayed bindings.
diff --git a/content/browser/mojo/mojo_shell_context.cc b/content/browser/mojo/mojo_shell_context.cc
index cb0f5bd2..7ad111d 100644
--- a/content/browser/mojo/mojo_shell_context.cc
+++ b/content/browser/mojo/mojo_shell_context.cc
@@ -27,6 +27,7 @@
#include "services/catalog/catalog.h"
#include "services/catalog/manifest_provider.h"
#include "services/catalog/store.h"
+#include "services/file/public/cpp/constants.h"
#include "services/shell/connect_params.h"
#include "services/shell/native_runner.h"
#include "services/shell/public/cpp/connector.h"
@@ -35,7 +36,6 @@
#include "services/shell/runner/common/client_util.h"
#include "services/shell/runner/host/in_process_native_runner.h"
#include "services/shell/service_manager.h"
-#include "services/user/public/cpp/constants.h"
namespace content {
@@ -236,8 +236,8 @@
IDR_MOJO_CONTENT_UTILITY_MANIFEST);
manifest_provider->AddManifestResource("mojo:catalog",
IDR_MOJO_CATALOG_MANIFEST);
- manifest_provider->AddManifestResource(user_service::kUserServiceName,
- IDR_MOJO_PROFILE_MANIFEST);
+ manifest_provider->AddManifestResource(file::kFileServiceName,
+ IDR_MOJO_FILE_MANIFEST);
in_process_context_ = new InProcessServiceManagerContext;
request = in_process_context_->Start(std::move(manifest_provider));