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

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

Issue 166053003: Move ProfileKeyedAPI implementations to take BrowserContext in the constructor (part 2). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: | Created 6 years, 10 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
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 "chrome/browser/extensions/api/profile_keyed_api_factory.h" 14 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h"
15 #include "extensions/browser/event_router.h" 15 #include "extensions/browser/event_router.h"
16 16
17 namespace content {
18 class BrowserContext;
19 }
20
17 namespace extensions { 21 namespace extensions {
18 22
19 class DnsSdRegistry; 23 class DnsSdRegistry;
20 24
21 // MDnsAPI is instantiated with the profile and will listen for extensions that 25 // MDnsAPI is instantiated with the profile and will listen for extensions that
22 // register listeners for the chrome.mdns extension API. It will use a registry 26 // register listeners for the chrome.mdns extension API. It will use a registry
23 // class to start the mDNS listener process (if necessary) and observe new 27 // class to start the mDNS listener process (if necessary) and observe new
24 // service events to dispatch them to registered extensions. 28 // service events to dispatch them to registered extensions.
25 class MDnsAPI : public ProfileKeyedAPI, 29 class MDnsAPI : public ProfileKeyedAPI,
26 public EventRouter::Observer, 30 public EventRouter::Observer,
27 public DnsSdRegistry::DnsSdObserver { 31 public DnsSdRegistry::DnsSdObserver {
28 public: 32 public:
29 explicit MDnsAPI(Profile* profile); 33 explicit MDnsAPI(content::BrowserContext* context);
30 virtual ~MDnsAPI(); 34 virtual ~MDnsAPI();
31 35
32 static MDnsAPI* Get(Profile* profile); 36 static MDnsAPI* Get(content::BrowserContext* context);
33 37
34 // ProfileKeyedAPI implementation. 38 // ProfileKeyedAPI implementation.
35 static ProfileKeyedAPIFactory<MDnsAPI>* GetFactoryInstance(); 39 static ProfileKeyedAPIFactory<MDnsAPI>* GetFactoryInstance();
36 40
37 // Used to mock out the DnsSdRegistry for testing. 41 // Used to mock out the DnsSdRegistry for testing.
38 void SetDnsSdRegistryForTesting(scoped_ptr<DnsSdRegistry> registry); 42 void SetDnsSdRegistryForTesting(scoped_ptr<DnsSdRegistry> registry);
39 43
40 protected: 44 protected:
41 // Retrieve an instance of the registry. Lazily created when needed. 45 // Retrieve an instance of the registry. Lazily created when needed.
42 virtual DnsSdRegistry* dns_sd_registry(); 46 virtual DnsSdRegistry* dns_sd_registry();
(...skipping 16 matching lines...) Expand all
59 } 63 }
60 64
61 static const bool kServiceIsCreatedWithBrowserContext = true; 65 static const bool kServiceIsCreatedWithBrowserContext = true;
62 static const bool kServiceIsNULLWhileTesting = true; 66 static const bool kServiceIsNULLWhileTesting = true;
63 67
64 // Update the current list of service types and update the registry. 68 // Update the current list of service types and update the registry.
65 void UpdateMDnsListeners(const EventListenerInfo& details); 69 void UpdateMDnsListeners(const EventListenerInfo& details);
66 70
67 // Ensure methods are only called on UI thread. 71 // Ensure methods are only called on UI thread.
68 base::ThreadChecker thread_checker_; 72 base::ThreadChecker thread_checker_;
69 Profile* const profile_; 73 content::BrowserContext* const browser_context_;
70 // Lazily created on first access and destroyed with this API class. 74 // Lazily created on first access and destroyed with this API class.
71 scoped_ptr<DnsSdRegistry> dns_sd_registry_; 75 scoped_ptr<DnsSdRegistry> dns_sd_registry_;
72 // Current set of service types registered with the registry. 76 // Current set of service types registered with the registry.
73 std::set<std::string> service_types_; 77 std::set<std::string> service_types_;
74 78
75 DISALLOW_COPY_AND_ASSIGN(MDnsAPI); 79 DISALLOW_COPY_AND_ASSIGN(MDnsAPI);
76 }; 80 };
77 81
78 } // namespace extensions 82 } // namespace extensions
79 83
80 #endif // CHROME_BROWSER_EXTENSIONS_API_MDNS_MDNS_API_H_ 84 #endif // CHROME_BROWSER_EXTENSIONS_API_MDNS_MDNS_API_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/management/management_api.cc ('k') | chrome/browser/extensions/api/mdns/mdns_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698