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

Unified Diff: services/ui/demo/mus_demo_external.cc

Issue 2712203002: c++ / mojo changes for 'external window mode'
Patch Set: addressed sky's request (take 4) Created 3 years, 9 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
Index: services/ui/demo/mus_demo_external.cc
diff --git a/services/ui/demo/mus_demo_external.cc b/services/ui/demo/mus_demo_external.cc
index 468506a978cbcba623afa4743c63ea8d6ae30612..6f61d6c0a83256c033f655b4f95cb8e5ce40df5f 100644
--- a/services/ui/demo/mus_demo_external.cc
+++ b/services/ui/demo/mus_demo_external.cc
@@ -22,18 +22,18 @@ namespace {
class WindowTreeDataExternal : public WindowTreeData {
public:
// Creates a new window tree host associated to the WindowTreeData.
- WindowTreeDataExternal(mojom::WindowTreeHostFactory* factory,
- mojom::WindowTreeClientPtr tree_client,
+ WindowTreeDataExternal(aura::WindowTreeClient* window_tree_client,
int square_size)
: WindowTreeData(square_size) {
- // TODO(tonikitoo,fwang): Extend the API to allow creating WindowTreeHost
- // using the WindowTreeClient.
- factory->CreateWindowTreeHost(MakeRequest(&host_), std::move(tree_client));
+ window_tree_host_ =
+ base::MakeUnique<aura::WindowTreeHostMus>(window_tree_client);
fwang 2017/03/07 09:21:24 IIUC, the Chromium style is to use setter for priv
tonikitoo 2017/03/07 14:00:49 Done.
}
private:
- // Holds the Mojo pointer to the window tree host.
- mojom::WindowTreeHostPtr host_;
+ void Init(
+ std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) override {
+ InitImpl(window_tree_host_.get());
+ }
fwang 2017/03/07 09:21:25 Let's postpone too much changes in MusDemo and jus
DISALLOW_COPY_AND_ASSIGN(WindowTreeDataExternal);
};
@@ -50,9 +50,11 @@ MusDemoExternal::~MusDemoExternal() {}
std::unique_ptr<aura::WindowTreeClient>
MusDemoExternal::CreateWindowTreeClient() {
- return base::MakeUnique<aura::WindowTreeClient>(
- context()->connector(), this, nullptr,
- MakeRequest(&window_tree_client_mojo_));
+ return base::MakeUnique<aura::WindowTreeClient>(context()->connector(), this);
+}
+
+bool MusDemoExternal::HasPendingWindowTreeData() const {
+ return initialized_windows_count_ != window_tree_data_list().size();
fwang 2017/03/07 09:21:24 Again overriding HasPendingWindowTreeData is not n
tonikitoo 2017/03/07 14:00:49 Done.
}
void MusDemoExternal::OnStartImpl() {
@@ -67,10 +69,7 @@ void MusDemoExternal::OnStartImpl() {
}
}
- // TODO(tonikitoo,fwang): Extend the WindowTreeClient API to allow connection
- // to the window tree host factory using window_tree_client().
- context()->connector()->BindInterface(ui::mojom::kServiceName,
- &window_tree_host_factory_);
+ window_tree_client()->ConnectViaWindowTreeHostFactory();
// TODO(tonikitoo,fwang): Implement management of displays in external mode.
// For now, a fake display is created in order to work around an assertion in
@@ -86,19 +85,15 @@ void MusDemoExternal::OnStartImpl() {
}
void MusDemoExternal::OpenNewWindow() {
- // TODO(tonikitoo,fwang): Extend the WindowTreeClient API to allow creation
- // of window tree host. Then pass window_tree_client() here and remove
- // window_tree_host_factory_ and window_tree_client_mojo_. Currently
- // window_tree_client_mojo_ is only initialized once so this is incorrect when
- // kNumberOfWindows > 1.
AppendWindowTreeData(base::MakeUnique<WindowTreeDataExternal>(
- window_tree_host_factory_.get(), std::move(window_tree_client_mojo_),
+ window_tree_client(),
GetSquareSizeForWindow(initialized_windows_count_)));
}
void MusDemoExternal::OnEmbed(
std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) {
- InitWindowTreeData(std::move(window_tree_host));
+ DCHECK(!window_tree_host);
+ InitWindowTreeData(nullptr);
fwang 2017/03/07 09:21:24 This is a bit weird, but I guess it's ok if we don
tonikitoo 2017/03/07 14:00:49 This is right. As written in the commit message, t
initialized_windows_count_++;
// Open the next window until the requested number of windows is reached.

Powered by Google App Engine
This is Rietveld 408576698