Index: mash/catalog_viewer/catalog_viewer.cc |
diff --git a/mash/catalog_viewer/catalog_viewer.cc b/mash/catalog_viewer/catalog_viewer.cc |
index 0aa4a241fa477e579a2d1354207957f586a8b4c9..e169ee4adcd6e863756916abb5365f5d7c8a898e 100644 |
--- a/mash/catalog_viewer/catalog_viewer.cc |
+++ b/mash/catalog_viewer/catalog_viewer.cc |
@@ -41,8 +41,7 @@ class CatalogViewerContents : public views::WidgetDelegateView, |
catalog_(std::move(catalog)), |
table_view_(nullptr), |
table_view_parent_(nullptr), |
- observer_(nullptr), |
- weak_ptr_factory_(this) { |
+ observer_(nullptr) { |
table_view_ = new views::TableView(this, GetColumns(), views::TEXT_ONLY, |
false); |
set_background(views::Background::CreateStandardPanelBackground()); |
@@ -50,12 +49,15 @@ class CatalogViewerContents : public views::WidgetDelegateView, |
table_view_parent_ = table_view_->CreateParentIfNecessary(); |
AddChildView(table_view_parent_); |
- catalog_->GetEntries(nullptr, |
- base::Bind(&CatalogViewerContents::OnGotCatalogEntries, |
- weak_ptr_factory_.GetWeakPtr())); |
// We don't want to show an empty UI so we just block until we have all the |
- // data. |
- catalog_.WaitForIncomingResponse(); |
+ // data. GetEntries is a sync call. |
+ mojo::Array<catalog::mojom::EntryPtr> entries; |
+ bool got = catalog_->GetEntries(nullptr, &entries); |
+ if (got) { |
+ for (auto& entry : entries) |
+ entries_.push_back(Entry(entry->display_name, entry->name)); |
+ observer_->OnModelChanged(); |
+ } |
} |
~CatalogViewerContents() override { |
table_view_->SetModel(nullptr); |
@@ -117,13 +119,6 @@ class CatalogViewerContents : public views::WidgetDelegateView, |
observer_ = observer; |
} |
- void OnGotCatalogEntries(mojo::Array<catalog::mojom::EntryPtr> entries) { |
- entries_.clear(); |
- for (auto& entry : entries) |
- entries_.push_back(Entry(entry->display_name, entry->name)); |
- observer_->OnModelChanged(); |
- } |
- |
static std::vector<ui::TableColumn> GetColumns() { |
std::vector<ui::TableColumn> columns; |
@@ -157,8 +152,6 @@ class CatalogViewerContents : public views::WidgetDelegateView, |
std::vector<Entry> entries_; |
- base::WeakPtrFactory<CatalogViewerContents> weak_ptr_factory_; |
- |
DISALLOW_COPY_AND_ASSIGN(CatalogViewerContents); |
}; |