| Index: content/browser/browser_context.cc
|
| diff --git a/content/browser/browser_context.cc b/content/browser/browser_context.cc
|
| index f5ec433add25adc2d7006cebb2225733007f7ffb..5b7ba414fede1cfde3b029ed98f7b60c0ca2b418 100644
|
| --- a/content/browser/browser_context.cc
|
| +++ b/content/browser/browser_context.cc
|
| @@ -32,7 +32,7 @@
|
| #include "content/public/browser/render_process_host.h"
|
| #include "content/public/browser/site_instance.h"
|
| #include "content/public/common/content_switches.h"
|
| -#include "content/public/common/mojo_shell_connection.h"
|
| +#include "content/public/common/service_manager_connection.h"
|
| #include "content/public/common/service_names.h"
|
| #include "net/cookies/cookie_store.h"
|
| #include "net/ssl/channel_id_service.h"
|
| @@ -57,24 +57,25 @@ namespace {
|
| base::LazyInstance<std::map<std::string, BrowserContext*>>
|
| g_user_id_to_context = LAZY_INSTANCE_INITIALIZER;
|
|
|
| -class ShellUserIdHolder : public base::SupportsUserData::Data {
|
| +class ServiceUserIdHolder : public base::SupportsUserData::Data {
|
| public:
|
| - explicit ShellUserIdHolder(const std::string& user_id) : user_id_(user_id) {}
|
| - ~ShellUserIdHolder() override {}
|
| + explicit ServiceUserIdHolder(const std::string& user_id)
|
| + : user_id_(user_id) {}
|
| + ~ServiceUserIdHolder() override {}
|
|
|
| const std::string& user_id() const { return user_id_; }
|
|
|
| private:
|
| std::string user_id_;
|
|
|
| - DISALLOW_COPY_AND_ASSIGN(ShellUserIdHolder);
|
| + DISALLOW_COPY_AND_ASSIGN(ServiceUserIdHolder);
|
| };
|
|
|
| // Key names on BrowserContext.
|
| const char kDownloadManagerKeyName[] = "download_manager";
|
| -const char kMojoShellConnection[] = "mojo-shell-connection";
|
| const char kMojoWasInitialized[] = "mojo-was-initialized";
|
| -const char kMojoShellUserId[] = "mojo-shell-user-id";
|
| +const char kServiceManagerConnection[] = "service-manager-connection";
|
| +const char kServiceUserId[] = "service-user-id";
|
| const char kStoragePartitionMapKeyName[] = "content_storage_partition_map";
|
|
|
| #if defined(OS_CHROMEOS)
|
| @@ -82,8 +83,8 @@ const char kMountPointsKey[] = "mount_points";
|
| #endif // defined(OS_CHROMEOS)
|
|
|
| void RemoveBrowserContextFromUserIdMap(BrowserContext* browser_context) {
|
| - ShellUserIdHolder* holder = static_cast<ShellUserIdHolder*>(
|
| - browser_context->GetUserData(kMojoShellUserId));
|
| + ServiceUserIdHolder* holder = static_cast<ServiceUserIdHolder*>(
|
| + browser_context->GetUserData(kServiceUserId));
|
| if (holder) {
|
| auto it = g_user_id_to_context.Get().find(holder->user_id());
|
| if (it != g_user_id_to_context.Get().end())
|
| @@ -146,25 +147,27 @@ void SetDownloadManager(BrowserContext* context,
|
| context->SetUserData(kDownloadManagerKeyName, download_manager);
|
| }
|
|
|
| -class BrowserContextShellConnectionHolder
|
| +class BrowserContextServiceManagerConnectionHolder
|
| : public base::SupportsUserData::Data {
|
| public:
|
| - BrowserContextShellConnectionHolder(
|
| + BrowserContextServiceManagerConnectionHolder(
|
| std::unique_ptr<shell::Connection> connection,
|
| shell::mojom::ServiceRequest request)
|
| : root_connection_(std::move(connection)),
|
| - shell_connection_(MojoShellConnection::Create(
|
| + service_manager_connection_(ServiceManagerConnection::Create(
|
| std::move(request),
|
| BrowserThread::GetTaskRunnerForThread(BrowserThread::IO))) {}
|
| - ~BrowserContextShellConnectionHolder() override {}
|
| + ~BrowserContextServiceManagerConnectionHolder() override {}
|
|
|
| - MojoShellConnection* shell_connection() { return shell_connection_.get(); }
|
| + ServiceManagerConnection* service_manager_connection() {
|
| + return service_manager_connection_.get();
|
| + }
|
|
|
| private:
|
| std::unique_ptr<shell::Connection> root_connection_;
|
| - std::unique_ptr<MojoShellConnection> shell_connection_;
|
| + std::unique_ptr<ServiceManagerConnection> service_manager_connection_;
|
|
|
| - DISALLOW_COPY_AND_ASSIGN(BrowserContextShellConnectionHolder);
|
| + DISALLOW_COPY_AND_ASSIGN(BrowserContextServiceManagerConnectionHolder);
|
| };
|
|
|
| } // namespace
|
| @@ -406,56 +409,58 @@ void BrowserContext::Initialize(
|
|
|
| std::string new_id;
|
| if (GetContentClient() && GetContentClient()->browser()) {
|
| - new_id = GetContentClient()->browser()->GetShellUserIdForBrowserContext(
|
| + new_id = GetContentClient()->browser()->GetServiceUserIdForBrowserContext(
|
| browser_context);
|
| } else {
|
| // Some test scenarios initialize a BrowserContext without a content client.
|
| new_id = base::GenerateGUID();
|
| }
|
|
|
| - ShellUserIdHolder* holder = static_cast<ShellUserIdHolder*>(
|
| - browser_context->GetUserData(kMojoShellUserId));
|
| + ServiceUserIdHolder* holder = static_cast<ServiceUserIdHolder*>(
|
| + browser_context->GetUserData(kServiceUserId));
|
| if (holder)
|
| - file::ForgetShellUserIdUserDirAssociation(holder->user_id());
|
| - file::AssociateShellUserIdWithUserDir(new_id, path);
|
| + file::ForgetServiceUserIdUserDirAssociation(holder->user_id());
|
| + file::AssociateServiceUserIdWithUserDir(new_id, path);
|
| RemoveBrowserContextFromUserIdMap(browser_context);
|
| g_user_id_to_context.Get()[new_id] = browser_context;
|
| - browser_context->SetUserData(kMojoShellUserId,
|
| - new ShellUserIdHolder(new_id));
|
| + browser_context->SetUserData(kServiceUserId,
|
| + new ServiceUserIdHolder(new_id));
|
|
|
| browser_context->SetUserData(kMojoWasInitialized,
|
| new base::SupportsUserData::Data);
|
|
|
| - MojoShellConnection* shell = MojoShellConnection::GetForProcess();
|
| - if (shell && base::MessageLoop::current()) {
|
| + ServiceManagerConnection* service_manager_connection =
|
| + ServiceManagerConnection::GetForProcess();
|
| + if (service_manager_connection && base::MessageLoop::current()) {
|
| // NOTE: Many unit tests create a TestBrowserContext without initializing
|
| - // Mojo or the global Mojo shell connection.
|
| + // Mojo or the global service manager connection.
|
|
|
| shell::mojom::ServicePtr service;
|
| shell::mojom::ServiceRequest service_request = mojo::GetProxy(&service);
|
|
|
| shell::mojom::PIDReceiverPtr pid_receiver;
|
| shell::Connector::ConnectParams params(
|
| - shell::Identity(kBrowserMojoApplicationName, new_id));
|
| + shell::Identity(kBrowserServiceName, new_id));
|
| params.set_client_process_connection(std::move(service),
|
| mojo::GetProxy(&pid_receiver));
|
| pid_receiver->SetPID(base::GetCurrentProcId());
|
|
|
| - BrowserContextShellConnectionHolder* connection_holder =
|
| - new BrowserContextShellConnectionHolder(
|
| - shell->GetConnector()->Connect(¶ms),
|
| - std::move(service_request));
|
| - browser_context->SetUserData(kMojoShellConnection, connection_holder);
|
| + BrowserContextServiceManagerConnectionHolder* connection_holder =
|
| + new BrowserContextServiceManagerConnectionHolder(
|
| + service_manager_connection->GetConnector()->Connect(¶ms),
|
| + std::move(service_request));
|
| + browser_context->SetUserData(kServiceManagerConnection, connection_holder);
|
|
|
| - MojoShellConnection* connection = connection_holder->shell_connection();
|
| + ServiceManagerConnection* connection =
|
| + connection_holder->service_manager_connection();
|
| connection->Start();
|
|
|
| // New embedded service factories should be added to |connection| here.
|
|
|
| if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| switches::kMojoLocalStorage)) {
|
| - MojoApplicationInfo info;
|
| - info.application_factory =
|
| + ServiceInfo info;
|
| + info.factory =
|
| base::Bind(&file::CreateFileService,
|
| BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE),
|
| BrowserThread::GetTaskRunnerForThread(BrowserThread::DB));
|
| @@ -465,38 +470,40 @@ void BrowserContext::Initialize(
|
| }
|
|
|
| // static
|
| -const std::string& BrowserContext::GetShellUserIdFor(
|
| +const std::string& BrowserContext::GetServiceUserIdFor(
|
| BrowserContext* browser_context) {
|
| CHECK(browser_context->GetUserData(kMojoWasInitialized))
|
| << "Attempting to get the mojo user id for a BrowserContext that was "
|
| << "never Initialize()ed.";
|
|
|
| - ShellUserIdHolder* holder = static_cast<ShellUserIdHolder*>(
|
| - browser_context->GetUserData(kMojoShellUserId));
|
| + ServiceUserIdHolder* holder = static_cast<ServiceUserIdHolder*>(
|
| + browser_context->GetUserData(kServiceUserId));
|
| return holder->user_id();
|
| }
|
|
|
| // static
|
| -BrowserContext* BrowserContext::GetBrowserContextForShellUserId(
|
| +BrowserContext* BrowserContext::GetBrowserContextForServiceUserId(
|
| const std::string& user_id) {
|
| auto it = g_user_id_to_context.Get().find(user_id);
|
| return it != g_user_id_to_context.Get().end() ? it->second : nullptr;
|
| }
|
|
|
| // static
|
| -shell::Connector* BrowserContext::GetShellConnectorFor(
|
| +shell::Connector* BrowserContext::GetConnectorFor(
|
| BrowserContext* browser_context) {
|
| - MojoShellConnection* connection = GetMojoShellConnectionFor(browser_context);
|
| + ServiceManagerConnection* connection =
|
| + GetServiceManagerConnectionFor(browser_context);
|
| return connection ? connection->GetConnector() : nullptr;
|
| }
|
|
|
| // static
|
| -MojoShellConnection* BrowserContext::GetMojoShellConnectionFor(
|
| +ServiceManagerConnection* BrowserContext::GetServiceManagerConnectionFor(
|
| BrowserContext* browser_context) {
|
| - BrowserContextShellConnectionHolder* connection_holder =
|
| - static_cast<BrowserContextShellConnectionHolder*>(
|
| - browser_context->GetUserData(kMojoShellConnection));
|
| - return connection_holder ? connection_holder->shell_connection() : nullptr;
|
| + BrowserContextServiceManagerConnectionHolder* connection_holder =
|
| + static_cast<BrowserContextServiceManagerConnectionHolder*>(
|
| + browser_context->GetUserData(kServiceManagerConnection));
|
| + return connection_holder ? connection_holder->service_manager_connection()
|
| + : nullptr;
|
| }
|
|
|
| BrowserContext::~BrowserContext() {
|
|
|