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

Side by Side Diff: extensions/browser/api/media_perception_private/media_perception_api_manager.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_api_m anager.h"
6
7 #include "base/lazy_instance.h"
8 #include "base/memory/ptr_util.h"
9 #include "extensions/browser/event_router.h"
10
11 namespace mpp = extensions::api::media_perception_private;
12
13 namespace extensions {
14
15 // static
bmayer 2017/04/13 17:41:59 Static comments are typically discouraged in googl
Luke Sorenson 2017/04/13 17:58:21 I saw this // static comment in other BrowserConte
16 MediaPerceptionAPIManager* MediaPerceptionAPIManager::Get(
17 content::BrowserContext* context) {
18 return GetFactoryInstance()->Get(context);
19 }
20
21 static base::LazyInstance<
22 BrowserContextKeyedAPIFactory<MediaPerceptionAPIManager>>::DestructorAtExit
23 g_factory = LAZY_INSTANCE_INITIALIZER;
24
25 // static
26 BrowserContextKeyedAPIFactory<MediaPerceptionAPIManager>*
27 MediaPerceptionAPIManager::GetFactoryInstance() {
28 return g_factory.Pointer();
29 }
30
31 MediaPerceptionAPIManager::MediaPerceptionAPIManager(
32 content::BrowserContext* context)
33 : browser_context_(context) {}
34
35 MediaPerceptionAPIManager::~MediaPerceptionAPIManager() {}
36
37 void MediaPerceptionAPIManager::TriggerOnMediaPerceptionEvent() {
38 EventRouter* router = EventRouter::Get(browser_context_);
39 if (router && router->HasEventListener(mpp::OnMediaPerception::kEventName)) {
40 mpp::MediaPerception media_perception;
41 media_perception.timestamp.reset(new int(777));
42 std::unique_ptr<Event> event(
43 new Event(events::MEDIA_PERCEPTION_PRIVATE_ON_MEDIA_PERCEPTION,
44 mpp::OnMediaPerception::kEventName,
45 std::move(mpp::OnMediaPerception::Create(media_perception))));
46 router->BroadcastEvent(std::move(event));
47 }
48 }
49
50 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698