| OLD | NEW | 
|---|
| 1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2017 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 #include "services/preferences/public/cpp/pref_service_factory.h" | 5 #include "services/preferences/public/cpp/pref_service_factory.h" | 
| 6 | 6 | 
| 7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" | 
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" | 
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" | 
| 10 #include "base/test/sequenced_worker_pool_owner.h" | 10 #include "base/test/sequenced_worker_pool_owner.h" | 
| (...skipping 27 matching lines...) Expand all  Loading... | 
| 38 | 38 | 
| 39  protected: | 39  protected: | 
| 40   bool OnConnect(const service_manager::ServiceInfo& remote_info, | 40   bool OnConnect(const service_manager::ServiceInfo& remote_info, | 
| 41                  service_manager::InterfaceRegistry* registry) override { | 41                  service_manager::InterfaceRegistry* registry) override { | 
| 42     registry->AddInterface<service_manager::mojom::ServiceFactory>(this); | 42     registry->AddInterface<service_manager::mojom::ServiceFactory>(this); | 
| 43     return true; | 43     return true; | 
| 44   } | 44   } | 
| 45 | 45 | 
| 46   void CreateService(service_manager::mojom::ServiceRequest request, | 46   void CreateService(service_manager::mojom::ServiceRequest request, | 
| 47                      const std::string& name) override { | 47                      const std::string& name) override { | 
| 48     if (name == prefs::mojom::kPrefStoreServiceName) { | 48     if (name == prefs::mojom::kServiceName) { | 
| 49       pref_service_context_.reset(new service_manager::ServiceContext( | 49       pref_service_context_.reset(new service_manager::ServiceContext( | 
| 50           CreatePrefService({PrefValueStore::COMMAND_LINE_STORE, | 50           CreatePrefService({PrefValueStore::COMMAND_LINE_STORE, | 
| 51                              PrefValueStore::RECOMMENDED_STORE}, | 51                              PrefValueStore::RECOMMENDED_STORE}, | 
| 52                             worker_pool_), | 52                             worker_pool_), | 
| 53           std::move(request))); | 53           std::move(request))); | 
| 54     } | 54     } | 
| 55   } | 55   } | 
| 56 | 56 | 
| 57   void Create(const service_manager::Identity& remote_identity, | 57   void Create(const service_manager::Identity& remote_identity, | 
| 58               service_manager::mojom::ServiceFactoryRequest request) override { | 58               service_manager::mojom::ServiceFactoryRequest request) override { | 
| (...skipping 17 matching lines...) Expand all  Loading... | 
| 76  public: | 76  public: | 
| 77   PrefServiceFactoryTest() : ServiceTest("prefs_unittests", false) {} | 77   PrefServiceFactoryTest() : ServiceTest("prefs_unittests", false) {} | 
| 78 | 78 | 
| 79  protected: | 79  protected: | 
| 80   void SetUp() override { | 80   void SetUp() override { | 
| 81     ServiceTest::SetUp(); | 81     ServiceTest::SetUp(); | 
| 82     ASSERT_TRUE(profile_dir_.CreateUniqueTempDir()); | 82     ASSERT_TRUE(profile_dir_.CreateUniqueTempDir()); | 
| 83 | 83 | 
| 84     // Init the pref service (in production Chrome startup would do this.) | 84     // Init the pref service (in production Chrome startup would do this.) | 
| 85     mojom::PrefServiceControlPtr control; | 85     mojom::PrefServiceControlPtr control; | 
| 86     connector()->BindInterface(mojom::kPrefStoreServiceName, &control); | 86     connector()->BindInterface(mojom::kServiceName, &control); | 
| 87     auto config = mojom::PersistentPrefStoreConfiguration::New(); | 87     auto config = mojom::PersistentPrefStoreConfiguration::New(); | 
| 88     config->set_simple_configuration( | 88     config->set_simple_configuration( | 
| 89         mojom::SimplePersistentPrefStoreConfiguration::New( | 89         mojom::SimplePersistentPrefStoreConfiguration::New( | 
| 90             profile_dir_.GetPath().AppendASCII("Preferences"))); | 90             profile_dir_.GetPath().AppendASCII("Preferences"))); | 
| 91     control->Init(std::move(config)); | 91     control->Init(std::move(config)); | 
| 92     above_user_prefs_pref_store_ = new ValueMapPrefStore(); | 92     above_user_prefs_pref_store_ = new ValueMapPrefStore(); | 
| 93     below_user_prefs_pref_store_ = new ValueMapPrefStore(); | 93     below_user_prefs_pref_store_ = new ValueMapPrefStore(); | 
| 94     mojom::PrefStoreRegistryPtr registry; | 94     mojom::PrefStoreRegistryPtr registry; | 
| 95     connector()->BindInterface(mojom::kPrefStoreServiceName, ®istry); | 95     connector()->BindInterface(mojom::kServiceName, ®istry); | 
| 96     above_user_prefs_impl_ = | 96     above_user_prefs_impl_ = | 
| 97         PrefStoreImpl::Create(registry.get(), above_user_prefs_pref_store_, | 97         PrefStoreImpl::Create(registry.get(), above_user_prefs_pref_store_, | 
| 98                               PrefValueStore::COMMAND_LINE_STORE); | 98                               PrefValueStore::COMMAND_LINE_STORE); | 
| 99     below_user_prefs_impl_ = | 99     below_user_prefs_impl_ = | 
| 100         PrefStoreImpl::Create(registry.get(), below_user_prefs_pref_store_, | 100         PrefStoreImpl::Create(registry.get(), below_user_prefs_pref_store_, | 
| 101                               PrefValueStore::RECOMMENDED_STORE); | 101                               PrefValueStore::RECOMMENDED_STORE); | 
| 102   } | 102   } | 
| 103 | 103 | 
| 104   // service_manager::test::ServiceTest: | 104   // service_manager::test::ServiceTest: | 
| 105   std::unique_ptr<service_manager::Service> CreateService() override { | 105   std::unique_ptr<service_manager::Service> CreateService() override { | 
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 253                                           base::MakeUnique<base::Value>(2), 0); | 253                                           base::MakeUnique<base::Value>(2), 0); | 
| 254   WaitForPrefChange(pref_service.get(), kKey); | 254   WaitForPrefChange(pref_service.get(), kKey); | 
| 255   EXPECT_EQ(2, pref_service->GetInteger(kKey)); | 255   EXPECT_EQ(2, pref_service->GetInteger(kKey)); | 
| 256 | 256 | 
| 257   pref_service->SetInteger(kKey, 3); | 257   pref_service->SetInteger(kKey, 3); | 
| 258   EXPECT_EQ(2, pref_service->GetInteger(kKey)); | 258   EXPECT_EQ(2, pref_service->GetInteger(kKey)); | 
| 259 } | 259 } | 
| 260 | 260 | 
| 261 }  // namespace | 261 }  // namespace | 
| 262 }  // namespace prefs | 262 }  // namespace prefs | 
| OLD | NEW | 
|---|