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

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

Issue 11299312: Run Chrome OS accessibility histograms on main thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed feedback Created 8 years 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 | Annotate | Revision Log
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 "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
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 // UpdateHistogram only takes a couple of milliseconds, but run it on 52 #if defined(OS_WIN)
53 // the FILE thread to guarantee there's no jank. 53 // On Windows, UpdateHistogram calls some system functions with unknown
54 // And we need to AddRef() the leaky singleton so that Bind doesn't 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 update_histogram_thread = BrowserThread::FILE;
57 #else
58 // On all other platforms, UpdateHistogram should be called on the main
59 // thread.
60 BrowserThread::ID update_histogram_thread = BrowserThread::UI;
61 #endif
62
63 // We need to AddRef() the leaky singleton so that Bind doesn't
55 // delete it prematurely. 64 // delete it prematurely.
56 AddRef(); 65 AddRef();
57 BrowserThread::PostDelayedTask( 66 BrowserThread::PostDelayedTask(
58 BrowserThread::FILE, FROM_HERE, 67 update_histogram_thread, FROM_HERE,
59 base::Bind(&BrowserAccessibilityStateImpl::UpdateHistogram, this), 68 base::Bind(&BrowserAccessibilityStateImpl::UpdateHistogram, this),
60 base::TimeDelta::FromSeconds(kAccessibilityHistogramDelaySecs)); 69 base::TimeDelta::FromSeconds(kAccessibilityHistogramDelaySecs));
61 } 70 }
62 71
63 BrowserAccessibilityStateImpl::~BrowserAccessibilityStateImpl() { 72 BrowserAccessibilityStateImpl::~BrowserAccessibilityStateImpl() {
64 } 73 }
65 74
66 void BrowserAccessibilityStateImpl::OnScreenReaderDetected() { 75 void BrowserAccessibilityStateImpl::OnScreenReaderDetected() {
67 if (CommandLine::ForCurrentProcess()->HasSwitch( 76 if (CommandLine::ForCurrentProcess()->HasSwitch(
68 switches::kDisableRendererAccessibility)) { 77 switches::kDisableRendererAccessibility)) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 AccessibilityMode BrowserAccessibilityStateImpl::GetAccessibilityMode() { 116 AccessibilityMode BrowserAccessibilityStateImpl::GetAccessibilityMode() {
108 return accessibility_mode_; 117 return accessibility_mode_;
109 } 118 }
110 119
111 void BrowserAccessibilityStateImpl::SetAccessibilityMode( 120 void BrowserAccessibilityStateImpl::SetAccessibilityMode(
112 AccessibilityMode mode) { 121 AccessibilityMode mode) {
113 accessibility_mode_ = mode; 122 accessibility_mode_ = mode;
114 } 123 }
115 124
116 } // namespace content 125 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698