Chromium Code Reviews| Index: blimp/engine/common/blimp_browser_context.cc |
| diff --git a/blimp/engine/common/blimp_browser_context.cc b/blimp/engine/common/blimp_browser_context.cc |
| index 6a2a7ec04ad9ba83d257b766bf9ef850515804b0..0c591fc521dd6975612a21086992248c37a0aebd 100644 |
| --- a/blimp/engine/common/blimp_browser_context.cc |
| +++ b/blimp/engine/common/blimp_browser_context.cc |
| @@ -10,11 +10,22 @@ |
| #include "base/nix/xdg_util.h" |
| #include "base/path_service.h" |
| #include "blimp/engine/app/blimp_permission_manager.h" |
| +#include "components/metrics/metrics_service.h" |
| +#include "components/pref_registry/pref_registry_syncable.h" |
| +#include "components/prefs/in_memory_pref_store.h" |
| +#include "components/prefs/pref_service.h" |
| +#include "components/prefs/pref_service_factory.h" |
| #include "content/public/browser/background_sync_controller.h" |
| #include "content/public/browser/browser_thread.h" |
| #include "content/public/browser/storage_partition.h" |
| #include "content/public/common/content_switches.h" |
| +namespace { |
| +// Shows notifications which correspond to PersistentPrefStore's reading errors. |
| +void HandleReadError(PersistentPrefStore::PrefReadError error) { |
| +} |
| +} // namespace |
| + |
| namespace blimp { |
| namespace engine { |
| @@ -68,6 +79,17 @@ BlimpBrowserContext::~BlimpBrowserContext() { |
| } |
| } |
| +void BlimpBrowserContext::Initialize() { |
| + InitPrefService(); |
| + BlimpMetricsServiceClient::GetInstance()->Initialize( |
| + pref_service_.get(), |
| + GetSystemRequestContextGetter()); |
| +} |
| + |
| +void BlimpBrowserContext::Finalize() { |
| + BlimpMetricsServiceClient::GetInstance()->Finalize(); |
| +} |
| + |
| void BlimpBrowserContext::InitWhileIOAllowed() { |
| // Ensures ~/.config/blimp_engine directory exists. |
| std::unique_ptr<base::Environment> env(base::Environment::Create()); |
| @@ -79,6 +101,17 @@ void BlimpBrowserContext::InitWhileIOAllowed() { |
| BrowserContext::Initialize(this, path_); |
| } |
| +void BlimpBrowserContext::InitPrefService() { |
| + user_prefs::PrefRegistrySyncable* pref_registry = |
|
Alexei Svitkine (slow)
2016/04/25 20:44:25
Nit: unique_ptr
Jess
2016/04/26 00:01:25
Unique ptr is not usable in this case since user_p
|
| + new user_prefs::PrefRegistrySyncable(); |
| + metrics::MetricsService::RegisterPrefs(pref_registry); |
| + PrefServiceFactory pref_service_factory; |
| + // The pref storage for metrics logs. |
| + pref_service_factory.set_user_prefs(new InMemoryPrefStore()); |
| + pref_service_factory.set_read_error_callback(base::Bind(&HandleReadError)); |
| + pref_service_ = pref_service_factory.Create(pref_registry); |
| +} |
| + |
| std::unique_ptr<content::ZoomLevelDelegate> |
| BlimpBrowserContext::CreateZoomLevelDelegate(const base::FilePath&) { |
| return nullptr; |