| OLD | NEW |
| 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 "services/catalog/catalog.h" | 5 #include "services/catalog/catalog.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 base::FilePath system_package_dir; | 99 base::FilePath system_package_dir; |
| 100 PathService::Get(base::DIR_MODULE, &system_package_dir); | 100 PathService::Get(base::DIR_MODULE, &system_package_dir); |
| 101 system_package_dir = system_package_dir.AppendASCII(kMojoApplicationsDirName); | 101 system_package_dir = system_package_dir.AppendASCII(kMojoApplicationsDirName); |
| 102 system_reader_->Read(system_package_dir, &system_cache_, | 102 system_reader_->Read(system_package_dir, &system_cache_, |
| 103 base::Bind(&Catalog::SystemPackageDirScanned, | 103 base::Bind(&Catalog::SystemPackageDirScanned, |
| 104 weak_factory_.GetWeakPtr())); | 104 weak_factory_.GetWeakPtr())); |
| 105 } | 105 } |
| 106 | 106 |
| 107 bool Catalog::AcceptConnection(shell::Connection* connection) { | 107 bool Catalog::AcceptConnection(shell::Connection* connection) { |
| 108 connection->AddInterface<mojom::Catalog>(this); | 108 connection->AddInterface<mojom::Catalog>(this); |
| 109 connection->AddInterface<filesystem::Directory>(this); | 109 connection->AddInterface<filesystem::mojom::Directory>(this); |
| 110 connection->AddInterface<shell::mojom::ShellResolver>(this); | 110 connection->AddInterface<shell::mojom::ShellResolver>(this); |
| 111 return true; | 111 return true; |
| 112 } | 112 } |
| 113 | 113 |
| 114 void Catalog::Create(shell::Connection* connection, | 114 void Catalog::Create(shell::Connection* connection, |
| 115 shell::mojom::ShellResolverRequest request) { | 115 shell::mojom::ShellResolverRequest request) { |
| 116 Instance* instance = | 116 Instance* instance = |
| 117 GetInstanceForUserId(connection->GetRemoteIdentity().user_id()); | 117 GetInstanceForUserId(connection->GetRemoteIdentity().user_id()); |
| 118 instance->BindShellResolver(std::move(request)); | 118 instance->BindShellResolver(std::move(request)); |
| 119 } | 119 } |
| 120 | 120 |
| 121 void Catalog::Create(shell::Connection* connection, | 121 void Catalog::Create(shell::Connection* connection, |
| 122 mojom::CatalogRequest request) { | 122 mojom::CatalogRequest request) { |
| 123 Instance* instance = | 123 Instance* instance = |
| 124 GetInstanceForUserId(connection->GetRemoteIdentity().user_id()); | 124 GetInstanceForUserId(connection->GetRemoteIdentity().user_id()); |
| 125 instance->BindCatalog(std::move(request)); | 125 instance->BindCatalog(std::move(request)); |
| 126 } | 126 } |
| 127 | 127 |
| 128 void Catalog::Create(shell::Connection* connection, | 128 void Catalog::Create(shell::Connection* connection, |
| 129 filesystem::DirectoryRequest request) { | 129 filesystem::mojom::DirectoryRequest request) { |
| 130 if (!lock_table_) | 130 if (!lock_table_) |
| 131 lock_table_ = new filesystem::LockTable; | 131 lock_table_ = new filesystem::LockTable; |
| 132 base::FilePath resources_path = | 132 base::FilePath resources_path = |
| 133 GetPathForApplicationName(connection->GetRemoteIdentity().name()); | 133 GetPathForApplicationName(connection->GetRemoteIdentity().name()); |
| 134 new filesystem::DirectoryImpl(std::move(request), resources_path, | 134 new filesystem::DirectoryImpl(std::move(request), resources_path, |
| 135 scoped_refptr<filesystem::SharedTempDir>(), | 135 scoped_refptr<filesystem::SharedTempDir>(), |
| 136 lock_table_); | 136 lock_table_); |
| 137 } | 137 } |
| 138 | 138 |
| 139 Instance* Catalog::GetInstanceForUserId(const std::string& user_id) { | 139 Instance* Catalog::GetInstanceForUserId(const std::string& user_id) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 150 return instance; | 150 return instance; |
| 151 } | 151 } |
| 152 | 152 |
| 153 void Catalog::SystemPackageDirScanned() { | 153 void Catalog::SystemPackageDirScanned() { |
| 154 loaded_ = true; | 154 loaded_ = true; |
| 155 for (auto& instance : instances_) | 155 for (auto& instance : instances_) |
| 156 instance.second->CacheReady(&system_cache_); | 156 instance.second->CacheReady(&system_cache_); |
| 157 } | 157 } |
| 158 | 158 |
| 159 } // namespace catalog | 159 } // namespace catalog |
| OLD | NEW |