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

Unified Diff: extensions/browser/api/media_perception_private/media_perception_private_api.cc

Issue 2791983004: DBus MediaAnalyticsClient and media_perception pb. (Closed)
Patch Set: C++ test impl and target Created 3 years, 8 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: extensions/browser/api/media_perception_private/media_perception_private_api.cc
diff --git a/extensions/browser/api/media_perception_private/media_perception_private_api.cc b/extensions/browser/api/media_perception_private/media_perception_private_api.cc
new file mode 100644
index 0000000000000000000000000000000000000000..799d6d034157bb66574ae2f17233aa08848b3837
--- /dev/null
+++ b/extensions/browser/api/media_perception_private/media_perception_private_api.cc
@@ -0,0 +1,61 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "extensions/browser/api/media_perception_private/media_perception_private_api.h"
+
+#include "extensions/browser/api/media_perception_private/media_perception_api_manager.h"
+
+namespace mpp = extensions::api::media_perception_private;
+
+namespace extensions {
+
+MediaPerceptionPrivateGetStateFunction ::
+ MediaPerceptionPrivateGetStateFunction() {}
+
+MediaPerceptionPrivateGetStateFunction ::
+ ~MediaPerceptionPrivateGetStateFunction() {}
+
+bool MediaPerceptionPrivateGetStateFunction::RunAsync() {
+ MediaPerceptionAPIManager* manager =
+ MediaPerceptionAPIManager::Get(browser_context());
+ if (!manager) {
+ SetError("Can't get manager");
+ return false;
+ }
+ mpp::State result;
+ result.status = manager->status_;
+ SetResult(result.ToValue());
+ SendResponse(true);
+ return true;
+}
+
+MediaPerceptionPrivateSetStateFunction ::
+ MediaPerceptionPrivateSetStateFunction() {}
+
+MediaPerceptionPrivateSetStateFunction ::
+ ~MediaPerceptionPrivateSetStateFunction() {}
+
+bool MediaPerceptionPrivateSetStateFunction::RunAsync() {
+ std::unique_ptr<mpp::SetState::Params> params =
+ mpp::SetState::Params::Create(*args_);
+ EXTENSION_FUNCTION_VALIDATE(params.get());
+ const auto& status = params->state.status;
+ // Test triggering an onMediaPerception event.
+ MediaPerceptionAPIManager* manager =
+ MediaPerceptionAPIManager::Get(browser_context());
+ if (!manager) {
+ SetError("Can't get manager");
+ return false;
+ }
+ manager->TriggerOnMediaPerceptionEvent();
+ manager->status_ = status;
+ // Echo the status right back.
+ mpp::State result;
+ result.status = manager->status_;
+ SetResult(result.ToValue());
+ SendResponse(true);
+ return true;
+}
+
+} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698