Chromium Code Reviews| Index: ios/web_view/internal/app/application_context.h |
| diff --git a/ios/web_view/internal/app/application_context.h b/ios/web_view/internal/app/application_context.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..9fdf85ceca22da2c4d60baeb3b7139bf506cb2d9 |
| --- /dev/null |
| +++ b/ios/web_view/internal/app/application_context.h |
| @@ -0,0 +1,90 @@ |
| +// 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_H_ |
| +#define IOS_WEB_VIEW_INTERNAL_APP_APPLICATION_CONTEXT_H_ |
| + |
| +#include <memory> |
| +#include <string> |
| + |
| +#include "base/macros.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "base/threading/thread_checker.h" |
| + |
| +namespace base { |
| +template <typename T> |
| +struct DefaultSingletonTraits; |
| +class FilePath; |
| +class SequencedTaskRunner; |
| +} |
| + |
| +namespace net { |
| +class URLRequestContextGetter; |
| +} |
| + |
| +namespace net_log { |
| +class ChromeNetLog; |
| +} |
| + |
| +class PrefService; |
| + |
| +namespace ios_web_view { |
| + |
| +class WebViewIOThread; |
| + |
| +// Exposes application global state objects. |
| +class ApplicationContext { |
| + public: |
| + static ApplicationContext* GetInstance(); |
| + |
| + // Gets the preferences associated with this application. |
| + PrefService* GetLocalState(); |
| + |
| + // Gets the URL request context associated with this application. |
| + net::URLRequestContextGetter* GetSystemURLRequestContext(); |
| + |
| + // Gets the locale used by the application. |
| + const std::string& GetApplicationLocale(); |
| + |
| + // Creates state tied to application threads. |
|
Eugene But (OOO till 7-30)
2017/05/31 16:25:34
When and why this should be called? Please specify
michaeldo
2017/05/31 21:03:43
Done.
|
| + void PreCreateThreads(); |
| + |
| + // Saves applicaiton context state. |
|
Eugene But (OOO till 7-30)
2017/05/31 16:25:34
ditto
michaeldo
2017/05/31 21:03:42
Done.
|
| + void SaveState(); |
| + |
| + // Destroys state tied to application threads. |
|
Eugene But (OOO till 7-30)
2017/05/31 16:25:34
ditto
michaeldo
2017/05/31 21:03:43
Done.
|
| + void PostDestroyThreads(); |
| + |
| + private: |
| + ApplicationContext(); |
| + ~ApplicationContext(); |
| + friend struct base::DefaultSingletonTraits<ApplicationContext>; |
| + |
| + // Gets the ChromeNetLog. |
| + net_log::ChromeNetLog* GetNetLog(); |
| + |
| + // Gets the WebViewIOThread. |
| + WebViewIOThread* GetWebViewIOThread(); |
| + |
| + // 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); |
| + |
| + 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_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ApplicationContext); |
| +}; |
| + |
| +} // namespace ios_web_view |
| + |
| +#endif // IOS_WEB_VIEW_INTERNAL_APP_APPLICATION_CONTEXT_H_ |