Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(396)

Unified Diff: mash/catalog_viewer/catalog_viewer.cc

Issue 2096293002: Eliminate usage of InterfacePtr::WaitForIncomingResponse. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix trybots failure Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/leveldb/remote_iterator_unittest.cc ('k') | mojo/public/cpp/bindings/interface_ptr.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
};
« no previous file with comments | « components/leveldb/remote_iterator_unittest.cc ('k') | mojo/public/cpp/bindings/interface_ptr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698