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

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: 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 unified diff | Download patch
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/threading/thread_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 class WebViewIOThread;
32
33 namespace ios_web_view {
34
35 // Exposes application global state objects.
36 class ApplicationContext {
37 public:
38 static ApplicationContext* GetInstance();
39
40 // Gets the preferences associated with this application.
41 PrefService* GetLocalState();
42
43 // Gets the URL request context associated with this application.
44 net::URLRequestContextGetter* GetSystemURLRequestContext();
45
46 // Gets the locale used by the application.
47 const std::string& GetApplicationLocale();
48
49 // Creates state tied to application threads.
50 void PreCreateThreads();
51
52 // Saves applicaiton context state.
53 void SaveState();
54
55 // Destroys state tied to application threads.
56 void PostDestroyThreads();
57
58 private:
59 ApplicationContext();
60 ~ApplicationContext();
61 friend struct base::DefaultSingletonTraits<ApplicationContext>;
62
63 // Gets the ChromeNetLog.
64 net_log::ChromeNetLog* GetNetLog();
65
66 // Gets the WebViewIOThread.
67 WebViewIOThread* GetWebViewIOThread();
68
69 // Returns the path to the application level preferences.
70 static base::FilePath GetLocalStatePath();
71
72 // Sets the locale used by the application.
73 void SetApplicationLocale(const std::string& locale);
74
75 THREAD_CHECKER(thread_checker_);
76 std::unique_ptr<PrefService> local_state_;
77 std::unique_ptr<net_log::ChromeNetLog> net_log_;
78 std::unique_ptr<WebViewIOThread> web_view_io_thread_;
79 std::string application_locale_;
80
81 // Sequenced task runner for local state related I/O tasks.
82 const scoped_refptr<base::SequencedTaskRunner> local_state_task_runner_;
83
84 DISALLOW_COPY_AND_ASSIGN(ApplicationContext);
85 };
86
87 } // namespace ios_web_view
88
89 #endif // IOS_WEB_VIEW_INTERNAL_APP_APPLICATION_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698