Commit 28a60c89 authored by Thanh Nguyen's avatar Thanh Nguyen Committed by Commit Bot

[local-search-service] Rename local search service proxy

Rename local search service proxy for the new LSS.
Please see go/lss-sandboxing-impl for more details

Bug: 1137560
Change-Id: I92a9b38f425462f6b771e835f6afd0cc4666b3a0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2500382Reviewed-by: default avatarSam McNally <sammc@chromium.org>
Reviewed-by: default avatarRachel Carpenter <carpenterr@chromium.org>
Reviewed-by: default avatarJia Meng <jiameng@chromium.org>
Commit-Queue: Thanh Nguyen <thanhdng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#821503}
parent 444dfe7a
...@@ -733,8 +733,8 @@ void PopulateChromeWebUIFrameBinders( ...@@ -733,8 +733,8 @@ void PopulateChromeWebUIFrameBinders(
chromeos::HelpAppUI>(map); chromeos::HelpAppUI>(map);
RegisterWebUIControllerInterfaceBinder< RegisterWebUIControllerInterfaceBinder<
chromeos::local_search_service::mojom::IndexProxy, chromeos::HelpAppUI>( chromeos::local_search_service::mojom::IndexSyncProxy,
map); chromeos::HelpAppUI>(map);
RegisterWebUIControllerInterfaceBinder< RegisterWebUIControllerInterfaceBinder<
media_app_ui::mojom::PageHandlerFactory, chromeos::MediaAppUI>(map); media_app_ui::mojom::PageHandlerFactory, chromeos::MediaAppUI>(map);
......
...@@ -9,8 +9,8 @@ ...@@ -9,8 +9,8 @@
#include "chromeos/components/help_app_ui/help_app_page_handler.h" #include "chromeos/components/help_app_ui/help_app_page_handler.h"
#include "chromeos/components/help_app_ui/help_app_untrusted_ui.h" #include "chromeos/components/help_app_ui/help_app_untrusted_ui.h"
#include "chromeos/components/help_app_ui/url_constants.h" #include "chromeos/components/help_app_ui/url_constants.h"
#include "chromeos/components/local_search_service/local_search_service_proxy.h" #include "chromeos/components/local_search_service/local_search_service_sync_proxy.h"
#include "chromeos/components/local_search_service/local_search_service_proxy_factory.h" #include "chromeos/components/local_search_service/local_search_service_sync_proxy_factory.h"
#include "chromeos/components/local_search_service/mojom/types.mojom.h" #include "chromeos/components/local_search_service/mojom/types.mojom.h"
#include "chromeos/grit/chromeos_help_app_resources.h" #include "chromeos/grit/chromeos_help_app_resources.h"
#include "chromeos/strings/grit/chromeos_strings.h" #include "chromeos/strings/grit/chromeos_strings.h"
...@@ -91,9 +91,9 @@ void HelpAppUI::BindInterface( ...@@ -91,9 +91,9 @@ void HelpAppUI::BindInterface(
} }
void HelpAppUI::BindInterface( void HelpAppUI::BindInterface(
mojo::PendingReceiver<chromeos::local_search_service::mojom::IndexProxy> mojo::PendingReceiver<chromeos::local_search_service::mojom::IndexSyncProxy>
index_receiver) { index_receiver) {
chromeos::local_search_service::LocalSearchServiceProxyFactory:: chromeos::local_search_service::LocalSearchServiceSyncProxyFactory::
GetForBrowserContext(web_ui()->GetWebContents()->GetBrowserContext()) GetForBrowserContext(web_ui()->GetWebContents()->GetBrowserContext())
->GetIndex(chromeos::local_search_service::IndexId::kHelpApp, ->GetIndex(chromeos::local_search_service::IndexId::kHelpApp,
chromeos::local_search_service::Backend::kInvertedIndex, chromeos::local_search_service::Backend::kInvertedIndex,
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include "chromeos/components/help_app_ui/help_app_ui.mojom.h" #include "chromeos/components/help_app_ui/help_app_ui.mojom.h"
#include "chromeos/components/help_app_ui/help_app_ui_delegate.h" #include "chromeos/components/help_app_ui/help_app_ui_delegate.h"
#include "chromeos/components/local_search_service/local_search_service_proxy.h" #include "chromeos/components/local_search_service/local_search_service_sync_proxy.h"
#include "mojo/public/cpp/bindings/receiver.h" #include "mojo/public/cpp/bindings/receiver.h"
#include "ui/webui/mojo_web_ui_controller.h" #include "ui/webui/mojo_web_ui_controller.h"
...@@ -32,7 +32,7 @@ class HelpAppUI : public ui::MojoWebUIController, ...@@ -32,7 +32,7 @@ class HelpAppUI : public ui::MojoWebUIController,
mojo::PendingReceiver<help_app_ui::mojom::PageHandlerFactory> receiver); mojo::PendingReceiver<help_app_ui::mojom::PageHandlerFactory> receiver);
void BindInterface( void BindInterface(
mojo::PendingReceiver<local_search_service::mojom::IndexProxy> mojo::PendingReceiver<local_search_service::mojom::IndexSyncProxy>
index_receiver); index_receiver);
HelpAppUIDelegate* delegate() { return delegate_.get(); } HelpAppUIDelegate* delegate() { return delegate_.get(); }
......
...@@ -11,8 +11,9 @@ helpAppUi.mojom.PageHandlerFactory.getRemote().createPageHandler( ...@@ -11,8 +11,9 @@ helpAppUi.mojom.PageHandlerFactory.getRemote().createPageHandler(
help_app.handler.$.bindNewPipeAndPassReceiver()); help_app.handler.$.bindNewPipeAndPassReceiver());
// Set up an index remote to talk to Local Search Service. // Set up an index remote to talk to Local Search Service.
/** @type {!chromeos.localSearchService.mojom.IndexProxyRemote} */ /** @type {!chromeos.localSearchService.mojom.IndexSyncProxyRemote} */
const indexRemote = chromeos.localSearchService.mojom.IndexProxy.getRemote(); const indexRemote =
chromeos.localSearchService.mojom.IndexSyncProxy.getRemote();
const GUEST_ORIGIN = 'chrome-untrusted://help-app'; const GUEST_ORIGIN = 'chrome-untrusted://help-app';
const guestFrame = const guestFrame =
......
...@@ -48,12 +48,12 @@ source_set("local_search_service") { ...@@ -48,12 +48,12 @@ source_set("local_search_service") {
source_set("local_search_service_proxy") { source_set("local_search_service_proxy") {
sources = [ sources = [
"index_proxy.cc", "index_sync_proxy.cc",
"index_proxy.h", "index_sync_proxy.h",
"local_search_service_proxy.cc", "local_search_service_sync_proxy.cc",
"local_search_service_proxy.h", "local_search_service_sync_proxy.h",
"local_search_service_proxy_factory.cc", "local_search_service_sync_proxy_factory.cc",
"local_search_service_proxy_factory.h", "local_search_service_sync_proxy_factory.h",
] ]
deps = [ deps = [
...@@ -92,7 +92,7 @@ source_set("unit_tests") { ...@@ -92,7 +92,7 @@ source_set("unit_tests") {
"inverted_index_search_unittest.cc", "inverted_index_search_unittest.cc",
"inverted_index_unittest.cc", "inverted_index_unittest.cc",
"linear_map_search_unittest.cc", "linear_map_search_unittest.cc",
"local_search_service_proxy_unittest.cc", "local_search_service_sync_proxy_unittest.cc",
"local_search_service_sync_unittest.cc", "local_search_service_sync_unittest.cc",
"search_metrics_reporter_sync_unittest.cc", "search_metrics_reporter_sync_unittest.cc",
"search_utils_unittest.cc", "search_utils_unittest.cc",
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chromeos/components/local_search_service/index_proxy.h" #include "chromeos/components/local_search_service/index_sync_proxy.h"
#include "base/optional.h" #include "base/optional.h"
#include "chromeos/components/local_search_service/index_sync.h" #include "chromeos/components/local_search_service/index_sync.h"
...@@ -10,37 +10,37 @@ ...@@ -10,37 +10,37 @@
namespace chromeos { namespace chromeos {
namespace local_search_service { namespace local_search_service {
IndexProxy::IndexProxy(IndexSync* index) : index_(index) { IndexSyncProxy::IndexSyncProxy(IndexSync* index) : index_(index) {
DCHECK(index_); DCHECK(index_);
} }
IndexProxy::~IndexProxy() = default; IndexSyncProxy::~IndexSyncProxy() = default;
void IndexProxy::BindReceiver( void IndexSyncProxy::BindReceiver(
mojo::PendingReceiver<mojom::IndexProxy> receiver) { mojo::PendingReceiver<mojom::IndexSyncProxy> receiver) {
receivers_.Add(this, std::move(receiver)); receivers_.Add(this, std::move(receiver));
} }
void IndexProxy::GetSize(GetSizeCallback callback) { void IndexSyncProxy::GetSize(GetSizeCallback callback) {
const uint64_t num_items = index_->GetSizeSync(); const uint64_t num_items = index_->GetSizeSync();
std::move(callback).Run(num_items); std::move(callback).Run(num_items);
} }
void IndexProxy::AddOrUpdate(const std::vector<Data>& data, void IndexSyncProxy::AddOrUpdate(const std::vector<Data>& data,
AddOrUpdateCallback callback) { AddOrUpdateCallback callback) {
index_->AddOrUpdateSync(data); index_->AddOrUpdateSync(data);
std::move(callback).Run(); std::move(callback).Run();
} }
void IndexProxy::Delete(const std::vector<std::string>& ids, void IndexSyncProxy::Delete(const std::vector<std::string>& ids,
DeleteCallback callback) { DeleteCallback callback) {
const uint64_t num_deleted = index_->DeleteSync(ids); const uint64_t num_deleted = index_->DeleteSync(ids);
std::move(callback).Run(num_deleted); std::move(callback).Run(num_deleted);
} }
void IndexProxy::Find(const base::string16& query, void IndexSyncProxy::Find(const base::string16& query,
uint32_t max_results, uint32_t max_results,
FindCallback callback) { FindCallback callback) {
std::vector<Result> results; std::vector<Result> results;
ResponseStatus status = index_->FindSync(query, max_results, &results); ResponseStatus status = index_->FindSync(query, max_results, &results);
if (status != ResponseStatus::kSuccess) { if (status != ResponseStatus::kSuccess) {
...@@ -50,7 +50,7 @@ void IndexProxy::Find(const base::string16& query, ...@@ -50,7 +50,7 @@ void IndexProxy::Find(const base::string16& query,
} }
} }
void IndexProxy::ClearIndex(ClearIndexCallback callback) { void IndexSyncProxy::ClearIndex(ClearIndexCallback callback) {
index_->ClearIndexSync(); index_->ClearIndexSync();
std::move(callback).Run(); std::move(callback).Run();
} }
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROMEOS_COMPONENTS_LOCAL_SEARCH_SERVICE_INDEX_PROXY_H_ #ifndef CHROMEOS_COMPONENTS_LOCAL_SEARCH_SERVICE_INDEX_SYNC_PROXY_H_
#define CHROMEOS_COMPONENTS_LOCAL_SEARCH_SERVICE_INDEX_PROXY_H_ #define CHROMEOS_COMPONENTS_LOCAL_SEARCH_SERVICE_INDEX_SYNC_PROXY_H_
#include <vector> #include <vector>
...@@ -17,14 +17,14 @@ namespace local_search_service { ...@@ -17,14 +17,14 @@ namespace local_search_service {
class IndexSync; class IndexSync;
class IndexProxy : public mojom::IndexProxy { class IndexSyncProxy : public mojom::IndexSyncProxy {
public: public:
explicit IndexProxy(IndexSync* index); explicit IndexSyncProxy(IndexSync* index);
~IndexProxy() override; ~IndexSyncProxy() override;
void BindReceiver(mojo::PendingReceiver<mojom::IndexProxy> receiver); void BindReceiver(mojo::PendingReceiver<mojom::IndexSyncProxy> receiver);
// mojom::IndexProxy: // mojom::IndexSyncProxy:
void GetSize(GetSizeCallback callback) override; void GetSize(GetSizeCallback callback) override;
void AddOrUpdate(const std::vector<Data>& data, void AddOrUpdate(const std::vector<Data>& data,
AddOrUpdateCallback callback) override; AddOrUpdateCallback callback) override;
...@@ -37,10 +37,10 @@ class IndexProxy : public mojom::IndexProxy { ...@@ -37,10 +37,10 @@ class IndexProxy : public mojom::IndexProxy {
private: private:
IndexSync* const index_; IndexSync* const index_;
mojo::ReceiverSet<mojom::IndexProxy> receivers_; mojo::ReceiverSet<mojom::IndexSyncProxy> receivers_;
}; };
} // namespace local_search_service } // namespace local_search_service
} // namespace chromeos } // namespace chromeos
#endif // CHROMEOS_COMPONENTS_LOCAL_SEARCH_SERVICE_INDEX_PROXY_H_ #endif // CHROMEOS_COMPONENTS_LOCAL_SEARCH_SERVICE_INDEX_SYNC_PROXY_H_
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chromeos/components/local_search_service/local_search_service_proxy.h" #include "chromeos/components/local_search_service/local_search_service_sync_proxy.h"
#include "chromeos/components/local_search_service/index_proxy.h" #include "chromeos/components/local_search_service/index_sync_proxy.h"
#include "chromeos/components/local_search_service/local_search_service_sync.h" #include "chromeos/components/local_search_service/local_search_service_sync.h"
#include "chromeos/components/local_search_service/shared_structs.h" #include "chromeos/components/local_search_service/shared_structs.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
...@@ -12,36 +12,37 @@ ...@@ -12,36 +12,37 @@
namespace chromeos { namespace chromeos {
namespace local_search_service { namespace local_search_service {
LocalSearchServiceProxy::LocalSearchServiceProxy( LocalSearchServiceSyncProxy::LocalSearchServiceSyncProxy(
local_search_service::LocalSearchServiceSync* local_search_service) local_search_service::LocalSearchServiceSync* local_search_service)
: service_(local_search_service) { : service_(local_search_service) {
DCHECK(service_); DCHECK(service_);
} }
LocalSearchServiceProxy::~LocalSearchServiceProxy() = default; LocalSearchServiceSyncProxy::~LocalSearchServiceSyncProxy() = default;
void LocalSearchServiceProxy::GetIndex( void LocalSearchServiceSyncProxy::GetIndex(
IndexId index_id, IndexId index_id,
Backend backend, Backend backend,
mojo::PendingReceiver<mojom::IndexProxy> index_receiver) { mojo::PendingReceiver<mojom::IndexSyncProxy> index_receiver) {
GetIndex(index_id, backend, nullptr, std::move(index_receiver)); GetIndex(index_id, backend, nullptr, std::move(index_receiver));
} }
void LocalSearchServiceProxy::GetIndex( void LocalSearchServiceSyncProxy::GetIndex(
IndexId index_id, IndexId index_id,
Backend backend, Backend backend,
PrefService* local_state, PrefService* local_state,
mojo::PendingReceiver<mojom::IndexProxy> index_receiver) { mojo::PendingReceiver<mojom::IndexSyncProxy> index_receiver) {
auto it = indices_.find(index_id); auto it = indices_.find(index_id);
if (it == indices_.end()) { if (it == indices_.end()) {
IndexSync* index = service_->GetIndexSync(index_id, backend, local_state); IndexSync* index = service_->GetIndexSync(index_id, backend, local_state);
it = indices_.emplace(index_id, std::make_unique<IndexProxy>(index)).first; it = indices_.emplace(index_id, std::make_unique<IndexSyncProxy>(index))
.first;
} }
it->second->BindReceiver(std::move(index_receiver)); it->second->BindReceiver(std::move(index_receiver));
} }
void LocalSearchServiceProxy::BindReceiver( void LocalSearchServiceSyncProxy::BindReceiver(
mojo::PendingReceiver<mojom::LocalSearchServiceProxy> receiver) { mojo::PendingReceiver<mojom::LocalSearchServiceSyncProxy> receiver) {
receivers_.Add(this, std::move(receiver)); receivers_.Add(this, std::move(receiver));
} }
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROMEOS_COMPONENTS_LOCAL_SEARCH_SERVICE_LOCAL_SEARCH_SERVICE_PROXY_H_ #ifndef CHROMEOS_COMPONENTS_LOCAL_SEARCH_SERVICE_LOCAL_SEARCH_SERVICE_SYNC_PROXY_H_
#define CHROMEOS_COMPONENTS_LOCAL_SEARCH_SERVICE_LOCAL_SEARCH_SERVICE_PROXY_H_ #define CHROMEOS_COMPONENTS_LOCAL_SEARCH_SERVICE_LOCAL_SEARCH_SERVICE_SYNC_PROXY_H_
#include <map> #include <map>
...@@ -18,48 +18,49 @@ namespace chromeos { ...@@ -18,48 +18,49 @@ namespace chromeos {
namespace local_search_service { namespace local_search_service {
class LocalSearchServiceSync; class LocalSearchServiceSync;
class IndexProxy; class IndexSyncProxy;
enum class IndexId; enum class IndexId;
enum class Backend; enum class Backend;
class LocalSearchServiceProxy : public mojom::LocalSearchServiceProxy, class LocalSearchServiceSyncProxy : public mojom::LocalSearchServiceSyncProxy,
public KeyedService { public KeyedService {
public: public:
explicit LocalSearchServiceProxy( explicit LocalSearchServiceSyncProxy(
LocalSearchServiceSync* local_search_service); LocalSearchServiceSync* local_search_service);
~LocalSearchServiceProxy() override; ~LocalSearchServiceSyncProxy() override;
LocalSearchServiceProxy(const LocalSearchServiceProxy&) = delete; LocalSearchServiceSyncProxy(const LocalSearchServiceSyncProxy&) = delete;
LocalSearchServiceProxy& operator=(const LocalSearchServiceProxy) = delete; LocalSearchServiceSyncProxy& operator=(const LocalSearchServiceSyncProxy) =
delete;
// mojom::LocalSearchServiceProxy: // mojom::LocalSearchServiceSyncProxy:
void GetIndex( void GetIndex(
IndexId index_id, IndexId index_id,
Backend backend, Backend backend,
mojo::PendingReceiver<mojom::IndexProxy> index_receiver) override; mojo::PendingReceiver<mojom::IndexSyncProxy> index_receiver) override;
void BindReceiver( void BindReceiver(
mojo::PendingReceiver<mojom::LocalSearchServiceProxy> receiver); mojo::PendingReceiver<mojom::LocalSearchServiceSyncProxy> receiver);
// The version below allows an out-of-process client to directly obtain an // The version below allows an out-of-process client to directly obtain an
// Index using their own delegate that runs in C++. // Index using their own delegate that runs in C++.
// 1. Client's delegate obtains LocalSearchServicProxy from // 1. Client's delegate obtains LocalSearchServicProxy from
// LocalSearchServiceProxyFactory. // LocalSearchServiceSyncProxyFactory.
// 2. Client's delegate calls GetIndex to obtain an Index and binds the // 2. Client's delegate calls GetIndex to obtain an Index and binds the
// IndexProxy remote // IndexSyncProxy remote
// to the IndexProxy implementation. // to the IndexSyncProxy implementation.
void GetIndex(IndexId index_id, void GetIndex(IndexId index_id,
Backend backend, Backend backend,
PrefService* local_state, PrefService* local_state,
mojo::PendingReceiver<mojom::IndexProxy> index_receiver); mojo::PendingReceiver<mojom::IndexSyncProxy> index_receiver);
private: private:
LocalSearchServiceSync* const service_; LocalSearchServiceSync* const service_;
mojo::ReceiverSet<mojom::LocalSearchServiceProxy> receivers_; mojo::ReceiverSet<mojom::LocalSearchServiceSyncProxy> receivers_;
std::map<IndexId, std::unique_ptr<IndexProxy>> indices_; std::map<IndexId, std::unique_ptr<IndexSyncProxy>> indices_;
}; };
} // namespace local_search_service } // namespace local_search_service
} // namespace chromeos } // namespace chromeos
#endif // CHROMEOS_COMPONENTS_LOCAL_SEARCH_SERVICE_LOCAL_SEARCH_SERVICE_PROXY_H_ #endif // CHROMEOS_COMPONENTS_LOCAL_SEARCH_SERVICE_LOCAL_SEARCH_SERVICE_SYNC_PROXY_H_
...@@ -2,48 +2,52 @@ ...@@ -2,48 +2,52 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chromeos/components/local_search_service/local_search_service_proxy_factory.h" #include "chromeos/components/local_search_service/local_search_service_sync_proxy_factory.h"
#include "chromeos/components/local_search_service/local_search_service_proxy.h"
#include "chromeos/components/local_search_service/local_search_service_sync_factory.h" #include "chromeos/components/local_search_service/local_search_service_sync_factory.h"
#include "chromeos/components/local_search_service/local_search_service_sync_proxy.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h" #include "components/keyed_service/content/browser_context_dependency_manager.h"
namespace chromeos { namespace chromeos {
namespace local_search_service { namespace local_search_service {
// static // static
LocalSearchServiceProxy* LocalSearchServiceProxyFactory::GetForBrowserContext( LocalSearchServiceSyncProxy*
LocalSearchServiceSyncProxyFactory::GetForBrowserContext(
content::BrowserContext* context) { content::BrowserContext* context) {
return static_cast<LocalSearchServiceProxy*>( return static_cast<LocalSearchServiceSyncProxy*>(
LocalSearchServiceProxyFactory::GetInstance() LocalSearchServiceSyncProxyFactory::GetInstance()
->GetServiceForBrowserContext(context, /*create=*/true)); ->GetServiceForBrowserContext(context, /*create=*/true));
} }
// static // static
LocalSearchServiceProxyFactory* LocalSearchServiceProxyFactory::GetInstance() { LocalSearchServiceSyncProxyFactory*
static base::NoDestructor<LocalSearchServiceProxyFactory> instance; LocalSearchServiceSyncProxyFactory::GetInstance() {
static base::NoDestructor<LocalSearchServiceSyncProxyFactory> instance;
return instance.get(); return instance.get();
} }
LocalSearchServiceProxyFactory::LocalSearchServiceProxyFactory() LocalSearchServiceSyncProxyFactory::LocalSearchServiceSyncProxyFactory()
: BrowserContextKeyedServiceFactory( : BrowserContextKeyedServiceFactory(
"LocalSearchServiceProxy", "LocalSearchServiceSyncProxy",
BrowserContextDependencyManager::GetInstance()) { BrowserContextDependencyManager::GetInstance()) {
DependsOn(LocalSearchServiceSyncFactory::GetInstance()); DependsOn(LocalSearchServiceSyncFactory::GetInstance());
} }
LocalSearchServiceProxyFactory::~LocalSearchServiceProxyFactory() = default; LocalSearchServiceSyncProxyFactory::~LocalSearchServiceSyncProxyFactory() =
default;
content::BrowserContext* LocalSearchServiceProxyFactory::GetBrowserContextToUse( content::BrowserContext*
LocalSearchServiceSyncProxyFactory::GetBrowserContextToUse(
content::BrowserContext* context) const { content::BrowserContext* context) const {
// The service should exist in incognito mode. // The service should exist in incognito mode.
return context; return context;
} }
KeyedService* LocalSearchServiceProxyFactory::BuildServiceInstanceFor( KeyedService* LocalSearchServiceSyncProxyFactory::BuildServiceInstanceFor(
content::BrowserContext* context) const { content::BrowserContext* context) const {
DCHECK(context); DCHECK(context);
return new LocalSearchServiceProxy( return new LocalSearchServiceSyncProxy(
LocalSearchServiceSyncFactory::GetForBrowserContext(context)); LocalSearchServiceSyncFactory::GetForBrowserContext(context));
} }
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROMEOS_COMPONENTS_LOCAL_SEARCH_SERVICE_LOCAL_SEARCH_SERVICE_PROXY_FACTORY_H_ #ifndef CHROMEOS_COMPONENTS_LOCAL_SEARCH_SERVICE_LOCAL_SEARCH_SERVICE_SYNC_PROXY_FACTORY_H_
#define CHROMEOS_COMPONENTS_LOCAL_SEARCH_SERVICE_LOCAL_SEARCH_SERVICE_PROXY_FACTORY_H_ #define CHROMEOS_COMPONENTS_LOCAL_SEARCH_SERVICE_LOCAL_SEARCH_SERVICE_SYNC_PROXY_FACTORY_H_
#include "base/no_destructor.h" #include "base/no_destructor.h"
#include "components/keyed_service/content/browser_context_keyed_service_factory.h" #include "components/keyed_service/content/browser_context_keyed_service_factory.h"
...@@ -11,25 +11,25 @@ ...@@ -11,25 +11,25 @@
namespace chromeos { namespace chromeos {
namespace local_search_service { namespace local_search_service {
class LocalSearchServiceProxy; class LocalSearchServiceSyncProxy;
class LocalSearchServiceProxyFactory class LocalSearchServiceSyncProxyFactory
: public BrowserContextKeyedServiceFactory { : public BrowserContextKeyedServiceFactory {
public: public:
static LocalSearchServiceProxy* GetForBrowserContext( static LocalSearchServiceSyncProxy* GetForBrowserContext(
content::BrowserContext* context); content::BrowserContext* context);
static LocalSearchServiceProxyFactory* GetInstance(); static LocalSearchServiceSyncProxyFactory* GetInstance();
LocalSearchServiceProxyFactory(const LocalSearchServiceProxyFactory&) = LocalSearchServiceSyncProxyFactory(
delete; const LocalSearchServiceSyncProxyFactory&) = delete;
LocalSearchServiceProxyFactory& operator=( LocalSearchServiceSyncProxyFactory& operator=(
const LocalSearchServiceProxyFactory&) = delete; const LocalSearchServiceSyncProxyFactory&) = delete;
private: private:
friend class base::NoDestructor<LocalSearchServiceProxyFactory>; friend class base::NoDestructor<LocalSearchServiceSyncProxyFactory>;
LocalSearchServiceProxyFactory(); LocalSearchServiceSyncProxyFactory();
~LocalSearchServiceProxyFactory() override; ~LocalSearchServiceSyncProxyFactory() override;
// BrowserContextKeyedServiceFactory: // BrowserContextKeyedServiceFactory:
content::BrowserContext* GetBrowserContextToUse( content::BrowserContext* GetBrowserContextToUse(
...@@ -41,4 +41,4 @@ class LocalSearchServiceProxyFactory ...@@ -41,4 +41,4 @@ class LocalSearchServiceProxyFactory
} // namespace local_search_service } // namespace local_search_service
} // namespace chromeos } // namespace chromeos
#endif // CHROMEOS_COMPONENTS_LOCAL_SEARCH_SERVICE_LOCAL_SEARCH_SERVICE_PROXY_FACTORY_H_ #endif // CHROMEOS_COMPONENTS_LOCAL_SEARCH_SERVICE_LOCAL_SEARCH_SERVICE_SYNC_PROXY_FACTORY_H_
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chromeos/components/local_search_service/local_search_service_proxy.h" #include "chromeos/components/local_search_service/local_search_service_sync_proxy.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/test/task_environment.h" #include "base/test/task_environment.h"
#include "chromeos/components/local_search_service/index_proxy.h" #include "chromeos/components/local_search_service/index_sync_proxy.h"
#include "chromeos/components/local_search_service/local_search_service_sync.h" #include "chromeos/components/local_search_service/local_search_service_sync.h"
#include "chromeos/components/local_search_service/mojom/types.mojom.h" #include "chromeos/components/local_search_service/mojom/types.mojom.h"
#include "mojo/public/cpp/bindings/remote.h" #include "mojo/public/cpp/bindings/remote.h"
...@@ -16,25 +16,25 @@ ...@@ -16,25 +16,25 @@
namespace chromeos { namespace chromeos {
namespace local_search_service { namespace local_search_service {
class LocalSearchServiceProxyTest : public testing::Test { class LocalSearchServiceSyncProxyTest : public testing::Test {
public: public:
LocalSearchServiceProxyTest() { LocalSearchServiceSyncProxyTest() {
service_proxy_ = std::make_unique<LocalSearchServiceProxy>(&service_); service_proxy_ = std::make_unique<LocalSearchServiceSyncProxy>(&service_);
service_proxy_->BindReceiver(service_remote_.BindNewPipeAndPassReceiver()); service_proxy_->BindReceiver(service_remote_.BindNewPipeAndPassReceiver());
} }
protected: protected:
mojo::Remote<mojom::LocalSearchServiceProxy> service_remote_; mojo::Remote<mojom::LocalSearchServiceSyncProxy> service_remote_;
private: private:
base::test::TaskEnvironment task_environment_; base::test::TaskEnvironment task_environment_;
LocalSearchServiceSync service_; LocalSearchServiceSync service_;
std::unique_ptr<LocalSearchServiceProxy> service_proxy_; std::unique_ptr<LocalSearchServiceSyncProxy> service_proxy_;
}; };
TEST_F(LocalSearchServiceProxyTest, GetIndex) { TEST_F(LocalSearchServiceSyncProxyTest, GetIndex) {
mojo::Remote<mojom::IndexProxy> index_remote; mojo::Remote<mojom::IndexSyncProxy> index_remote;
service_remote_->GetIndex(IndexId::kCrosSettings, Backend::kLinearMap, service_remote_->GetIndex(IndexId::kCrosSettings, Backend::kLinearMap,
index_remote.BindNewPipeAndPassReceiver()); index_remote.BindNewPipeAndPassReceiver());
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
......
...@@ -18,17 +18,17 @@ enum Backend { ...@@ -18,17 +18,17 @@ enum Backend {
kInvertedIndex = 1 kInvertedIndex = 1
}; };
// LocalSearchServiceProxy creates and owns content-specific IndexProxies. // LocalSearchServiceSyncProxy creates and owns content-specific IndexProxies.
// Clients can call |GetIndex| to get an IndexProxy for a given index id. // Clients can call |GetIndex| to get an IndexSyncProxy for a given index id.
interface LocalSearchServiceProxy { interface LocalSearchServiceSyncProxy {
// A client can call this function to bind an IndexProxy for |index_id|. If // A client can call this function to bind an IndexSyncProxy for |index_id|.
// the Index isn't created when this function is called, LocalSearchService // If the Index isn't created when this function is called, LocalSearchService
// will create one. // will create one.
// Note, there should be one primary client that is the owner of the data and // Note, there should be one primary client that is the owner of the data and
// can read/write the data to the Index. The other clients should only use // can read/write the data to the Index. The other clients should only use
// the Index for query search. // the Index for query search.
GetIndex(IndexId index_id, Backend backend, GetIndex(IndexId index_id, Backend backend,
pending_receiver<IndexProxy> index_receiver); pending_receiver<IndexSyncProxy> index_receiver);
}; };
// A proxy to a local search service Index. // A proxy to a local search service Index.
...@@ -36,7 +36,7 @@ interface LocalSearchServiceProxy { ...@@ -36,7 +36,7 @@ interface LocalSearchServiceProxy {
// runs a search function to find matching items for a given query. // runs a search function to find matching items for a given query.
// Each Index can serve multiple clients, but only one client (the primary // Each Index can serve multiple clients, but only one client (the primary
// client) that owns the data should be allowed to modify the Index. // client) that owns the data should be allowed to modify the Index.
interface IndexProxy { interface IndexSyncProxy {
// Returns number of data items. // Returns number of data items.
GetSize() => (uint64 num_items); GetSize() => (uint64 num_items);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment