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

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

Issue 2894483003: Initialize ios/web_view translate with a system-wide URLRequestContext. (Closed)
Patch Set: Respond to comments. 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_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 base {
17 class CommandLine;
18 class FilePath;
19 class SequencedTaskRunner;
20 }
21
22 namespace ios_web_view {
23
24 // Exposes application global state objects. This class is not a standard
25 // singleton (from //base/memory/singleton.h) because it's creation relies on
26 // on two parameters.
27 class ApplicationContextImpl : public ApplicationContext {
28 public:
29 ApplicationContextImpl(const base::CommandLine& command_line,
30 const std::string& locale);
31 ~ApplicationContextImpl() override;
32
33 // Creates state tied to application threads.
34 void PreCreateThreads();
35
36 // Saves applicaiton context state.
37 void SaveState();
38
39 // Destroys state tied to application threads.
40 void PostDestroyThreads();
41
42 // ApplicationContext implementation.
43 PrefService* GetLocalState() override;
44 net_log::ChromeNetLog* GetNetLog() override;
45 net::URLRequestContextGetter* GetSystemURLRequestContext() override;
46 const std::string& GetApplicationLocale() override;
47 WebViewIOThread* GetWebViewIOThread() override;
48
49 private:
50 // Returns the path to the application level preferences.
51 static base::FilePath GetLocalStatePath();
52
53 // Sets the locale used by the application.
54 void SetApplicationLocale(const std::string& locale);
55
56 // Creates the application level preferences.
57 void CreateLocalState();
58
59 THREAD_CHECKER(thread_checker_);
60 std::unique_ptr<PrefService> local_state_;
61 std::unique_ptr<net_log::ChromeNetLog> net_log_;
62 std::unique_ptr<WebViewIOThread> web_view_io_thread_;
63 std::string application_locale_;
64
65 // Sequenced task runner for local state related I/O tasks.
66 const scoped_refptr<base::SequencedTaskRunner> local_state_task_runner_;
67
68 bool created_local_state_;
69
70 DISALLOW_COPY_AND_ASSIGN(ApplicationContextImpl);
71 };
72
73 } // namespace ios_web_view
74
75 #endif // IOS_WEB_VIEW_INTERNAL_APP_APPLICATION_CONTEXT_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698