OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_MDNS_MDNS_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_MDNS_MDNS_API_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_MDNS_MDNS_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_MDNS_MDNS_API_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/threading/thread_checker.h" | 12 #include "base/threading/thread_checker.h" |
13 #include "chrome/browser/extensions/api/mdns/dns_sd_registry.h" | 13 #include "chrome/browser/extensions/api/mdns/dns_sd_registry.h" |
14 #include "extensions/browser/browser_context_keyed_api_factory.h" | 14 #include "extensions/browser/browser_context_keyed_api_factory.h" |
15 #include "extensions/browser/event_router.h" | 15 #include "extensions/browser/event_router.h" |
16 #include "extensions/browser/extension_function.h" | |
16 | 17 |
17 namespace content { | 18 namespace content { |
18 class BrowserContext; | 19 class BrowserContext; |
19 } | 20 } |
20 | 21 |
21 namespace extensions { | 22 namespace extensions { |
22 | 23 |
23 class DnsSdRegistry; | 24 class DnsSdRegistry; |
24 | 25 |
25 // MDnsAPI is instantiated with the profile and will listen for extensions that | 26 // MDnsAPI is instantiated with the profile and will listen for extensions that |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
60 static const char* service_name() { | 61 static const char* service_name() { |
61 return "MDnsAPI"; | 62 return "MDnsAPI"; |
62 } | 63 } |
63 | 64 |
64 static const bool kServiceIsCreatedWithBrowserContext = true; | 65 static const bool kServiceIsCreatedWithBrowserContext = true; |
65 static const bool kServiceIsNULLWhileTesting = true; | 66 static const bool kServiceIsNULLWhileTesting = true; |
66 | 67 |
67 // Update the current list of service types and update the registry. | 68 // Update the current list of service types and update the registry. |
68 void UpdateMDnsListeners(const EventListenerInfo& details); | 69 void UpdateMDnsListeners(const EventListenerInfo& details); |
69 | 70 |
71 // Write a message to the consoles of extensions listening to a given service | |
72 // type. | |
73 void WriteToConsole(const std::string& service_type, | |
74 content::ConsoleMessageLevel level, | |
75 const std::string& message); | |
76 | |
77 // Finds all all the valid listeners of the mdns.onServiceList event and | |
78 // outputs them to |listeners| if |listeners| is non-null. Also outputs the | |
mark a. foltz
2015/04/06 23:01:43
There is no parameter named |listeners|.
Red Daly
2015/04/07 18:08:14
Done.
| |
79 // corresponding mDNS service types to |service_types| when |service_types| is | |
80 // non-null. | |
81 std::set<const EventListener*> GetValidOnServiceListListeners(); | |
mark a. foltz
2015/04/06 23:01:43
This is just used for iteration, return a const_it
Red Daly
2015/04/07 18:08:14
N/A with new interface, unless you think it makes
| |
82 | |
70 // Ensure methods are only called on UI thread. | 83 // Ensure methods are only called on UI thread. |
71 base::ThreadChecker thread_checker_; | 84 base::ThreadChecker thread_checker_; |
72 content::BrowserContext* const browser_context_; | 85 content::BrowserContext* const browser_context_; |
73 // Lazily created on first access and destroyed with this API class. | 86 // Lazily created on first access and destroyed with this API class. |
74 scoped_ptr<DnsSdRegistry> dns_sd_registry_; | 87 scoped_ptr<DnsSdRegistry> dns_sd_registry_; |
75 // Current set of service types registered with the registry. | 88 // Current set of service types registered with the registry. |
76 std::set<std::string> service_types_; | 89 std::set<std::string> service_types_; |
77 | 90 |
78 DISALLOW_COPY_AND_ASSIGN(MDnsAPI); | 91 DISALLOW_COPY_AND_ASSIGN(MDnsAPI); |
79 }; | 92 }; |
80 | 93 |
81 } // namespace extensions | 94 } // namespace extensions |
82 | 95 |
83 #endif // CHROME_BROWSER_EXTENSIONS_API_MDNS_MDNS_API_H_ | 96 #endif // CHROME_BROWSER_EXTENSIONS_API_MDNS_MDNS_API_H_ |
OLD | NEW |