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_BROWSER_SERVICE_CAST_SERVICE_H_
6 #define CHROMECAST_BROWSER_SERVICE_CAST_SERVICE_H_
8 #include "base/callback.h"
9 #include "base/macros.h"
10 #include "base/memory/scoped_ptr.h"
23 class URLRequestContextGetter
;
26 namespace chromecast
{
29 class CastMetricsServiceClient
;
34 // Create() takes a separate url request context getter because the request
35 // context getter obtained through the browser context might not be
36 // appropriate for the url requests made by the cast service/reciever.
37 // For example, on Chromecast, it is needed to pass in a system url request
38 // context getter that would set the request context for NSS, which the main
40 static scoped_ptr
<CastService
> Create(
41 content::BrowserContext
* browser_context
,
42 PrefService
* pref_service
,
43 metrics::CastMetricsServiceClient
* metrics_service_client
,
44 net::URLRequestContextGetter
* request_context_getter
);
46 virtual ~CastService();
48 // Initializes/finalizes the cast service.
52 // Starts/stops the cast service.
57 CastService(content::BrowserContext
* browser_context
,
58 PrefService
* pref_service
,
59 metrics::CastMetricsServiceClient
* metrics_service_client
);
61 // Implementation-specific initialization. Initialization of cast service's
62 // sub-components, and anything that requires IO operations should go here.
63 // Anything that should happen before cast service is started but doesn't need
64 // the sub-components to finish initializing should also go here.
65 virtual void InitializeInternal() = 0;
67 // Implementation-specific finalization. Any initializations done by
68 // InitializeInternal() should be finalized here.
69 virtual void FinalizeInternal() = 0;
71 // Implementation-specific start behavior. It basically starts the
72 // sub-component services and does additional initialization that cannot be
73 // done in the InitializationInternal().
74 virtual void StartInternal() = 0;
76 // Implementation-specific stop behavior. Any initializations done by
77 // StartInternal() should be finalized here.
78 virtual void StopInternal() = 0;
80 content::BrowserContext
* browser_context() const { return browser_context_
; }
81 PrefService
* pref_service() const { return pref_service_
; }
82 metrics::CastMetricsServiceClient
* metrics_service_client() const {
83 return metrics_service_client_
;
87 content::BrowserContext
* const browser_context_
;
88 PrefService
* const pref_service_
;
89 metrics::CastMetricsServiceClient
* const metrics_service_client_
;
91 const scoped_ptr
<base::ThreadChecker
> thread_checker_
;
93 DISALLOW_COPY_AND_ASSIGN(CastService
);
96 } // namespace chromecast
98 #endif // CHROMECAST_BROWSER_SERVICE_CAST_SERVICE_H_