Index: extensions/browser/api/media_perception_private/media_perception_api_manager.cc |
diff --git a/extensions/browser/api/media_perception_private/media_perception_api_manager.cc b/extensions/browser/api/media_perception_private/media_perception_api_manager.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..c33ffb0a6d5d594b690e4aedc0c7569c592baf83 |
--- /dev/null |
+++ b/extensions/browser/api/media_perception_private/media_perception_api_manager.cc |
@@ -0,0 +1,50 @@ |
+// 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_api_manager.h" |
+ |
+#include "base/lazy_instance.h" |
+#include "base/memory/ptr_util.h" |
+#include "extensions/browser/event_router.h" |
+ |
+namespace mpp = extensions::api::media_perception_private; |
+ |
+namespace extensions { |
+ |
+// 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
|
+MediaPerceptionAPIManager* MediaPerceptionAPIManager::Get( |
+ content::BrowserContext* context) { |
+ return GetFactoryInstance()->Get(context); |
+} |
+ |
+static base::LazyInstance< |
+ BrowserContextKeyedAPIFactory<MediaPerceptionAPIManager>>::DestructorAtExit |
+ g_factory = LAZY_INSTANCE_INITIALIZER; |
+ |
+// static |
+BrowserContextKeyedAPIFactory<MediaPerceptionAPIManager>* |
+MediaPerceptionAPIManager::GetFactoryInstance() { |
+ return g_factory.Pointer(); |
+} |
+ |
+MediaPerceptionAPIManager::MediaPerceptionAPIManager( |
+ content::BrowserContext* context) |
+ : browser_context_(context) {} |
+ |
+MediaPerceptionAPIManager::~MediaPerceptionAPIManager() {} |
+ |
+void MediaPerceptionAPIManager::TriggerOnMediaPerceptionEvent() { |
+ EventRouter* router = EventRouter::Get(browser_context_); |
+ if (router && router->HasEventListener(mpp::OnMediaPerception::kEventName)) { |
+ mpp::MediaPerception media_perception; |
+ media_perception.timestamp.reset(new int(777)); |
+ std::unique_ptr<Event> event( |
+ new Event(events::MEDIA_PERCEPTION_PRIVATE_ON_MEDIA_PERCEPTION, |
+ mpp::OnMediaPerception::kEventName, |
+ std::move(mpp::OnMediaPerception::Create(media_perception)))); |
+ router->BroadcastEvent(std::move(event)); |
+ } |
+} |
+ |
+} // namespace extensions |