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 // filters them by service type if |service_type_filter| is non-empty. The |
| 79 // extension ids and matched service types are output to |extension_ids| and |
| 80 // |service_types|, respectively, if the supplied pointers is non-null. |
| 81 void GetValidOnServiceListListeners(const std::string& service_type_filter, |
| 82 std::set<std::string>* extension_ids, |
| 83 std::set<std::string>* service_types); |
| 84 |
70 // Ensure methods are only called on UI thread. | 85 // Ensure methods are only called on UI thread. |
71 base::ThreadChecker thread_checker_; | 86 base::ThreadChecker thread_checker_; |
72 content::BrowserContext* const browser_context_; | 87 content::BrowserContext* const browser_context_; |
73 // Lazily created on first access and destroyed with this API class. | 88 // Lazily created on first access and destroyed with this API class. |
74 scoped_ptr<DnsSdRegistry> dns_sd_registry_; | 89 scoped_ptr<DnsSdRegistry> dns_sd_registry_; |
75 // Current set of service types registered with the registry. | 90 // Current set of service types registered with the registry. |
76 std::set<std::string> service_types_; | 91 std::set<std::string> service_types_; |
77 | 92 |
78 DISALLOW_COPY_AND_ASSIGN(MDnsAPI); | 93 DISALLOW_COPY_AND_ASSIGN(MDnsAPI); |
79 }; | 94 }; |
80 | 95 |
81 } // namespace extensions | 96 } // namespace extensions |
82 | 97 |
83 #endif // CHROME_BROWSER_EXTENSIONS_API_MDNS_MDNS_API_H_ | 98 #endif // CHROME_BROWSER_EXTENSIONS_API_MDNS_MDNS_API_H_ |
OLD | NEW |