Commit 1a26a9be authored by Kevin Marshall's avatar Kevin Marshall Committed by Commit Bot

[Fuchsia] Modify QueryableData to send entry change events.

Change the FIDL interface QueryableData::GetAllEntries() to GetChangedEntries(),
which is identical to the current implementation on the first
invocation but on, but for subsequent invocations it uses hanging
callbacks to send incremental changes to the client.

The change is necessary for allowing QueryableData values to change at
page runtime.

Implementation of support for incremental change events are reserved for
a followup CL.


Bug: 929291
Change-Id: I7af7e77130eff55699a90fd5aff0a581bf3e3dd6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1500021
Commit-Queue: Kevin Marshall <kmarshall@chromium.org>
Reviewed-by: default avatarWez <wez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#637909}
parent 4721a358
......@@ -13,7 +13,10 @@ struct QueryableDataEntry {
/// to CastRunner instances.
[Discoverable]
protocol QueryableData {
/// Gets all entries managed by the QueryableData service.
GetAllEntries() -> (vector<QueryableDataEntry> values);
/// Gets a list of changed entries since the last call to GetChangedEntries,
/// delaying execution of the the pending callback until a change becomes
/// available. The initial call will return all entries managed by the
/// QueryableData service.
GetChangedEntries() -> (vector<QueryableDataEntry> values);
};
......@@ -21,7 +21,7 @@ void FakeQueryableData::Add(base::StringPiece key, const base::Value& value) {
entries_[key.as_string()] = cur_entry_converted;
}
void FakeQueryableData::GetAllEntries(GetAllEntriesCallback callback) {
void FakeQueryableData::GetChangedEntries(GetChangedEntriesCallback callback) {
std::vector<chromium::cast::QueryableDataEntry> output;
for (const auto& e : entries_) {
output.push_back(e.second);
......
......@@ -23,7 +23,7 @@ class FakeQueryableData : public chromium::cast::QueryableData {
void Add(base::StringPiece key, const base::Value& value);
// chromium::cast::QueryableData implementation.
void GetAllEntries(GetAllEntriesCallback callback) override;
void GetChangedEntries(GetChangedEntriesCallback callback) override;
private:
std::map<std::string, chromium::cast::QueryableDataEntry> entries_;
......
......@@ -32,7 +32,7 @@ QueryableDataBindings::QueryableDataBindings(
CHECK(base::PathService::Get(base::DIR_ASSETS, &assets_path));
InjectJavaScriptFileIntoFrame(assets_path.AppendASCII(kBindingsPath), frame_);
service_->GetAllEntries(
service_->GetChangedEntries(
fit::bind_member(this, &QueryableDataBindings::OnEntriesReceived));
}
......@@ -75,4 +75,7 @@ void QueryableDataBindings::OnEntriesReceived(
InjectJavaScriptBufferIntoFrame(std::move(initialize_values_js_buffer),
frame_);
// TODO(crbug.com/929291): Handle change events by calling and waiting on
// GetChangedEntries() here.
}
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