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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "extensions/browser/api/media_perception_private/media_perception_priva te_api.h"
6
7 #include "extensions/browser/api/media_perception_private/media_perception_api_m anager.h"
8
9 namespace mpp = extensions::api::media_perception_private;
10
11 namespace extensions {
12
13 MediaPerceptionPrivateGetStateFunction ::
14 MediaPerceptionPrivateGetStateFunction() {}
15
16 MediaPerceptionPrivateGetStateFunction ::
17 ~MediaPerceptionPrivateGetStateFunction() {}
18
19 bool MediaPerceptionPrivateGetStateFunction::RunAsync() {
20 MediaPerceptionAPIManager* manager =
21 MediaPerceptionAPIManager::Get(browser_context());
22 if (!manager) {
23 SetError("Can't get manager");
24 return false;
25 }
26 mpp::State result;
27 result.status = manager->status_;
28 SetResult(result.ToValue());
29 SendResponse(true);
30 return true;
31 }
32
33 MediaPerceptionPrivateSetStateFunction ::
34 MediaPerceptionPrivateSetStateFunction() {}
35
36 MediaPerceptionPrivateSetStateFunction ::
37 ~MediaPerceptionPrivateSetStateFunction() {}
38
39 bool MediaPerceptionPrivateSetStateFunction::RunAsync() {
40 std::unique_ptr<mpp::SetState::Params> params =
41 mpp::SetState::Params::Create(*args_);
42 EXTENSION_FUNCTION_VALIDATE(params.get());
43 const auto& status = params->state.status;
44 // Test triggering an onMediaPerception event.
45 MediaPerceptionAPIManager* manager =
46 MediaPerceptionAPIManager::Get(browser_context());
47 if (!manager) {
48 SetError("Can't get manager");
49 return false;
50 }
51 manager->TriggerOnMediaPerceptionEvent();
52 manager->status_ = status;
53 // Echo the status right back.
54 mpp::State result;
55 result.status = manager->status_;
56 SetResult(result.ToValue());
57 SendResponse(true);
58 return true;
59 }
60
61 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698