OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef IOS_WEB_VIEW_INTERNAL_APP_APPLICATION_CONTEXT_IMPL_H_ | |
6 #define IOS_WEB_VIEW_INTERNAL_APP_APPLICATION_CONTEXT_IMPL_H_ | |
7 | |
8 #include <memory> | |
9 #include <string> | |
10 | |
11 #include "base/macros.h" | |
12 #include "base/memory/ref_counted.h" | |
13 #include "base/threading/thread_checker.h" | |
14 #include "ios/web_view/internal/app/application_context.h" | |
15 | |
16 namespace ios_web_view { | |
17 | |
18 // Exposes application global state objects. This class is not a standard | |
19 // singleton (from //base/memory/singleton.h) because it's creation relies on | |
20 // on two parameters. | |
21 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
| |
22 public: | |
23 ApplicationContextImpl(const base::CommandLine& command_line, | |
24 const std::string& locale); | |
25 ~ApplicationContextImpl() override; | |
26 | |
27 // Creates state tied to application threads. | |
28 void PreCreateThreads(); | |
29 | |
30 // Saves applicaiton context state. | |
31 void SaveState(); | |
32 | |
33 // Destroys state tied to application threads. | |
34 void PostDestroyThreads(); | |
35 | |
36 // ApplicationContext implementation. | |
37 PrefService* GetLocalState() override; | |
38 net_log::ChromeNetLog* GetNetLog() override; | |
39 net::URLRequestContextGetter* GetSystemURLRequestContext() override; | |
40 const std::string& GetApplicationLocale() override; | |
41 WebViewIOThread* GetWebViewIOThread() override; | |
42 | |
43 private: | |
44 // Returns the path to the application level preferences. | |
45 static base::FilePath GetLocalStatePath(); | |
46 | |
47 // Sets the locale used by the application. | |
48 void SetApplicationLocale(const std::string& locale); | |
49 | |
50 // Creates the application level preferences. | |
51 void CreateLocalState(); | |
52 | |
53 THREAD_CHECKER(thread_checker_); | |
54 std::unique_ptr<PrefService> local_state_; | |
55 std::unique_ptr<net_log::ChromeNetLog> net_log_; | |
56 std::unique_ptr<WebViewIOThread> web_view_io_thread_; | |
57 std::string application_locale_; | |
58 | |
59 // Sequenced task runner for local state related I/O tasks. | |
60 const scoped_refptr<base::SequencedTaskRunner> local_state_task_runner_; | |
61 | |
62 bool created_local_state_; | |
63 | |
64 DISALLOW_COPY_AND_ASSIGN(ApplicationContextImpl); | |
65 }; | |
66 | |
67 } // namespace ios_web_view | |
68 | |
69 #endif // IOS_WEB_VIEW_INTERNAL_APP_APPLICATION_CONTEXT_IMPL_H_ | |
OLD | NEW |