Commit 10dba963 authored by Gabriel Charette's avatar Gabriel Charette Committed by Commit Bot

Migrate iOS ApplicationContext to TaskScheduler.

(this doesn't use the TaskScheduler API directly because that's the
default behavior on JsonPrefStore now when not provided an explicit
SequencedTaskRunner at construction :))

R=rohitrao@chromium.org

Bug: 667892
Change-Id: Ifa0549e4ddf65ad8606451a47724234981c35467
Reviewed-on: https://chromium-review.googlesource.com/590573Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
Commit-Queue: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#490766}
parent 6c5fc503
...@@ -28,10 +28,7 @@ ApplicationContext* ApplicationContext::GetInstance() { ...@@ -28,10 +28,7 @@ ApplicationContext* ApplicationContext::GetInstance() {
return base::Singleton<ApplicationContext>::get(); return base::Singleton<ApplicationContext>::get();
} }
ApplicationContext::ApplicationContext() ApplicationContext::ApplicationContext() {
: local_state_task_runner_(JsonPrefStore::GetTaskRunnerForFile(
GetLocalStatePath(),
web::WebThread::GetBlockingPool())) {
net_log_ = base::MakeUnique<net_log::ChromeNetLog>(); net_log_ = base::MakeUnique<net_log::ChromeNetLog>();
SetApplicationLocale(l10n_util::GetLocaleOverride()); SetApplicationLocale(l10n_util::GetLocaleOverride());
...@@ -74,8 +71,15 @@ PrefService* ApplicationContext::GetLocalState() { ...@@ -74,8 +71,15 @@ PrefService* ApplicationContext::GetLocalState() {
PrefProxyConfigTrackerImpl::RegisterPrefs(pref_registry.get()); PrefProxyConfigTrackerImpl::RegisterPrefs(pref_registry.get());
ssl_config::SSLConfigServiceManager::RegisterPrefs(pref_registry.get()); ssl_config::SSLConfigServiceManager::RegisterPrefs(pref_registry.get());
scoped_refptr<PersistentPrefStore> user_pref_store = new JsonPrefStore( base::FilePath local_state_path;
GetLocalStatePath(), local_state_task_runner_, nullptr); PathService::Get(base::DIR_APP_DATA, &local_state_path);
local_state_path =
local_state_path.Append(FILE_PATH_LITERAL("ChromeWebView"));
local_state_path =
local_state_path.Append(FILE_PATH_LITERAL("Local State"));
scoped_refptr<PersistentPrefStore> user_pref_store =
new JsonPrefStore(std::move(local_state_path));
PrefServiceFactory factory; PrefServiceFactory factory;
factory.set_user_prefs(user_pref_store); factory.set_user_prefs(user_pref_store);
...@@ -114,15 +118,6 @@ WebViewIOThread* ApplicationContext::GetWebViewIOThread() { ...@@ -114,15 +118,6 @@ WebViewIOThread* ApplicationContext::GetWebViewIOThread() {
return web_view_io_thread_.get(); return web_view_io_thread_.get();
} }
base::FilePath ApplicationContext::GetLocalStatePath() {
base::FilePath local_state_path;
PathService::Get(base::DIR_APP_DATA, &local_state_path);
local_state_path =
local_state_path.Append(FILE_PATH_LITERAL("ChromeWebView"));
local_state_path = local_state_path.Append(FILE_PATH_LITERAL("Local State"));
return local_state_path;
}
void ApplicationContext::SetApplicationLocale(const std::string& locale) { void ApplicationContext::SetApplicationLocale(const std::string& locale) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
application_locale_ = locale; application_locale_ = locale;
......
...@@ -9,14 +9,11 @@ ...@@ -9,14 +9,11 @@
#include <string> #include <string>
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/sequence_checker.h" #include "base/sequence_checker.h"
namespace base { namespace base {
template <typename T> template <typename T>
struct DefaultSingletonTraits; struct DefaultSingletonTraits;
class FilePath;
class SequencedTaskRunner;
} }
namespace net { namespace net {
...@@ -71,9 +68,6 @@ class ApplicationContext { ...@@ -71,9 +68,6 @@ class ApplicationContext {
// Gets the WebViewIOThread. // Gets the WebViewIOThread.
WebViewIOThread* GetWebViewIOThread(); WebViewIOThread* GetWebViewIOThread();
// Returns the path to the application level preferences.
static base::FilePath GetLocalStatePath();
// Sets the locale used by the application. // Sets the locale used by the application.
void SetApplicationLocale(const std::string& locale); void SetApplicationLocale(const std::string& locale);
...@@ -83,9 +77,6 @@ class ApplicationContext { ...@@ -83,9 +77,6 @@ class ApplicationContext {
std::unique_ptr<WebViewIOThread> web_view_io_thread_; std::unique_ptr<WebViewIOThread> web_view_io_thread_;
std::string application_locale_; std::string application_locale_;
// Sequenced task runner for local state related I/O tasks.
const scoped_refptr<base::SequencedTaskRunner> local_state_task_runner_;
DISALLOW_COPY_AND_ASSIGN(ApplicationContext); DISALLOW_COPY_AND_ASSIGN(ApplicationContext);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment