OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2012 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 "chrome/browser/extensions/api/mdns/mdns_api.h" | |
6 | |
7 #include <vector> | |
8 | |
9 #include "base/time/time.h" | |
10 #include "chrome/browser/extensions/api/mdns/mdns_api_factory.h" | |
11 #include "chrome/browser/extensions/event_router.h" | |
12 #include "chrome/browser/extensions/extension_service.h" | |
13 #include "chrome/browser/extensions/extension_system.h" | |
14 #include "chrome/browser/profiles/profile.h" | |
15 #include "chrome/common/extensions/api/mdns.h" | |
16 #include "chrome/common/extensions/api/mdns/mdns_manifest_handler.h" | |
17 #include "content/public/browser/browser_thread.h" | |
18 #include "extensions/common/manifest_constants.h" | |
19 | |
20 using base::TimeDelta; | |
21 using content::BrowserThread; | |
22 | |
23 namespace extensions { | |
24 | |
25 namespace mdns = api::mdns; | |
26 | |
27 MDnsAPI::MDnsAPI(Profile* profile) : profile_(profile) { | |
28 ExtensionSystem::Get(profile)->event_router()->RegisterObserver( | |
mark a. foltz
2013/08/23 23:27:23
DCHECK(profile_)
justinlin
2013/08/27 00:09:25
Done.
| |
29 this, mdns::OnServiceList::kEventName); | |
30 } | |
31 | |
32 MDnsAPI::~MDnsAPI() {} | |
33 | |
34 NsdRegistry* MDnsAPI::nsd_registry() { | |
35 if (!nsd_registry_.get()) { | |
36 nsd_registry_.reset(new extensions::NsdRegistry()); | |
37 } | |
38 return nsd_registry_.get(); | |
39 } | |
40 | |
41 void MDnsAPI::OnListenerAdded(const EventListenerInfo& details) { | |
42 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
mark a. foltz
2013/08/23 23:27:23
Use base::NonThreadSafe or base::TheadChecker inst
justinlin
2013/08/27 00:09:25
Done.
| |
43 const extensions::Extension* extension = ExtensionSystem::Get(profile_)-> | |
44 extension_service()->GetExtensionById(details.extension_id, false); | |
45 MDnsInfo* info = static_cast<MDnsInfo*>( | |
46 extension->GetManifestData(manifest_keys::kMDnsServiceTypes)); | |
47 NsdRegistry* nsd_registry = | |
48 MDnsAPIFactory::GetForProfile(profile_)->nsd_registry(); | |
49 for (std::vector<std::string>::iterator it = info->service_types.begin(); | |
50 it != info->service_types.end(); ++it) { | |
51 LOG(ERROR) << "LISTENING FOR SERVICE TYPE " << *it; | |
52 nsd_registry->RegisterMDnsListener(*it); | |
mark a. foltz
2013/08/23 23:27:23
When an extension is unloaded or disabled, do we h
justinlin
2013/08/27 00:09:25
Done.
| |
53 } | |
54 } | |
55 | |
56 void MDnsAPI::OnListenerRemoved(const EventListenerInfo& details) { | |
57 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
58 // TODO(justinlin): Unregister. | |
59 } | |
60 | |
61 void MDnsAPI::OnNsdEvent(const NsdRegistry::NsdDeviceList& devices) { | |
62 | |
63 } | |
64 | |
65 void MDnsAPI::OnNsdEvent(NsdRegistry::NsdErrorCode type) { | |
66 | |
67 } | |
68 | |
69 } // namespace extensions | |
OLD | NEW |