Skip to content

Commit

Permalink
[Chromecast] Remove protected fields from CastService.
Browse files Browse the repository at this point in the history
Classes that derive from this can choose to store these pointers
in private members, initialized at construction.

Merge-With: eureka-internal/480348

Bug: Internal b/138199589
Test: Build internal chromecast binaries and tests
Change-Id: I84723d6d298c9453d43c92ffd9f05b136d774b43
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2518715
Auto-Submit: Simeon Anfinrud <sanfin@chromium.org>
Commit-Queue: Luke Halliwell (slow) <halliwell@chromium.org>
Reviewed-by: Luke Halliwell (slow) <halliwell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#824179}
  • Loading branch information
Simeon Anfinrud authored and Commit Bot committed Nov 4, 2020
1 parent ba05b80 commit d781c58
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 27 deletions.
3 changes: 1 addition & 2 deletions chromecast/browser/cast_content_browser_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,7 @@ std::unique_ptr<CastService> CastContentBrowserClient::CreateCastService(
PrefService* pref_service,
media::VideoPlaneController* video_plane_controller,
CastWindowManager* window_manager) {
return std::make_unique<CastServiceSimple>(browser_context, pref_service,
window_manager);
return std::make_unique<CastServiceSimple>(browser_context, window_manager);
}

media::VideoModeSwitcher* CastContentBrowserClient::GetVideoModeSwitcher() {
Expand Down
4 changes: 1 addition & 3 deletions chromecast/browser/service/cast_service_simple.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,8 @@ GURL GetStartupURL() {
} // namespace

CastServiceSimple::CastServiceSimple(content::BrowserContext* browser_context,
PrefService* pref_service,
CastWindowManager* window_manager)
: CastService(browser_context, pref_service),
web_view_factory_(std::make_unique<CastWebViewFactory>(browser_context)),
: web_view_factory_(std::make_unique<CastWebViewFactory>(browser_context)),
web_service_(std::make_unique<CastWebService>(browser_context,
web_view_factory_.get(),
window_manager)) {
Expand Down
5 changes: 4 additions & 1 deletion chromecast/browser/service/cast_service_simple.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
#include "chromecast/service/cast_service.h"
#include "url/gurl.h"

namespace content {
class BrowserContext;
} // namespace content

namespace chromecast {

class CastWebService;
Expand All @@ -25,7 +29,6 @@ namespace shell {
class CastServiceSimple : public CastService, public CastWebView::Delegate {
public:
CastServiceSimple(content::BrowserContext* browser_context,
PrefService* pref_service,
CastWindowManager* window_manager);
~CastServiceSimple() override;

Expand Down
10 changes: 2 additions & 8 deletions chromecast/service/cast_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,8 @@

namespace chromecast {

CastService::CastService(
content::BrowserContext* browser_context,
PrefService* pref_service)
: browser_context_(browser_context),
pref_service_(pref_service),
stopped_(true),
thread_checker_(new base::ThreadChecker()) {
}
CastService::CastService()
: stopped_(true), thread_checker_(new base::ThreadChecker()) {}

CastService::~CastService() {
DCHECK(thread_checker_->CalledOnValidThread());
Expand Down
14 changes: 1 addition & 13 deletions chromecast/service/cast_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,10 @@
#include "base/callback.h"
#include "base/macros.h"

class PrefService;

namespace base {
class ThreadChecker;
}

namespace content {
class BrowserContext;
}

namespace chromecast {

class CastService {
Expand All @@ -38,8 +32,7 @@ class CastService {
virtual void AccessibilityStateChanged(bool enabled);

protected:
CastService(content::BrowserContext* browser_context,
PrefService* pref_service);
CastService();

// Implementation-specific initialization. Initialization of cast service's
// sub-components, and anything that requires IO operations should go here.
Expand All @@ -60,12 +53,7 @@ class CastService {
// StartInternal() should be finalized here.
virtual void StopInternal() = 0;

content::BrowserContext* browser_context() const { return browser_context_; }
PrefService* pref_service() const { return pref_service_; }

private:
content::BrowserContext* const browser_context_;
PrefService* const pref_service_;
bool stopped_;
const std::unique_ptr<base::ThreadChecker> thread_checker_;

Expand Down

0 comments on commit d781c58

Please sign in to comment.