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

Unified Diff: extensions/browser/api/cast_channel/cast_channel_service_factory.cc

Issue 2891023002: [cast_channel] Make CastSocket not inherit from ApiResource (Closed)
Patch Set: Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: extensions/browser/api/cast_channel/cast_channel_service_factory.cc
diff --git a/extensions/browser/api/cast_channel/cast_channel_service_factory.cc b/extensions/browser/api/cast_channel/cast_channel_service_factory.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b914bbc0dff0c0cbdf308bb15bc23464340b5187
--- /dev/null
+++ b/extensions/browser/api/cast_channel/cast_channel_service_factory.cc
@@ -0,0 +1,56 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "extensions/browser/api/cast_channel/cast_channel_service_factory.h"
+
+#include "components/keyed_service/content/browser_context_dependency_manager.h"
+#include "extensions/browser/api/cast_channel/cast_channel_service.h"
+
+namespace extensions {
+namespace api {
+namespace cast_channel {
+
+using content::BrowserContext;
+
+namespace {
+
+base::LazyInstance<CastChannelServiceFactory>::DestructorAtExit
+ service_factory = LAZY_INSTANCE_INITIALIZER;
+} // namespace
+
+// static
+CastChannelService* CastChannelServiceFactory::GetForBrowserContext(
+ BrowserContext* context) {
+ DCHECK(context);
+ // GetServiceForBrowserContext returns a KeyedService hence the static_cast<>
+ // to return a pointer to CastChannelService.
+ return static_cast<CastChannelService*>(
+ service_factory.Get().GetServiceForBrowserContext(context, true));
+}
+
+// static
+CastChannelServiceFactory* CastChannelServiceFactory::GetInstance() {
+ return &service_factory.Get();
+}
+
+CastChannelServiceFactory::CastChannelServiceFactory()
+ : BrowserContextKeyedServiceFactory(
+ "CastChannelService",
+ BrowserContextDependencyManager::GetInstance()) {}
+
+CastChannelServiceFactory::~CastChannelServiceFactory() {}
+
+content::BrowserContext* CastChannelServiceFactory::GetBrowserContextToUse(
+ content::BrowserContext* context) const {
+ return context;
mark a. foltz 2017/05/18 19:12:05 This will return separate services for a normal pr
zhaobin 2017/05/24 01:51:40 Verified that CastChannelAPI has the same browser
mark a. foltz 2017/05/24 17:44:10 Cool :)
+}
+
+KeyedService* CastChannelServiceFactory::BuildServiceInstanceFor(
+ BrowserContext* context) const {
+ return new CastChannelService();
+}
+
+} // namespace cast_channel
+} // namespace api
+} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698