OLD | NEW |
| (Empty) |
1 // Copyright 2014 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 CHROMECAST_SERVICE_CAST_SERVICE_H_ | |
6 #define CHROMECAST_SERVICE_CAST_SERVICE_H_ | |
7 | |
8 #include "base/callback.h" | |
9 #include "base/macros.h" | |
10 #include "base/memory/scoped_ptr.h" | |
11 | |
12 namespace base { | |
13 class ThreadChecker; | |
14 } | |
15 | |
16 namespace content { | |
17 class BrowserContext; | |
18 } | |
19 | |
20 namespace net { | |
21 class URLRequestContextGetter; | |
22 } | |
23 | |
24 namespace chromecast { | |
25 | |
26 class CastService { | |
27 public: | |
28 // A callback that will be invoked when the user changes the opt-in stats | |
29 // value. | |
30 typedef base::Callback<void(bool)> OptInStatsChangedCallback; | |
31 | |
32 // Create() takes a separate url request context getter because the request | |
33 // context getter obtained through the browser context might not be | |
34 // appropriate for the url requests made by the cast service/reciever. | |
35 // For example, on Chromecast, it is needed to pass in a system url request | |
36 // context getter that would set the request context for NSS, which the main | |
37 // getter doesn't do. | |
38 static CastService* Create( | |
39 content::BrowserContext* browser_context, | |
40 net::URLRequestContextGetter* request_context_getter, | |
41 const OptInStatsChangedCallback& opt_in_stats_callback); | |
42 | |
43 virtual ~CastService(); | |
44 | |
45 // Start/stop the cast service. | |
46 void Start(); | |
47 void Stop(); | |
48 | |
49 protected: | |
50 CastService(content::BrowserContext* browser_context, | |
51 const OptInStatsChangedCallback& opt_in_stats_callback); | |
52 virtual void Initialize() = 0; | |
53 | |
54 // Implementation-specific start/stop behavior. | |
55 virtual void StartInternal() = 0; | |
56 virtual void StopInternal() = 0; | |
57 | |
58 content::BrowserContext* browser_context() const { return browser_context_; } | |
59 const OptInStatsChangedCallback& opt_in_stats_callback() const { | |
60 return opt_in_stats_callback_; | |
61 } | |
62 | |
63 private: | |
64 content::BrowserContext* const browser_context_; | |
65 const OptInStatsChangedCallback opt_in_stats_callback_; | |
66 bool stopped_; | |
67 const scoped_ptr<base::ThreadChecker> thread_checker_; | |
68 | |
69 DISALLOW_COPY_AND_ASSIGN(CastService); | |
70 }; | |
71 | |
72 } // namespace chromecast | |
73 | |
74 #endif // CHROMECAST_SERVICE_CAST_SERVICE_H_ | |
OLD | NEW |