Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 | |
| OLD | NEW |