| 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_SETUP_H_ | 5 #ifndef COMPONENTS_HTML_VIEWER_SETUP_H_ |
| 6 #define COMPONENTS_HTML_VIEWER_SETUP_H_ | 6 #define COMPONENTS_HTML_VIEWER_SETUP_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.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" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 // InitIfNecessary() is invoked. | 32 // InitIfNecessary() is invoked. |
| 33 // Setup can be initialized in two distinct ways: | 33 // Setup can be initialized in two distinct ways: |
| 34 // . headless: this is determined by the command line, but can be forced by way | 34 // . headless: this is determined by the command line, but can be forced by way |
| 35 // of InitHeadless(). | 35 // of InitHeadless(). |
| 36 // . with a ui: this is done via InitIfNecessary(). | 36 // . with a ui: this is done via InitIfNecessary(). |
| 37 class Setup { | 37 class Setup { |
| 38 public: | 38 public: |
| 39 explicit Setup(mojo::ApplicationImpl* app); | 39 explicit Setup(mojo::ApplicationImpl* app); |
| 40 ~Setup(); | 40 ~Setup(); |
| 41 | 41 |
| 42 // Use to explicitly create headless regardless of command line switches. | |
| 43 // This must be invoked before InitIfNecessary(). | |
| 44 void InitHeadless(); | |
| 45 | |
| 46 // Inits with the specified screen size and device pixel ratio. | 42 // Inits with the specified screen size and device pixel ratio. |
| 47 // NOTE: we wait to complete setup until the device pixel ratio is available | 43 // NOTE: we wait to complete setup until the device pixel ratio is available |
| 48 // as ResourceBundle uses the device pixel ratio during initialization. | 44 // as ResourceBundle uses the device pixel ratio during initialization. |
| 49 void InitIfNecessary(const gfx::Size& screen_size_in_pixels, | 45 void InitIfNecessary(const gfx::Size& screen_size_in_pixels, |
| 50 float device_pixel_ratio); | 46 float device_pixel_ratio); |
| 51 | 47 |
| 52 bool is_headless() const { return is_headless_; } | 48 bool is_headless() const { return is_headless_; } |
| 53 bool did_init() const { return did_init_; } | 49 bool did_init() const { return did_init_; } |
| 54 | 50 |
| 55 const gfx::Size& screen_size_in_pixels() const { | 51 const gfx::Size& screen_size_in_pixels() const { |
| 56 return screen_size_in_pixels_; | 52 return screen_size_in_pixels_; |
| 57 } | 53 } |
| 58 | 54 |
| 59 float device_pixel_ratio() const { return device_pixel_ratio_; } | 55 float device_pixel_ratio() const { return device_pixel_ratio_; } |
| 60 | 56 |
| 61 scoped_refptr<base::SingleThreadTaskRunner> compositor_thread() { | 57 scoped_refptr<base::SingleThreadTaskRunner> compositor_thread() { |
| 62 return compositor_thread_.task_runner(); | 58 return compositor_thread_.task_runner(); |
| 63 } | 59 } |
| 64 | 60 |
| 65 MediaFactory* media_factory() { return media_factory_.get(); } | 61 MediaFactory* media_factory() { return media_factory_.get(); } |
| 66 | 62 |
| 67 private: | 63 private: |
| 68 // App for HTMLViewer, not the document's app. | 64 // App for HTMLViewer, not the document's app. |
| 69 // WARNING: do not expose this. It's too easy to use the wrong one. | 65 // WARNING: do not expose this. It's too easy to use the wrong one. |
| 70 // HTMLDocument should be using the application it creates, not this one. | 66 // HTMLDocument should be using the application it creates, not this one. |
| 71 mojo::ApplicationImpl* app_; | 67 mojo::ApplicationImpl* app_; |
| 72 | 68 |
| 73 resource_provider::ResourceLoader resource_loader_; | 69 resource_provider::ResourceLoader resource_loader_; |
| 74 | 70 |
| 75 bool is_headless_; | 71 const bool is_headless_; |
| 76 | 72 |
| 77 // True once we've completed init. | 73 // True once we've completed init. |
| 78 bool did_init_; | 74 bool did_init_; |
| 79 | 75 |
| 80 float device_pixel_ratio_; | 76 float device_pixel_ratio_; |
| 81 | 77 |
| 82 gfx::Size screen_size_in_pixels_; | 78 gfx::Size screen_size_in_pixels_; |
| 83 | 79 |
| 84 scoped_ptr<UISetup> ui_setup_; | 80 scoped_ptr<UISetup> ui_setup_; |
| 85 | 81 |
| 86 // Skia requires that we have one of these. Unlike the one used in chrome, | 82 // Skia requires that we have one of these. Unlike the one used in chrome, |
| 87 // this doesn't use purgable shared memory. Instead, it tries to free the | 83 // this doesn't use purgable shared memory. Instead, it tries to free the |
| 88 // oldest unlocked chunks on allocation. | 84 // oldest unlocked chunks on allocation. |
| 89 // | 85 // |
| 90 // TODO(erg): In the long run, delete this allocator and get the real shared | 86 // TODO(erg): In the long run, delete this allocator and get the real shared |
| 91 // memory based purging allocator working here. | 87 // memory based purging allocator working here. |
| 92 DiscardableMemoryAllocator discardable_memory_allocator_; | 88 DiscardableMemoryAllocator discardable_memory_allocator_; |
| 93 | 89 |
| 94 scoped_ptr<scheduler::RendererScheduler> renderer_scheduler_; | 90 scoped_ptr<scheduler::RendererScheduler> renderer_scheduler_; |
| 95 scoped_ptr<BlinkPlatformImpl> blink_platform_; | 91 scoped_ptr<BlinkPlatformImpl> blink_platform_; |
| 96 base::Thread compositor_thread_; | 92 base::Thread compositor_thread_; |
| 97 scoped_ptr<MediaFactory> media_factory_; | 93 scoped_ptr<MediaFactory> media_factory_; |
| 98 | 94 |
| 99 DISALLOW_COPY_AND_ASSIGN(Setup); | 95 DISALLOW_COPY_AND_ASSIGN(Setup); |
| 100 }; | 96 }; |
| 101 | 97 |
| 102 } // namespace html_viewer | 98 } // namespace html_viewer |
| 103 | 99 |
| 104 #endif // COMPONENTS_HTML_VIEWER_SETUP_H_ | 100 #endif // COMPONENTS_HTML_VIEWER_SETUP_H_ |
| OLD | NEW |