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

Side by Side Diff: ios/web_view/internal/app/application_context.h

Issue 2894483003: Initialize ios/web_view translate with a system-wide URLRequestContext. (Closed)
Patch Set: Respond to comments. Created 3 years, 6 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 unified diff | Download patch
« no previous file with comments | « ios/web_view/internal/DEPS ('k') | ios/web_view/internal/app/application_context.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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_H_
6 #define IOS_WEB_VIEW_INTERNAL_APP_APPLICATION_CONTEXT_H_
7
8 #include <memory>
9 #include <string>
10
11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/sequence_checker.h"
14
15 namespace base {
16 template <typename T>
17 struct DefaultSingletonTraits;
18 class FilePath;
19 class SequencedTaskRunner;
20 }
21
22 namespace net {
23 class URLRequestContextGetter;
24 }
25
26 namespace net_log {
27 class ChromeNetLog;
28 }
29
30 class PrefService;
31
32 namespace ios_web_view {
33
34 class WebViewIOThread;
35
36 // Exposes application global state objects.
37 class ApplicationContext {
38 public:
39 static ApplicationContext* GetInstance();
40
41 // Gets the preferences associated with this application.
42 PrefService* GetLocalState();
43
44 // Gets the URL request context associated with this application.
45 net::URLRequestContextGetter* GetSystemURLRequestContext();
46
47 // Gets the locale used by the application.
48 const std::string& GetApplicationLocale();
49
50 // Creates state tied to application threads. It is expected this will be
51 // called from web::WebMainParts::PreCreateThreads.
52 void PreCreateThreads();
53
54 // Saves application context state if |local_state_| exists. This should be
55 // called during shutdown to save application state.
56 void SaveState();
57
58 // Destroys state tied to application threads. It is expected this will be
59 // called from web::WebMainParts::PostDestroyThreads.
60 void PostDestroyThreads();
61
62 private:
63 friend struct base::DefaultSingletonTraits<ApplicationContext>;
64
65 ApplicationContext();
66 ~ApplicationContext();
67
68 // Gets the ChromeNetLog.
69 net_log::ChromeNetLog* GetNetLog();
70
71 // Gets the WebViewIOThread.
72 WebViewIOThread* GetWebViewIOThread();
73
74 // Returns the path to the application level preferences.
75 static base::FilePath GetLocalStatePath();
76
77 // Sets the locale used by the application.
78 void SetApplicationLocale(const std::string& locale);
79
80 SEQUENCE_CHECKER(sequence_checker_);
81 std::unique_ptr<PrefService> local_state_;
82 std::unique_ptr<net_log::ChromeNetLog> net_log_;
83 std::unique_ptr<WebViewIOThread> web_view_io_thread_;
84 std::string application_locale_;
85
86 // Sequenced task runner for local state related I/O tasks.
87 const scoped_refptr<base::SequencedTaskRunner> local_state_task_runner_;
88
89 DISALLOW_COPY_AND_ASSIGN(ApplicationContext);
90 };
91
92 } // namespace ios_web_view
93
94 #endif // IOS_WEB_VIEW_INTERNAL_APP_APPLICATION_CONTEXT_H_
OLDNEW
« no previous file with comments | « ios/web_view/internal/DEPS ('k') | ios/web_view/internal/app/application_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698