Roll src/third_party/skia e6efd39:47bb382
[chromium-blink-merge.git] / chromecast / service / cast_service.h
blob14532c91321a99393ab4e9d6f3426e30947fd8c4
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"
12 namespace base {
13 class ThreadChecker;
16 namespace content {
17 class BrowserContext;
20 namespace net {
21 class URLRequestContextGetter;
24 namespace chromecast {
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;
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);
43 virtual ~CastService();
45 // Start/stop the cast service.
46 void Start();
47 void Stop();
49 protected:
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_;
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_;
69 DISALLOW_COPY_AND_ASSIGN(CastService);
72 } // namespace chromecast
74 #endif // CHROMECAST_SERVICE_CAST_SERVICE_H_