| 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 |
| 70 // Ensure methods are only called on UI thread. | 77 // Ensure methods are only called on UI thread. |
| 71 base::ThreadChecker thread_checker_; | 78 base::ThreadChecker thread_checker_; |
| 72 content::BrowserContext* const browser_context_; | 79 content::BrowserContext* const browser_context_; |
| 73 // Lazily created on first access and destroyed with this API class. | 80 // Lazily created on first access and destroyed with this API class. |
| 74 scoped_ptr<DnsSdRegistry> dns_sd_registry_; | 81 scoped_ptr<DnsSdRegistry> dns_sd_registry_; |
| 75 // Current set of service types registered with the registry. | 82 // Current set of service types registered with the registry. |
| 76 std::set<std::string> service_types_; | 83 std::set<std::string> service_types_; |
| 77 | 84 |
| 78 DISALLOW_COPY_AND_ASSIGN(MDnsAPI); | 85 DISALLOW_COPY_AND_ASSIGN(MDnsAPI); |
| 79 }; | 86 }; |
| 80 | 87 |
| 81 } // namespace extensions | 88 } // namespace extensions |
| 82 | 89 |
| 83 #endif // CHROME_BROWSER_EXTENSIONS_API_MDNS_MDNS_API_H_ | 90 #endif // CHROME_BROWSER_EXTENSIONS_API_MDNS_MDNS_API_H_ |
| OLD | NEW |