OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_HTML_VIEWER_GLOBAL_STATE_H_ | 5 #ifndef COMPONENTS_HTML_VIEWER_GLOBAL_STATE_H_ |
6 #define COMPONENTS_HTML_VIEWER_GLOBAL_STATE_H_ | 6 #define COMPONENTS_HTML_VIEWER_GLOBAL_STATE_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
12 #include "components/html_viewer/blink_settings.h" | 12 #include "components/html_viewer/blink_settings.h" |
13 #include "components/html_viewer/discardable_memory_allocator.h" | 13 #include "components/html_viewer/discardable_memory_allocator.h" |
14 #include "components/mus/gles2/mojo_gpu_memory_buffer_manager.h" | 14 #include "components/mus/gles2/mojo_gpu_memory_buffer_manager.h" |
15 #include "components/mus/gles2/raster_thread_helper.h" | 15 #include "components/mus/gles2/raster_thread_helper.h" |
16 #include "components/mus/public/interfaces/gpu.mojom.h" | 16 #include "components/mus/public/interfaces/gpu.mojom.h" |
17 #include "components/resource_provider/public/cpp/resource_loader.h" | 17 #include "components/resource_provider/public/cpp/resource_loader.h" |
18 #include "mojo/services/tracing/public/cpp/tracing_impl.h" | 18 #include "mojo/services/tracing/public/cpp/tracing_impl.h" |
19 #include "skia/ext/refptr.h" | 19 #include "skia/ext/refptr.h" |
20 #include "ui/gfx/geometry/size.h" | 20 #include "ui/gfx/geometry/size.h" |
21 | 21 |
22 namespace font_service { | 22 namespace font_service { |
23 class FontLoader; | 23 class FontLoader; |
24 } | 24 } |
25 | 25 |
26 namespace mojo { | 26 namespace mojo { |
27 class ApplicationImpl; | |
28 namespace shell { | |
29 namespace mojom { | |
30 class Shell; | 27 class Shell; |
31 } | 28 } |
32 } | |
33 } | |
34 | 29 |
35 namespace ui { | 30 namespace ui { |
36 namespace mojo { | 31 namespace mojo { |
37 class UIInit; | 32 class UIInit; |
38 } | 33 } |
39 } | 34 } |
40 | 35 |
41 namespace scheduler { | 36 namespace scheduler { |
42 class RendererScheduler; | 37 class RendererScheduler; |
43 } | 38 } |
44 | 39 |
45 namespace html_viewer { | 40 namespace html_viewer { |
46 | 41 |
47 class BlinkPlatformImpl; | 42 class BlinkPlatformImpl; |
48 class MediaFactory; | 43 class MediaFactory; |
49 | 44 |
50 // GlobalState encapsulates the necessary state needed by HTMLViewer. Some | 45 // GlobalState encapsulates the necessary state needed by HTMLViewer. Some |
51 // objects are created immediately in the constructor, otherwise not until | 46 // objects are created immediately in the constructor, otherwise not until |
52 // InitIfNecessary() is invoked. | 47 // InitIfNecessary() is invoked. |
53 // | 48 // |
54 // GlobalState can be initialized in two distinct ways: | 49 // GlobalState can be initialized in two distinct ways: |
55 // . headless: this is determined by the command line, but can be forced by way | 50 // . headless: this is determined by the command line, but can be forced by way |
56 // of InitHeadless(). | 51 // of InitHeadless(). |
57 // . with a ui: this is done via InitIfNecessary(). | 52 // . with a ui: this is done via InitIfNecessary(). |
58 class GlobalState { | 53 class GlobalState { |
59 public: | 54 public: |
60 explicit GlobalState(mojo::ApplicationImpl* app); | 55 GlobalState(mojo::Shell* shell, const std::string& url); |
61 ~GlobalState(); | 56 ~GlobalState(); |
62 | 57 |
63 // Inits with the specified screen size and device pixel ratio. | 58 // Inits with the specified screen size and device pixel ratio. |
64 // NOTE: we wait to complete setup until the device pixel ratio is available | 59 // NOTE: we wait to complete setup until the device pixel ratio is available |
65 // as ResourceBundle uses the device pixel ratio during initialization. | 60 // as ResourceBundle uses the device pixel ratio during initialization. |
66 void InitIfNecessary(const gfx::Size& screen_size_in_pixels, | 61 void InitIfNecessary(const gfx::Size& screen_size_in_pixels, |
67 float device_pixel_ratio); | 62 float device_pixel_ratio); |
68 | 63 |
69 bool did_init() const { return did_init_; } | 64 bool did_init() const { return did_init_; } |
70 | 65 |
(...skipping 24 matching lines...) Expand all Loading... |
95 blink_settings_.reset(blink_settings); | 90 blink_settings_.reset(blink_settings); |
96 } | 91 } |
97 | 92 |
98 private: | 93 private: |
99 // Callback for |gpu_service_|->GetGpuInfo(). | 94 // Callback for |gpu_service_|->GetGpuInfo(). |
100 void GetGpuInfoCallback(mus::mojom::GpuInfoPtr gpu_info); | 95 void GetGpuInfoCallback(mus::mojom::GpuInfoPtr gpu_info); |
101 | 96 |
102 // App for HTMLViewer, not the document's app. | 97 // App for HTMLViewer, not the document's app. |
103 // WARNING: do not expose this. It's too easy to use the wrong one. | 98 // WARNING: do not expose this. It's too easy to use the wrong one. |
104 // HTMLDocument should be using the application it creates, not this one. | 99 // HTMLDocument should be using the application it creates, not this one. |
105 mojo::ApplicationImpl* app_; | 100 mojo::Shell* shell_; |
106 | 101 |
107 resource_provider::ResourceLoader resource_loader_; | 102 resource_provider::ResourceLoader resource_loader_; |
108 | 103 |
109 // True once we've completed init. | 104 // True once we've completed init. |
110 bool did_init_; | 105 bool did_init_; |
111 | 106 |
112 float device_pixel_ratio_; | 107 float device_pixel_ratio_; |
113 | 108 |
114 gfx::Size screen_size_in_pixels_; | 109 gfx::Size screen_size_in_pixels_; |
115 | 110 |
(...skipping 23 matching lines...) Expand all Loading... |
139 #if defined(OS_LINUX) && !defined(OS_ANDROID) | 134 #if defined(OS_LINUX) && !defined(OS_ANDROID) |
140 skia::RefPtr<font_service::FontLoader> font_loader_; | 135 skia::RefPtr<font_service::FontLoader> font_loader_; |
141 #endif | 136 #endif |
142 | 137 |
143 DISALLOW_COPY_AND_ASSIGN(GlobalState); | 138 DISALLOW_COPY_AND_ASSIGN(GlobalState); |
144 }; | 139 }; |
145 | 140 |
146 } // namespace html_viewer | 141 } // namespace html_viewer |
147 | 142 |
148 #endif // COMPONENTS_HTML_VIEWER_GLOBAL_STATE_H_ | 143 #endif // COMPONENTS_HTML_VIEWER_GLOBAL_STATE_H_ |
OLD | NEW |