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

Side by Side Diff: chromecast/service/cast_service.h

Issue 608093002: Chromecast: adds callback for CastService to control metrics state. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cast-network-delegate
Patch Set: rebase Created 6 years, 2 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
« no previous file with comments | « chromecast/metrics/cast_metrics_service_client.cc ('k') | chromecast/service/cast_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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 CHROMECAST_SERVICE_CAST_SERVICE_H_ 5 #ifndef CHROMECAST_SERVICE_CAST_SERVICE_H_
6 #define CHROMECAST_SERVICE_CAST_SERVICE_H_ 6 #define CHROMECAST_SERVICE_CAST_SERVICE_H_
7 7
8 #include "base/callback.h"
8 #include "base/macros.h" 9 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
10 11
11 namespace base { 12 namespace base {
12 class ThreadChecker; 13 class ThreadChecker;
13 } 14 }
14 15
15 namespace content { 16 namespace content {
16 class BrowserContext; 17 class BrowserContext;
17 } 18 }
18 19
19 namespace net { 20 namespace net {
20 class URLRequestContextGetter; 21 class URLRequestContextGetter;
21 } 22 }
22 23
23 namespace chromecast { 24 namespace chromecast {
24 namespace shell { 25 namespace shell {
25 class CastNetworkDelegate; 26 class CastNetworkDelegate;
26 } 27 }
27 28
28 class CastService { 29 class CastService {
29 public: 30 public:
31 // A callback that will be invoked when the user changes the opt-in stats
32 // value.
33 typedef base::Callback<void(bool)> OptInStatsChangedCallback;
34
30 // Create() takes a separate url request context getter because the request 35 // Create() takes a separate url request context getter because the request
31 // context getter obtained through the browser context might not be 36 // context getter obtained through the browser context might not be
32 // appropriate for the url requests made by the cast service/reciever. 37 // appropriate for the url requests made by the cast service/reciever.
33 // For example, on Chromecast, it is needed to pass in a system url request 38 // For example, on Chromecast, it is needed to pass in a system url request
34 // context getter that would set the request context for NSS, which the main 39 // context getter that would set the request context for NSS, which the main
35 // getter doesn't do. 40 // getter doesn't do.
36 static CastService* Create( 41 static CastService* Create(
37 content::BrowserContext* browser_context, 42 content::BrowserContext* browser_context,
38 net::URLRequestContextGetter* request_context_getter, 43 net::URLRequestContextGetter* request_context_getter,
39 shell::CastNetworkDelegate* network_delegate); 44 shell::CastNetworkDelegate* network_delegate,
45 const OptInStatsChangedCallback& opt_in_stats_callback);
40 46
41 virtual ~CastService(); 47 virtual ~CastService();
42 48
43 // Start/stop the cast service. 49 // Start/stop the cast service.
44 void Start(); 50 void Start();
45 void Stop(); 51 void Stop();
46 52
47 protected: 53 protected:
48 explicit CastService(content::BrowserContext* browser_context); 54 CastService(content::BrowserContext* browser_context,
55 const OptInStatsChangedCallback& opt_in_stats_callback);
49 virtual void Initialize() = 0; 56 virtual void Initialize() = 0;
50 57
51 // Implementation-specific start/stop behavior. 58 // Implementation-specific start/stop behavior.
52 virtual void StartInternal() = 0; 59 virtual void StartInternal() = 0;
53 virtual void StopInternal() = 0; 60 virtual void StopInternal() = 0;
54 61
55 content::BrowserContext* browser_context() const { return browser_context_; } 62 content::BrowserContext* browser_context() const { return browser_context_; }
63 const OptInStatsChangedCallback& opt_in_stats_callback() const {
64 return opt_in_stats_callback_;
65 }
56 66
57 private: 67 private:
58 content::BrowserContext* const browser_context_; 68 content::BrowserContext* const browser_context_;
69 const OptInStatsChangedCallback opt_in_stats_callback_;
59 bool stopped_; 70 bool stopped_;
60
61 const scoped_ptr<base::ThreadChecker> thread_checker_; 71 const scoped_ptr<base::ThreadChecker> thread_checker_;
62 72
63 DISALLOW_COPY_AND_ASSIGN(CastService); 73 DISALLOW_COPY_AND_ASSIGN(CastService);
64 }; 74 };
65 75
66 } // namespace chromecast 76 } // namespace chromecast
67 77
68 #endif // CHROMECAST_SERVICE_CAST_SERVICE_H_ 78 #endif // CHROMECAST_SERVICE_CAST_SERVICE_H_
OLDNEW
« no previous file with comments | « chromecast/metrics/cast_metrics_service_client.cc ('k') | chromecast/service/cast_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698