Commit 817aa173 authored by Luke Sorenson's avatar Luke Sorenson Committed by Commit Bot

Component Updater IDL interface for MPP

Bug: 780546
Change-Id: Ic363067d95e66f340f9c9425381d57eafd474980
Reviewed-on: https://chromium-review.googlesource.com/751285Reviewed-by: default avatarIlya Sherman <isherman@chromium.org>
Reviewed-by: default avatarToni Barzic <tbarzic@chromium.org>
Commit-Queue: Ilya Sherman <isherman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#516010}
parent ddf12d1e
......@@ -216,6 +216,7 @@ mri::State::Status StateStatusIdlToProto(const State& state) {
case STATUS_RESTARTING:
return mri::State::RESTARTING;
case STATUS_SERVICE_ERROR:
case STATUS_STOPPED: // Process is stopped by MPP.
case STATUS_NONE:
return mri::State::STATUS_UNSPECIFIED;
}
......
......@@ -224,6 +224,10 @@ TEST(MediaPerceptionConversionUtilsTest, StateIdlToProto) {
state.status = media_perception::STATUS_RESTARTING;
state_proto = StateIdlToProto(state);
EXPECT_EQ(state_proto.status(), mri::State::RESTARTING);
state.status = media_perception::STATUS_STOPPED;
state_proto = StateIdlToProto(state);
EXPECT_EQ(mri::State::STATUS_UNSPECIFIED, state_proto.status());
}
} // namespace extensions
......@@ -87,4 +87,15 @@ void MediaPerceptionPrivateGetDiagnosticsFunction::GetDiagnosticsCallback(
Respond(OneArgument(diagnostics.ToValue()));
}
MediaPerceptionPrivateSetAnalyticsComponentFunction::
MediaPerceptionPrivateSetAnalyticsComponentFunction() {}
MediaPerceptionPrivateSetAnalyticsComponentFunction::
~MediaPerceptionPrivateSetAnalyticsComponentFunction() {}
ExtensionFunction::ResponseAction
MediaPerceptionPrivateSetAnalyticsComponentFunction::Run() {
return RespondNow(Error("Not implemented."));
}
} // namespace extensions
......@@ -66,6 +66,22 @@ class MediaPerceptionPrivateGetDiagnosticsFunction
DISALLOW_COPY_AND_ASSIGN(MediaPerceptionPrivateGetDiagnosticsFunction);
};
class MediaPerceptionPrivateSetAnalyticsComponentFunction
: public UIThreadExtensionFunction {
public:
MediaPerceptionPrivateSetAnalyticsComponentFunction();
DECLARE_EXTENSION_FUNCTION("mediaPerceptionPrivate.setAnalyticsComponent",
MEDIAPERCEPTIONPRIVATE_SETANALYTICSCOMPONENT);
private:
~MediaPerceptionPrivateSetAnalyticsComponentFunction() override;
// ExtensionFunction:
ResponseAction Run() override;
DISALLOW_COPY_AND_ASSIGN(MediaPerceptionPrivateSetAnalyticsComponentFunction);
};
} // namespace extensions
#endif // EXTENSIONS_BROWSER_API_MEDIA_PERCEPTION_PRIVATE_MEDIA_PERCEPTION_PRIVATE_API_H_
......@@ -1260,6 +1260,7 @@ enum HistogramValue {
ACCESSIBILITY_PRIVATE_SETNATIVECHROMEVOXARCSUPPORTFORCURRENTAPP,
LANGUAGESETTINGSPRIVATE_SETENABLETRANSLATIONFORLANGUAGE,
LANGUAGESETTINGSPRIVATE_MOVELANGUAGE,
MEDIAPERCEPTIONPRIVATE_SETANALYTICSCOMPONENT,
// Last entry: Add new entries above, then run:
// python tools/metrics/histograms/update_extension_histograms.py
ENUM_BOUNDARY
......
......@@ -29,13 +29,16 @@ namespace mediaPerceptionPrivate {
// the media processing pipeline is suspended.
SUSPENDED,
// Enum for restarting the media analytics process using upstart.
// Enum for restarting the media analytics process using Upstart.
// Calling setState <code>RESTARTING</code> will restart the media process
// to the <code>SUSPENDED</code> state. The app has to set the state to
// <code>RUNNING</code> in order to start receiving media perception
// information again.
RESTARTING,
// Stops the media analytics process via Upstart.
STOPPED,
// Indicates that a ServiceError has occurred.
SERVICE_ERROR
};
......@@ -54,6 +57,33 @@ namespace mediaPerceptionPrivate {
SERVICE_BUSY_LAUNCHING
};
enum ComponentType {
// The smaller component with limited functionality (smaller size and
// limited models).
LIGHT,
// The fully-featured component with more functionality (larger size and
// more models).
FULL
};
// The status of the media analytics process component on the device.
enum ComponentStatus {
UNKNOWN,
// The component is successfully installed and the image is mounted.
INSTALLED,
// The component failed to download, install or load.
FAILED_TO_INSTALL
};
dictionary Component {
ComponentType type;
};
// The state of the media analytics downloadable component.
dictionary ComponentState {
ComponentStatus status;
};
// The system and configuration state of the analytics process.
dictionary State {
Status status;
......@@ -192,6 +222,8 @@ namespace mediaPerceptionPrivate {
callback DiagnosticsCallback = void(Diagnostics diagnostics);
callback ComponentStateCallback = void(ComponentState componentState);
interface Functions {
// Gets the status of the media perception process.
// |callback| : The current state of the system.
......@@ -208,6 +240,20 @@ namespace mediaPerceptionPrivate {
// Get a diagnostics buffer out of the video analytics process.
// |callback| : Returns a Diagnostics dictionary object.
static void getDiagnostics(DiagnosticsCallback callback);
// Attempts to download and load the media analytics component. This
// function should be called every time a client starts using this API. If
// the component is already loaded, the callback will simply return that
// information. The process must be <code>STOPPED</code> for this function
// to succeed.
// Note: If a different component type is desired, this function can
// be called with the new desired type and the new component will be
// downloaded and installed.
// |component| : The desired component to install and load.
// |callback| : Returns the state of the component.
static void setAnalyticsComponent(
Component component,
ComponentStateCallback callback);
};
interface Events {
......
......@@ -14007,6 +14007,7 @@ Called by update_net_error_codes.py.-->
<int value="1198"
label="LANGUAGESETTINGSPRIVATE_SETENABLETRANSLATIONFORLANGUAGE"/>
<int value="1199" label="LANGUAGESETTINGSPRIVATE_MOVELANGUAGE"/>
<int value="1200" label="MEDIAPERCEPTIONPRIVATE_SETANALYTICSCOMPONENT"/>
</enum>
<enum name="ExtensionIconState">
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