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.
5 #ifndef CHROMECAST_SERVICE_CAST_SERVICE_H_
6 #define CHROMECAST_SERVICE_CAST_SERVICE_H_
8 #include "base/callback.h"
9 #include "base/macros.h"
10 #include "base/memory/scoped_ptr.h"
21 class URLRequestContextGetter
;
24 namespace chromecast
{
28 // A callback that will be invoked when the user changes the opt-in stats
30 typedef base::Callback
<void(bool)> OptInStatsChangedCallback
;
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
38 static CastService
* Create(
39 content::BrowserContext
* browser_context
,
40 net::URLRequestContextGetter
* request_context_getter
,
41 const OptInStatsChangedCallback
& opt_in_stats_callback
);
43 virtual ~CastService();
45 // Start/stop the cast service.
50 CastService(content::BrowserContext
* browser_context
,
51 const OptInStatsChangedCallback
& opt_in_stats_callback
);
52 virtual void Initialize() = 0;
54 // Implementation-specific start/stop behavior.
55 virtual void StartInternal() = 0;
56 virtual void StopInternal() = 0;
58 content::BrowserContext
* browser_context() const { return browser_context_
; }
59 const OptInStatsChangedCallback
& opt_in_stats_callback() const {
60 return opt_in_stats_callback_
;
64 content::BrowserContext
* const browser_context_
;
65 const OptInStatsChangedCallback opt_in_stats_callback_
;
67 const scoped_ptr
<base::ThreadChecker
> thread_checker_
;
69 DISALLOW_COPY_AND_ASSIGN(CastService
);
72 } // namespace chromecast
74 #endif // CHROMECAST_SERVICE_CAST_SERVICE_H_