OLD | NEW |
---|---|
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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/timer.h" | 9 #include "base/timer.h" |
10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
42 switches::kDisableRendererAccessibility)) { | 42 switches::kDisableRendererAccessibility)) { |
43 accessibility_mode_ = AccessibilityModeEditableTextOnly; | 43 accessibility_mode_ = AccessibilityModeEditableTextOnly; |
44 } | 44 } |
45 #endif // defined(OS_WIN) | 45 #endif // defined(OS_WIN) |
46 | 46 |
47 if (CommandLine::ForCurrentProcess()->HasSwitch( | 47 if (CommandLine::ForCurrentProcess()->HasSwitch( |
48 switches::kForceRendererAccessibility)) { | 48 switches::kForceRendererAccessibility)) { |
49 accessibility_mode_ = AccessibilityModeComplete; | 49 accessibility_mode_ = AccessibilityModeComplete; |
50 } | 50 } |
51 | 51 |
52 #if defined(OS_WIN) | |
oshima
2012/12/03 22:09:23
From the stack trace, the problem seems to be chro
dmazzoni
2012/12/03 23:32:30
Currently there's no Mac-specific or Linux-specifi
| |
53 // On Windows, UpdateHistogram calls some system functions with unknown | |
54 // runtime, so call it on the file thread to ensure there's no jank. | |
55 // Everything in that method must be safe to call on another thread. | |
56 BrowserThread::ID browser_thread = BrowserThread::FILE; | |
57 #else | |
58 // On all other platforms, UpdateHistogram should be called on the main | |
59 // thread. | |
60 BrowserThread::ID browser_thread = BrowserThread::UI; | |
oshima
2012/12/03 22:09:23
the name |browser_thread| doesn't make much sense.
dmazzoni
2012/12/03 23:32:30
Done.
| |
61 #endif | |
62 | |
52 // UpdateHistogram only takes a couple of milliseconds, but run it on | 63 // UpdateHistogram only takes a couple of milliseconds, but run it on |
53 // the FILE thread to guarantee there's no jank. | 64 // the FILE thread to guarantee there's no jank. |
54 // And we need to AddRef() the leaky singleton so that Bind doesn't | 65 // And we need to AddRef() the leaky singleton so that Bind doesn't |
55 // delete it prematurely. | 66 // delete it prematurely. |
oshima
2012/12/03 22:09:23
update this comment too. May be just move it insid
dmazzoni
2012/12/03 23:32:30
Thanks, meant to do that earlier. Done.
| |
56 AddRef(); | 67 AddRef(); |
57 BrowserThread::PostDelayedTask( | 68 BrowserThread::PostDelayedTask( |
58 BrowserThread::FILE, FROM_HERE, | 69 browser_thread, FROM_HERE, |
59 base::Bind(&BrowserAccessibilityStateImpl::UpdateHistogram, this), | 70 base::Bind(&BrowserAccessibilityStateImpl::UpdateHistogram, this), |
60 base::TimeDelta::FromSeconds(kAccessibilityHistogramDelaySecs)); | 71 base::TimeDelta::FromSeconds(kAccessibilityHistogramDelaySecs)); |
61 } | 72 } |
62 | 73 |
63 BrowserAccessibilityStateImpl::~BrowserAccessibilityStateImpl() { | 74 BrowserAccessibilityStateImpl::~BrowserAccessibilityStateImpl() { |
64 } | 75 } |
65 | 76 |
66 void BrowserAccessibilityStateImpl::OnScreenReaderDetected() { | 77 void BrowserAccessibilityStateImpl::OnScreenReaderDetected() { |
67 if (CommandLine::ForCurrentProcess()->HasSwitch( | 78 if (CommandLine::ForCurrentProcess()->HasSwitch( |
68 switches::kDisableRendererAccessibility)) { | 79 switches::kDisableRendererAccessibility)) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
107 AccessibilityMode BrowserAccessibilityStateImpl::GetAccessibilityMode() { | 118 AccessibilityMode BrowserAccessibilityStateImpl::GetAccessibilityMode() { |
108 return accessibility_mode_; | 119 return accessibility_mode_; |
109 } | 120 } |
110 | 121 |
111 void BrowserAccessibilityStateImpl::SetAccessibilityMode( | 122 void BrowserAccessibilityStateImpl::SetAccessibilityMode( |
112 AccessibilityMode mode) { | 123 AccessibilityMode mode) { |
113 accessibility_mode_ = mode; | 124 accessibility_mode_ = mode; |
114 } | 125 } |
115 | 126 |
116 } // namespace content | 127 } // namespace content |
OLD | NEW |