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

Unified Diff: ios/web_view/internal/app/application_context_impl.h

Issue 2894483003: Initialize ios/web_view translate with a system-wide URLRequestContext. (Closed)
Patch Set: Remove unneeded deps. 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: ios/web_view/internal/app/application_context_impl.h
diff --git a/ios/web_view/internal/app/application_context_impl.h b/ios/web_view/internal/app/application_context_impl.h
new file mode 100644
index 0000000000000000000000000000000000000000..b4f7ec533a7fcfd61e5c86a173890e880c25254e
--- /dev/null
+++ b/ios/web_view/internal/app/application_context_impl.h
@@ -0,0 +1,69 @@
+// 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.
+
+#ifndef IOS_WEB_VIEW_INTERNAL_APP_APPLICATION_CONTEXT_IMPL_H_
+#define IOS_WEB_VIEW_INTERNAL_APP_APPLICATION_CONTEXT_IMPL_H_
+
+#include <memory>
+#include <string>
+
+#include "base/macros.h"
+#include "base/memory/ref_counted.h"
+#include "base/threading/thread_checker.h"
+#include "ios/web_view/internal/app/application_context.h"
+
+namespace ios_web_view {
+
+// Exposes application global state objects. This class is not a standard
+// singleton (from //base/memory/singleton.h) because it's creation relies on
+// on two parameters.
+class ApplicationContextImpl : public ApplicationContext {
Eugene But (OOO till 7-30) 2017/05/25 00:39:11 What is the reason in separating ApplicationContex
michaeldo 2017/05/25 21:49:54 No reason any longer. I removed the _impl class fr
+ public:
+ ApplicationContextImpl(const base::CommandLine& command_line,
+ const std::string& locale);
+ ~ApplicationContextImpl() override;
+
+ // Creates state tied to application threads.
+ void PreCreateThreads();
+
+ // Saves applicaiton context state.
+ void SaveState();
+
+ // Destroys state tied to application threads.
+ void PostDestroyThreads();
+
+ // ApplicationContext implementation.
+ PrefService* GetLocalState() override;
+ net_log::ChromeNetLog* GetNetLog() override;
+ net::URLRequestContextGetter* GetSystemURLRequestContext() override;
+ const std::string& GetApplicationLocale() override;
+ WebViewIOThread* GetWebViewIOThread() override;
+
+ private:
+ // Returns the path to the application level preferences.
+ static base::FilePath GetLocalStatePath();
+
+ // Sets the locale used by the application.
+ void SetApplicationLocale(const std::string& locale);
+
+ // Creates the application level preferences.
+ void CreateLocalState();
+
+ THREAD_CHECKER(thread_checker_);
+ std::unique_ptr<PrefService> local_state_;
+ std::unique_ptr<net_log::ChromeNetLog> net_log_;
+ std::unique_ptr<WebViewIOThread> web_view_io_thread_;
+ std::string application_locale_;
+
+ // Sequenced task runner for local state related I/O tasks.
+ const scoped_refptr<base::SequencedTaskRunner> local_state_task_runner_;
+
+ bool created_local_state_;
+
+ DISALLOW_COPY_AND_ASSIGN(ApplicationContextImpl);
+};
+
+} // namespace ios_web_view
+
+#endif // IOS_WEB_VIEW_INTERNAL_APP_APPLICATION_CONTEXT_IMPL_H_

Powered by Google App Engine
This is Rietveld 408576698