summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorjoaodasilva@chromium.org <joaodasilva@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-20 17:14:15 +0000
committerjoaodasilva@chromium.org <joaodasilva@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-20 17:14:15 +0000
commit80bfae1142d44fa37e51d9bec0610c3010796642 (patch)
tree2e7c1e6dfc789051c996fd9e2f3a879ac1d47452 /chrome/browser
parent68a31b1b3ed40a9146d45cd0e262a0d939275c48 (diff)
downloadchromium_src-80bfae1142d44fa37e51d9bec0610c3010796642.zip
chromium_src-80bfae1142d44fa37e51d9bec0610c3010796642.tar.gz
chromium_src-80bfae1142d44fa37e51d9bec0610c3010796642.tar.bz2
Decoupled the SchemaRegistryService from SchemaRegistry.
The service is not a SchemaRegistry anymore but owns one instead. This enables the service to own subclasses of SchemaRegistry. Also added a ForwardingSchemaRegisy, which wraps another SchemaRegistry. This will be used in a future CL. R=bartfab@chromium.org TBR=kalman@chromium.org BUG=224596 Review URL: https://codereview.chromium.org/349643002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@278735 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chromeos.cc3
-rw-r--r--chrome/browser/extensions/api/storage/managed_value_store_cache.cc6
-rw-r--r--chrome/browser/extensions/api/storage/settings_apitest.cc2
-rw-r--r--chrome/browser/policy/cloud/user_cloud_policy_manager_factory.cc3
-rw-r--r--chrome/browser/policy/profile_policy_connector_factory.cc3
-rw-r--r--chrome/browser/policy/schema_registry_service.cc25
-rw-r--r--chrome/browser/policy/schema_registry_service.h22
-rw-r--r--chrome/browser/policy/schema_registry_service_factory.cc9
-rw-r--r--chrome/browser/ui/webui/policy_ui.cc2
9 files changed, 37 insertions, 38 deletions
diff --git a/chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chromeos.cc b/chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chromeos.cc
index ba317a7..6b0e11c 100644
--- a/chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chromeos.cc
+++ b/chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chromeos.cc
@@ -209,7 +209,8 @@ scoped_ptr<UserCloudPolicyManagerChromeOS>
manager->EnableWildcardLoginCheck(username);
}
- manager->Init(SchemaRegistryServiceFactory::GetForContext(profile));
+ manager->Init(
+ SchemaRegistryServiceFactory::GetForContext(profile)->registry());
manager->Connect(g_browser_process->local_state(),
device_management_service,
g_browser_process->system_request_context(),
diff --git a/chrome/browser/extensions/api/storage/managed_value_store_cache.cc b/chrome/browser/extensions/api/storage/managed_value_store_cache.cc
index 92451c4..75387a9 100644
--- a/chrome/browser/extensions/api/storage/managed_value_store_cache.cc
+++ b/chrome/browser/extensions/api/storage/managed_value_store_cache.cc
@@ -107,8 +107,8 @@ class ManagedValueStoreCache::ExtensionTracker
ManagedValueStoreCache::ExtensionTracker::ExtensionTracker(Profile* profile)
: profile_(profile),
extension_registry_observer_(this),
- schema_registry_(
- policy::SchemaRegistryServiceFactory::GetForContext(profile)),
+ schema_registry_(policy::SchemaRegistryServiceFactory::GetForContext(
+ profile)->registry()),
weak_factory_(this) {
extension_registry_observer_.Add(ExtensionRegistry::Get(profile_));
// Load schemas when the extension system is ready. It might be ready now.
@@ -291,7 +291,7 @@ void ManagedValueStoreCache::OnPolicyServiceInitialized(
// The PolicyService now has all the initial policies ready. Send policy
// for all the managed extensions to their backing stores now.
policy::SchemaRegistry* registry =
- policy::SchemaRegistryServiceFactory::GetForContext(profile_);
+ policy::SchemaRegistryServiceFactory::GetForContext(profile_)->registry();
const policy::ComponentMap* map = registry->schema_map()->GetComponents(
policy::POLICY_DOMAIN_EXTENSIONS);
if (!map)
diff --git a/chrome/browser/extensions/api/storage/settings_apitest.cc b/chrome/browser/extensions/api/storage/settings_apitest.cc
index 7efa0c1..98a36fc 100644
--- a/chrome/browser/extensions/api/storage/settings_apitest.cc
+++ b/chrome/browser/extensions/api/storage/settings_apitest.cc
@@ -432,7 +432,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionSettingsApiTest, ExtensionsSchemas) {
message_.clear();
policy::SchemaRegistry* registry =
- policy::SchemaRegistryServiceFactory::GetForContext(profile);
+ policy::SchemaRegistryServiceFactory::GetForContext(profile)->registry();
ASSERT_TRUE(registry);
EXPECT_FALSE(registry->schema_map()->GetSchema(policy::PolicyNamespace(
policy::POLICY_DOMAIN_EXTENSIONS, kManagedStorageExtensionId)));
diff --git a/chrome/browser/policy/cloud/user_cloud_policy_manager_factory.cc b/chrome/browser/policy/cloud/user_cloud_policy_manager_factory.cc
index 3f43c4b..f1e5c35 100644
--- a/chrome/browser/policy/cloud/user_cloud_policy_manager_factory.cc
+++ b/chrome/browser/policy/cloud/user_cloud_policy_manager_factory.cc
@@ -160,7 +160,8 @@ UserCloudPolicyManagerFactory::CreateManagerForOriginalBrowserContext(
base::MessageLoopProxy::current(),
file_task_runner,
io_task_runner));
- manager->Init(SchemaRegistryServiceFactory::GetForContext(context));
+ manager->Init(
+ SchemaRegistryServiceFactory::GetForContext(context)->registry());
manager_wrappers_[context] = new ManagerWrapper(manager.get());
return manager.Pass();
}
diff --git a/chrome/browser/policy/profile_policy_connector_factory.cc b/chrome/browser/policy/profile_policy_connector_factory.cc
index 8089a3d..5f21949 100644
--- a/chrome/browser/policy/profile_policy_connector_factory.cc
+++ b/chrome/browser/policy/profile_policy_connector_factory.cc
@@ -91,7 +91,8 @@ ProfilePolicyConnectorFactory::CreateForProfileInternal(
CloudPolicyManager* user_cloud_policy_manager = NULL;
#if defined(ENABLE_CONFIGURATION_POLICY)
- schema_registry = SchemaRegistryServiceFactory::GetForContext(profile);
+ schema_registry =
+ SchemaRegistryServiceFactory::GetForContext(profile)->registry();
#if defined(OS_CHROMEOS)
chromeos::User* user = NULL;
diff --git a/chrome/browser/policy/schema_registry_service.cc b/chrome/browser/policy/schema_registry_service.cc
index b8124cd..9cf2b49 100644
--- a/chrome/browser/policy/schema_registry_service.cc
+++ b/chrome/browser/policy/schema_registry_service.cc
@@ -4,31 +4,26 @@
#include "chrome/browser/policy/schema_registry_service.h"
-#include "base/logging.h"
#include "components/policy/core/common/policy_namespace.h"
#include "components/policy/core/common/schema.h"
+#include "components/policy/core/common/schema_registry.h"
namespace policy {
SchemaRegistryService::SchemaRegistryService(
+ scoped_ptr<SchemaRegistry> registry,
const Schema& chrome_schema,
CombinedSchemaRegistry* global_registry)
- : global_registry_(global_registry) {
- if (chrome_schema.valid())
- RegisterComponent(PolicyNamespace(POLICY_DOMAIN_CHROME, ""), chrome_schema);
- SetReady(POLICY_DOMAIN_CHROME);
- if (global_registry_)
- global_registry->Track(this);
+ : registry_(registry.Pass()) {
+ if (chrome_schema.valid()) {
+ registry_->RegisterComponent(PolicyNamespace(POLICY_DOMAIN_CHROME, ""),
+ chrome_schema);
+ }
+ registry_->SetReady(POLICY_DOMAIN_CHROME);
+ if (global_registry)
+ global_registry->Track(registry_.get());
}
SchemaRegistryService::~SchemaRegistryService() {}
-void SchemaRegistryService::Shutdown() {
- if (global_registry_) {
- global_registry_->Untrack(this);
- global_registry_ = NULL;
- }
- DCHECK(!HasObservers());
-}
-
} // namespace policy
diff --git a/chrome/browser/policy/schema_registry_service.h b/chrome/browser/policy/schema_registry_service.h
index ecf97d7..24beefc 100644
--- a/chrome/browser/policy/schema_registry_service.h
+++ b/chrome/browser/policy/schema_registry_service.h
@@ -6,30 +6,30 @@
#define CHROME_BROWSER_POLICY_SCHEMA_REGISTRY_SERVICE_H_
#include "base/basictypes.h"
-#include "base/compiler_specific.h"
+#include "base/memory/scoped_ptr.h"
#include "components/keyed_service/core/keyed_service.h"
-#include "components/policy/core/common/schema_registry.h"
namespace policy {
+class CombinedSchemaRegistry;
class Schema;
+class SchemaRegistry;
-// A SchemaRegistry that is also a KeyedService, and is associated
-// with a Profile.
-class SchemaRegistryService : public SchemaRegistry, public KeyedService {
+// A KeyedService associated with a Profile that contains a SchemaRegistry.
+class SchemaRegistryService : public KeyedService {
public:
- // This SchemaRegistry will initially contain only the |chrome_schema|, if
+ // This |registry| will initially contain only the |chrome_schema|, if
// it's valid. The optional |global_registry| must outlive this, and will
- // track this registry.
- SchemaRegistryService(const Schema& chrome_schema,
+ // track |registry|.
+ SchemaRegistryService(scoped_ptr<SchemaRegistry> registry,
+ const Schema& chrome_schema,
CombinedSchemaRegistry* global_registry);
virtual ~SchemaRegistryService();
- // KeyedService:
- virtual void Shutdown() OVERRIDE;
+ SchemaRegistry* registry() const { return registry_.get(); }
private:
- CombinedSchemaRegistry* global_registry_;
+ scoped_ptr<SchemaRegistry> registry_;
DISALLOW_COPY_AND_ASSIGN(SchemaRegistryService);
};
diff --git a/chrome/browser/policy/schema_registry_service_factory.cc b/chrome/browser/policy/schema_registry_service_factory.cc
index 71758ff..eaa5268 100644
--- a/chrome/browser/policy/schema_registry_service_factory.cc
+++ b/chrome/browser/policy/schema_registry_service_factory.cc
@@ -60,10 +60,11 @@ SchemaRegistryServiceFactory::CreateForContextInternal(
CombinedSchemaRegistry* global_registry) {
DCHECK(!context->IsOffTheRecord());
DCHECK(registries_.find(context) == registries_.end());
- SchemaRegistryService* registry =
- new SchemaRegistryService(chrome_schema, global_registry);
- registries_[context] = registry;
- return make_scoped_ptr(registry);
+ scoped_ptr<SchemaRegistry> registry(new SchemaRegistry);
+ scoped_ptr<SchemaRegistryService> service(new SchemaRegistryService(
+ registry.Pass(), chrome_schema, global_registry));
+ registries_[context] = service.get();
+ return service.Pass();
}
void SchemaRegistryServiceFactory::BrowserContextShutdown(
diff --git a/chrome/browser/ui/webui/policy_ui.cc b/chrome/browser/ui/webui/policy_ui.cc
index 15c0b98..b1f3c39 100644
--- a/chrome/browser/ui/webui/policy_ui.cc
+++ b/chrome/browser/ui/webui/policy_ui.cc
@@ -613,7 +613,7 @@ void PolicyUIHandler::SendPolicyNames() const {
Profile* profile = Profile::FromWebUI(web_ui());
policy::SchemaRegistry* registry =
policy::SchemaRegistryServiceFactory::GetForContext(
- profile->GetOriginalProfile());
+ profile->GetOriginalProfile())->registry();
scoped_refptr<policy::SchemaMap> schema_map = registry->schema_map();
// Add Chrome policy names.