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

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

Issue 23437015: Initial chrome.mdns API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
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
mark a. foltz 2013/08/30 01:35:52 s/MDNS/chrome.mdns/
mark a. foltz 2013/08/30 01:35:52 You might explain what 'NSD' means in this context
mark a. foltz 2013/08/30 01:35:52 extensions that register DNS-SD service types with
justinlin 2013/09/03 21:21:56 Done.
justinlin 2013/09/03 21:21:56 Not addressing this for now since we might use fil
justinlin 2013/09/03 21:21:56 Done.
24 // class to start discovery and observe new service events to dispatch them to
mark a. foltz 2013/08/30 01:35:52 ... to start the mDNS listener process (if necessa
justinlin 2013/09/03 21:21:56 Done.
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);
mark a. foltz 2013/08/30 01:35:52 Since nsd_registry() is virtual would it be easier
justinlin 2013/09/03 21:21:56 The problem is that in browser_tests, I can't see
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.
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_;
mark a. foltz 2013/08/30 01:35:52 Add a comment that this API is normally only calle
justinlin 2013/09/03 21:21:56 Done.
56 Profile* const profile_;
57 scoped_ptr<NsdRegistry> nsd_registry_;
mark a. foltz 2013/08/30 01:35:52 Add a comment? Note that it is created lazily and
justinlin 2013/09/03 21:21:56 Done.
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

Powered by Google App Engine
This is Rietveld 408576698