Commit 7f57e462 authored by Noel Gordon's avatar Noel Gordon Committed by Commit Bot

[filesapp] Remove the Mojo demo API code from SWA files app

The example mojo code is being moved the SWA sample app. Remove it from
SWA files app, leaving an empty shell that will be filled-in later.

Bug: 1113981
Change-Id: If329ce6ba9df1bc08394892d67d6023f91cbeb21
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2536581Reviewed-by: default avatarSam McNally <sammc@chromium.org>
Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Commit-Queue: Noel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#827687}
parent 364370dc
......@@ -17,29 +17,5 @@ FileManagerPageHandler::FileManagerPageHandler(
FileManagerPageHandler::~FileManagerPageHandler() = default;
void FileManagerPageHandler::GetFoo(GetFooCallback callback) {
std::move(callback).Run(foo_);
}
void FileManagerPageHandler::SetFoo(const std::string& foo) {
foo_ = foo;
}
void FileManagerPageHandler::DoABarrelRoll() {
barrel_roll_timer_.Start(
FROM_HERE, base::TimeDelta::FromSeconds(1),
base::BindOnce(&FileManagerPageHandler::OnBarrelRollDone,
base::Unretained(this)));
}
void FileManagerPageHandler::OnBarrelRollDone() {
page_->GetBar(foo_, base::BindOnce(&FileManagerPageHandler::OnBarReceived,
base::Unretained(this)));
}
void FileManagerPageHandler::OnBarReceived(const std::string& bar) {
page_->OnSomethingHappened(foo_, bar);
}
} // namespace file_manager
} // namespace chromeos
......@@ -7,7 +7,6 @@
#include <memory>
#include "base/timer/timer.h"
#include "chromeos/components/file_manager/mojom/file_manager.mojom.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
......@@ -29,20 +28,8 @@ class FileManagerPageHandler : public mojom::PageHandler {
FileManagerPageHandler& operator=(const FileManagerPageHandler&) = delete;
private:
// mojom::PageHandler:
void GetFoo(GetFooCallback callback) override;
void SetFoo(const std::string& foo) override;
void DoABarrelRoll() override;
void OnBarrelRollDone();
void OnBarReceived(const std::string& bar);
mojo::Receiver<mojom::PageHandler> receiver_;
mojo::Remote<mojom::Page> page_;
std::string foo_;
base::OneShotTimer barrel_roll_timer_;
};
} // namespace file_manager
......
......@@ -15,20 +15,10 @@ interface PageHandlerFactory {
// Lives in the browser process. A renderer uses this to control/query the
// backend of the app.
interface PageHandler {
// Getter example.
GetFoo() => (string foo);
// Setter example.
SetFoo(string foo);
// Fire-an-forget action example.
DoABarrelRoll();
};
// Lives in the renderer process. The browser uses this to send status
// updates to the web page in the renderer and in rare cases to fetch
// some info from there.
interface Page {
// Notification example.
OnSomethingHappened(string something, string other);
// Reverse getter example. Unlikely something like that will be needed.
GetBar(string foo) => (string bar);
};
......@@ -22,39 +22,8 @@ class FileManagerApp {
document.body.appendChild(legacyLoader);
}
/**
* Demonstrates Mojo interactions.
*/
demoMojo() {
// Basic example of establishing communication with the backend.
const browserProxy = new BrowserProxy();
// There must be only one listener returning values.
browserProxy.callbackRouter.getBar.addListener((foo) => {
console.log('GetBar(' + foo + ')');
return Promise.resolve({bar: 'baz'});
});
// Listen-only callbacks can be multiple.
browserProxy.callbackRouter.onSomethingHappened.addListener(
(something, other) => {
console.log('OnSomethingHappened(' + something + ', ' + other + ')');
});
browserProxy.callbackRouter.onSomethingHappened.addListener(
(something, other) => {
console.log('eh? ' + something + '. what? ' + other);
});
// Show the interaction via Mojo.
window.setTimeout(() => {
browserProxy.handler.setFoo('foo-value');
browserProxy.handler.doABarrelRoll();
}, 1000);
}
run() {
this.loadLegacyCode();
this.demoMojo();
}
}
......
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