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

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: Cleanup. 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
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
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.
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.
51 void PreCreateThreads();
52
53 // 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.
54 void SaveState();
55
56 // 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.
57 void PostDestroyThreads();
58
59 private:
60 ApplicationContext();
61 ~ApplicationContext();
62 friend struct base::DefaultSingletonTraits<ApplicationContext>;
63
64 // Gets the ChromeNetLog.
65 net_log::ChromeNetLog* GetNetLog();
66
67 // Gets the WebViewIOThread.
68 WebViewIOThread* GetWebViewIOThread();
69
70 // Returns the path to the application level preferences.
71 static base::FilePath GetLocalStatePath();
72
73 // Sets the locale used by the application.
74 void SetApplicationLocale(const std::string& locale);
75
76 THREAD_CHECKER(thread_checker_);
77 std::unique_ptr<PrefService> local_state_;
78 std::unique_ptr<net_log::ChromeNetLog> net_log_;
79 std::unique_ptr<WebViewIOThread> web_view_io_thread_;
80 std::string application_locale_;
81
82 // Sequenced task runner for local state related I/O tasks.
83 const scoped_refptr<base::SequencedTaskRunner> local_state_task_runner_;
84
85 DISALLOW_COPY_AND_ASSIGN(ApplicationContext);
86 };
87
88 } // namespace ios_web_view
89
90 #endif // IOS_WEB_VIEW_INTERNAL_APP_APPLICATION_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698