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

Side by Side Diff: content/browser/accessibility/browser_accessibility_state_impl.cc

Issue 2899623003: Revert of Switch BrowserAccessibilityStateImpl to the TaskScheduler API. (Closed)
Patch Set: 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/accessibility/browser_accessibility_state_impl.h" 5 #include "content/browser/accessibility/browser_accessibility_state_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
11 #include "base/task_scheduler/post_task.h"
12 #include "build/build_config.h" 11 #include "build/build_config.h"
13 #include "content/browser/renderer_host/render_widget_host_impl.h" 12 #include "content/browser/renderer_host/render_widget_host_impl.h"
14 #include "content/browser/web_contents/web_contents_impl.h" 13 #include "content/browser/web_contents/web_contents_impl.h"
15 #include "content/public/browser/browser_thread.h" 14 #include "content/public/browser/browser_thread.h"
16 #include "content/public/common/content_switches.h" 15 #include "content/public/common/content_switches.h"
17 #include "ui/gfx/color_utils.h" 16 #include "ui/gfx/color_utils.h"
18 17
19 namespace content { 18 namespace content {
20 19
21 // IMPORTANT! 20 // IMPORTANT!
(...skipping 29 matching lines...) Expand all
51 BrowserAccessibilityStateImpl* BrowserAccessibilityStateImpl::GetInstance() { 50 BrowserAccessibilityStateImpl* BrowserAccessibilityStateImpl::GetInstance() {
52 return base::Singleton< 51 return base::Singleton<
53 BrowserAccessibilityStateImpl, 52 BrowserAccessibilityStateImpl,
54 base::LeakySingletonTraits<BrowserAccessibilityStateImpl>>::get(); 53 base::LeakySingletonTraits<BrowserAccessibilityStateImpl>>::get();
55 } 54 }
56 55
57 BrowserAccessibilityStateImpl::BrowserAccessibilityStateImpl() 56 BrowserAccessibilityStateImpl::BrowserAccessibilityStateImpl()
58 : BrowserAccessibilityState(), 57 : BrowserAccessibilityState(),
59 disable_hot_tracking_(false) { 58 disable_hot_tracking_(false) {
60 ResetAccessibilityModeValue(); 59 ResetAccessibilityModeValue();
60 #if defined(OS_WIN)
61 // On Windows, UpdateHistograms calls some system functions with unknown
62 // runtime, so call it on the file thread to ensure there's no jank.
63 // Everything in that method must be safe to call on another thread.
64 BrowserThread::ID update_histogram_thread = BrowserThread::FILE;
65 #else
66 // On all other platforms, UpdateHistograms should be called on the main
67 // thread.
68 BrowserThread::ID update_histogram_thread = BrowserThread::UI;
69 #endif
61 70
62 // We need to AddRef() the leaky singleton so that Bind doesn't 71 // We need to AddRef() the leaky singleton so that Bind doesn't
63 // delete it prematurely. 72 // delete it prematurely.
64 AddRef(); 73 AddRef();
65 // The delay is necessary because assistive technology sometimes isn't 74 BrowserThread::PostDelayedTask(
66 // detected until after the user interacts in some way, so a reasonable delay 75 update_histogram_thread, FROM_HERE,
67 // gives us better numbers.
68 base::PostDelayedTaskWithTraits(
69 FROM_HERE, {base::MayBlock(), base::TaskPriority::BACKGROUND},
70 base::Bind(&BrowserAccessibilityStateImpl::UpdateHistograms, this), 76 base::Bind(&BrowserAccessibilityStateImpl::UpdateHistograms, this),
71 base::TimeDelta::FromSeconds(ACCESSIBILITY_HISTOGRAM_DELAY_SECS)); 77 base::TimeDelta::FromSeconds(ACCESSIBILITY_HISTOGRAM_DELAY_SECS));
72 } 78 }
73 79
74 BrowserAccessibilityStateImpl::~BrowserAccessibilityStateImpl() { 80 BrowserAccessibilityStateImpl::~BrowserAccessibilityStateImpl() {
75 } 81 }
76 82
77 void BrowserAccessibilityStateImpl::OnScreenReaderDetected() { 83 void BrowserAccessibilityStateImpl::OnScreenReaderDetected() {
78 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 84 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
79 switches::kDisableRendererAccessibility)) { 85 switches::kDisableRendererAccessibility)) {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 accessibility_mode_.mode() ^ (mode.mode() & accessibility_mode_.mode()); 191 accessibility_mode_.mode() ^ (mode.mode() & accessibility_mode_.mode());
186 accessibility_mode_ = raw_flags; 192 accessibility_mode_ = raw_flags;
187 193
188 std::vector<WebContentsImpl*> web_contents_vector = 194 std::vector<WebContentsImpl*> web_contents_vector =
189 WebContentsImpl::GetAllWebContents(); 195 WebContentsImpl::GetAllWebContents();
190 for (size_t i = 0; i < web_contents_vector.size(); ++i) 196 for (size_t i = 0; i < web_contents_vector.size(); ++i)
191 web_contents_vector[i]->SetAccessibilityMode(accessibility_mode()); 197 web_contents_vector[i]->SetAccessibilityMode(accessibility_mode());
192 } 198 }
193 199
194 } // namespace content 200 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698