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

Side by Side Diff: components/html_viewer/global_state.cc

Issue 1341073004: Fix bug in shut down of HTMLViewer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge 2 trunk Created 5 years, 3 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
« no previous file with comments | « components/html_viewer/global_state.h ('k') | mojo/tools/data/apptests » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "components/html_viewer/global_state.h" 5 #include "components/html_viewer/global_state.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 device_pixel_ratio_(1.f), 65 device_pixel_ratio_(1.f),
66 discardable_memory_allocator_(kDesiredMaxMemory), 66 discardable_memory_allocator_(kDesiredMaxMemory),
67 compositor_thread_("compositor thread") { 67 compositor_thread_("compositor thread") {
68 } 68 }
69 69
70 GlobalState::~GlobalState() { 70 GlobalState::~GlobalState() {
71 if (blink_platform_) { 71 if (blink_platform_) {
72 renderer_scheduler_->Shutdown(); 72 renderer_scheduler_->Shutdown();
73 blink::shutdown(); 73 blink::shutdown();
74 } 74 }
75 #if defined(OS_LINUX) && !defined(OS_ANDROID)
76 if (font_loader_.get()) {
77 SkFontConfigInterface::SetGlobal(nullptr);
78 // FontLoader is ref counted. We need to explicitly shutdown the background
79 // thread, otherwise the background thread may be shutdown after the app is
80 // torn down, when we're in a bad state.
81 font_loader_->Shutdown();
82 }
83 #endif
75 } 84 }
76 85
77 void GlobalState::InitIfNecessary(const gfx::Size& screen_size_in_pixels, 86 void GlobalState::InitIfNecessary(const gfx::Size& screen_size_in_pixels,
78 float device_pixel_ratio) { 87 float device_pixel_ratio) {
79 if (did_init_) 88 if (did_init_)
80 return; 89 return;
81 90
82 DCHECK_NE(0.f, device_pixel_ratio); 91 DCHECK_NE(0.f, device_pixel_ratio);
83 92
84 did_init_ = true; 93 did_init_ = true;
85 device_pixel_ratio_ = device_pixel_ratio; 94 device_pixel_ratio_ = device_pixel_ratio;
86 screen_size_in_pixels_ = screen_size_in_pixels; 95 screen_size_in_pixels_ = screen_size_in_pixels;
87 96
88 if (!resource_loader_.BlockUntilLoaded()) { 97 if (!resource_loader_.BlockUntilLoaded()) {
89 // Assume on error we're being shut down. 98 // Assume on error we're being shut down.
90 app_->Quit(); 99 app_->Quit();
91 return; 100 return;
92 } 101 }
93 102
94 #if defined(OS_LINUX) && !defined(OS_ANDROID) 103 #if defined(OS_LINUX) && !defined(OS_ANDROID)
95 SkFontConfigInterface::SetGlobal(new font_service::FontLoader(app_)); 104 font_loader_ = skia::AdoptRef(new font_service::FontLoader(app_));
105 SkFontConfigInterface::SetGlobal(font_loader_.get());
96 #endif 106 #endif
97 107
98 ui_init_.reset( 108 ui_init_.reset(
99 new ui::mojo::UIInit(screen_size_in_pixels, device_pixel_ratio)); 109 new ui::mojo::UIInit(screen_size_in_pixels, device_pixel_ratio));
100 base::DiscardableMemoryAllocator::SetInstance(&discardable_memory_allocator_); 110 base::DiscardableMemoryAllocator::SetInstance(&discardable_memory_allocator_);
101 111
102 renderer_scheduler_ = scheduler::RendererScheduler::Create(); 112 renderer_scheduler_ = scheduler::RendererScheduler::Create();
103 blink_platform_.reset(new BlinkPlatformImpl(app_, renderer_scheduler_.get())); 113 blink_platform_.reset(new BlinkPlatformImpl(app_, renderer_scheduler_.get()));
104 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) 114 #if defined(V8_USE_EXTERNAL_STARTUP_DATA)
105 gin::V8Initializer::LoadV8SnapshotFromFD( 115 gin::V8Initializer::LoadV8SnapshotFromFD(
(...skipping 30 matching lines...) Expand all
136 media_factory_.reset( 146 media_factory_.reset(
137 new MediaFactory(compositor_thread_.task_runner(), app_->shell())); 147 new MediaFactory(compositor_thread_.task_runner(), app_->shell()));
138 148
139 if (command_line->HasSwitch(kJavaScriptFlags)) { 149 if (command_line->HasSwitch(kJavaScriptFlags)) {
140 std::string flags(command_line->GetSwitchValueASCII(kJavaScriptFlags)); 150 std::string flags(command_line->GetSwitchValueASCII(kJavaScriptFlags));
141 v8::V8::SetFlagsFromString(flags.c_str(), static_cast<int>(flags.size())); 151 v8::V8::SetFlagsFromString(flags.c_str(), static_cast<int>(flags.size()));
142 } 152 }
143 } 153 }
144 154
145 } // namespace html_viewer 155 } // namespace html_viewer
OLDNEW
« no previous file with comments | « components/html_viewer/global_state.h ('k') | mojo/tools/data/apptests » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698