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

Side by Side 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: 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 unified diff | Download patch
OLDNEW
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 "mash/catalog_viewer/catalog_viewer.h" 5 #include "mash/catalog_viewer/catalog_viewer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 table_view_parent_(nullptr), 43 table_view_parent_(nullptr),
44 observer_(nullptr), 44 observer_(nullptr),
45 weak_ptr_factory_(this) { 45 weak_ptr_factory_(this) {
46 table_view_ = new views::TableView(this, GetColumns(), views::TEXT_ONLY, 46 table_view_ = new views::TableView(this, GetColumns(), views::TEXT_ONLY,
47 false); 47 false);
48 set_background(views::Background::CreateStandardPanelBackground()); 48 set_background(views::Background::CreateStandardPanelBackground());
49 49
50 table_view_parent_ = table_view_->CreateParentIfNecessary(); 50 table_view_parent_ = table_view_->CreateParentIfNecessary();
51 AddChildView(table_view_parent_); 51 AddChildView(table_view_parent_);
52 52
53 catalog_->GetEntries(nullptr,
54 base::Bind(&CatalogViewerContents::OnGotCatalogEntries,
55 weak_ptr_factory_.GetWeakPtr()));
56 // We don't want to show an empty UI so we just block until we have all the 53 // We don't want to show an empty UI so we just block until we have all the
57 // data. 54 // data. GetEntries is a sync call.
58 catalog_.WaitForIncomingResponse(); 55 mojo::Array<catalog::mojom::EntryPtr> entries;
56 catalog_->GetEntries(nullptr, &entries);
57
58 OnGotCatalogEntries(entries);
59 } 59 }
60 ~CatalogViewerContents() override { 60 ~CatalogViewerContents() override {
61 table_view_->SetModel(nullptr); 61 table_view_->SetModel(nullptr);
62 catalog_viewer_->RemoveWindow(GetWidget()); 62 catalog_viewer_->RemoveWindow(GetWidget());
63 } 63 }
64 64
65 private: 65 private:
66 struct Entry { 66 struct Entry {
67 Entry(const std::string& name, const std::string& url) 67 Entry(const std::string& name, const std::string& url)
68 : name(name), url(url) {} 68 : name(name), url(url) {}
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 default: 110 default:
111 NOTREACHED(); 111 NOTREACHED();
112 break; 112 break;
113 } 113 }
114 return base::string16(); 114 return base::string16();
115 } 115 }
116 void SetObserver(ui::TableModelObserver* observer) override { 116 void SetObserver(ui::TableModelObserver* observer) override {
117 observer_ = observer; 117 observer_ = observer;
118 } 118 }
119 119
120 void OnGotCatalogEntries(mojo::Array<catalog::mojom::EntryPtr> entries) { 120 void OnGotCatalogEntries(
121 const mojo::Array<catalog::mojom::EntryPtr>& entries) {
121 entries_.clear(); 122 entries_.clear();
122 for (auto& entry : entries) 123 for (auto& entry : entries)
123 entries_.push_back(Entry(entry->display_name, entry->name)); 124 entries_.push_back(Entry(entry->display_name, entry->name));
124 observer_->OnModelChanged(); 125 observer_->OnModelChanged();
125 } 126 }
126 127
127 static std::vector<ui::TableColumn> GetColumns() { 128 static std::vector<ui::TableColumn> GetColumns() {
128 std::vector<ui::TableColumn> columns; 129 std::vector<ui::TableColumn> columns;
129 130
130 ui::TableColumn name_column; 131 ui::TableColumn name_column;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 windows_.push_back(window); 209 windows_.push_back(window);
209 } 210 }
210 211
211 void CatalogViewer::Create(shell::Connection* connection, 212 void CatalogViewer::Create(shell::Connection* connection,
212 mojom::LaunchableRequest request) { 213 mojom::LaunchableRequest request) {
213 bindings_.AddBinding(this, std::move(request)); 214 bindings_.AddBinding(this, std::move(request));
214 } 215 }
215 216
216 } // namespace catalog_viewer 217 } // namespace catalog_viewer
217 } // namespace mash 218 } // namespace mash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698