Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Side by Side Diff: chrome/browser/extensions/api/mdns/mdns_api.h

Issue 22870011: chrome.mdns API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add tests Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013 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 #ifndef CHROME_BROWSER_EXTENSIONS_API_MDNS_MDNS_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_MDNS_MDNS_API_H_
7
8 #include <map>
9 #include <set>
10 #include <string>
11 #include <vector>
12
13 #include "base/gtest_prod_util.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/threading/thread_checker.h"
16 #include "chrome/browser/extensions/api/mdns/nsd_registry.h"
17 #include "chrome/browser/extensions/event_router.h"
18 #include "components/browser_context_keyed_service/browser_context_keyed_service .h"
19
20 namespace extensions {
21
22 // MDnsAPI is instantiated with the profile and will listen for extensions that
23 // register listeners for the MDNS extension API. It will use an NSD registry
24 // class to start discovery and observe new service events to dispatch them to
25 // registered extensions.
26 class MDnsAPI : public BrowserContextKeyedService,
27 public EventRouter::Observer,
28 public NsdRegistry::NsdObserver {
29 public:
30 explicit MDnsAPI(Profile* profile);
31 virtual ~MDnsAPI();
32
33 // Used to mock out the NsdRegistry for testing.
34 void SetNsdRegistryForTesting(NsdRegistry* registry);
35
36 protected:
37 // Retrieve an instance to the registry. Lazily create it if needed.
38 virtual NsdRegistry* nsd_registry();
39
40 private:
41 // Mapping from MDNS service types to currently listening extensions.
mark a. foltz 2013/09/05 23:08:14 "to the set of currently listening extensions (by
42 typedef std::map<std::string, std::set<std::string> >
43 ServiceTypeToExtensionsMap;
44
45 // EventRouter::Observer:
46 virtual void OnListenerAdded(const EventListenerInfo& details) OVERRIDE;
47 virtual void OnListenerRemoved(const EventListenerInfo& details) OVERRIDE;
48
49 // NsdRegistry::Observer
50 virtual void OnMDnsEvent(
51 const std::string& service_type,
52 const NsdRegistry::NsdServiceList& services) OVERRIDE;
53
54
55 base::ThreadChecker thread_checker_;
56 Profile* const profile_;
57 scoped_ptr<NsdRegistry> nsd_registry_;
58 ServiceTypeToExtensionsMap service_type_to_extensions_map_;
59
60 DISALLOW_COPY_AND_ASSIGN(MDnsAPI);
61 };
62
63 } // namespace extensions
64
65 #endif // CHROME_BROWSER_EXTENSIONS_API_MDNS_MDNS_API_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/mdns/OWNERS ('k') | chrome/browser/extensions/api/mdns/mdns_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698