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

Side by Side Diff: components/startup_metric_utils/browser/startup_metric_utils.cc

Issue 1620673003: base: Implement GetCurrentThreadPriority. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase error. Created 4 years, 9 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/startup_metric_utils/browser/startup_metric_utils.h" 5 #include "components/startup_metric_utils/browser/startup_metric_utils.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/containers/hash_tables.h" 9 #include "base/containers/hash_tables.h"
10 #include "base/environment.h" 10 #include "base/environment.h"
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 // compared to multi-seconds startup timings. 264 // compared to multi-seconds startup timings.
265 base::TimeTicks StartupTimeToTimeTicks(const base::Time& time) { 265 base::TimeTicks StartupTimeToTimeTicks(const base::Time& time) {
266 // First get a base which represents the same point in time in both units. 266 // First get a base which represents the same point in time in both units.
267 // Bump the priority of this thread while doing this as the wall clock time it 267 // Bump the priority of this thread while doing this as the wall clock time it
268 // takes to resolve these two calls affects the precision of this method and 268 // takes to resolve these two calls affects the precision of this method and
269 // bumping the priority reduces the likelihood of a context switch interfering 269 // bumping the priority reduces the likelihood of a context switch interfering
270 // with this computation. 270 // with this computation.
271 271
272 // platform_thread_mac.mm unfortunately doesn't properly support base's 272 // platform_thread_mac.mm unfortunately doesn't properly support base's
273 // thread priority APIs (crbug.com/554651). 273 // thread priority APIs (crbug.com/554651).
274 #if !defined(OS_MACOSX)
275 static bool statics_initialized = false; 274 static bool statics_initialized = false;
276 275
277 base::ThreadPriority previous_priority = base::ThreadPriority::NORMAL; 276 base::ThreadPriority previous_priority = base::ThreadPriority::NORMAL;
278 if (!statics_initialized) { 277 if (!statics_initialized) {
279 previous_priority = base::PlatformThread::GetCurrentThreadPriority(); 278 previous_priority = base::PlatformThread::GetCurrentThreadPriority();
280 base::PlatformThread::SetCurrentThreadPriority( 279 base::PlatformThread::SetCurrentThreadPriority(
281 base::ThreadPriority::DISPLAY); 280 base::ThreadPriority::DISPLAY);
282 } 281 }
283 #endif
284 282
285 static const base::Time time_base = base::Time::Now(); 283 static const base::Time time_base = base::Time::Now();
286 static const base::TimeTicks trace_ticks_base = base::TimeTicks::Now(); 284 static const base::TimeTicks trace_ticks_base = base::TimeTicks::Now();
287 285
288 #if !defined(OS_MACOSX)
289 if (!statics_initialized) { 286 if (!statics_initialized) {
290 base::PlatformThread::SetCurrentThreadPriority(previous_priority); 287 base::PlatformThread::SetCurrentThreadPriority(previous_priority);
291 } 288 }
292 289
293 statics_initialized = true; 290 statics_initialized = true;
294 #endif
295 291
296 // Then use the TimeDelta common ground between the two units to make the 292 // Then use the TimeDelta common ground between the two units to make the
297 // conversion. 293 // conversion.
298 const base::TimeDelta delta_since_base = time_base - time; 294 const base::TimeDelta delta_since_base = time_base - time;
299 return trace_ticks_base - delta_since_base; 295 return trace_ticks_base - delta_since_base;
300 } 296 }
301 297
302 // Record time of main entry so it can be read from Telemetry performance tests. 298 // Record time of main entry so it can be read from Telemetry performance tests.
303 // TODO(jeremy): Remove once crbug.com/317481 is fixed. 299 // TODO(jeremy): Remove once crbug.com/317481 is fixed.
304 void RecordMainEntryTimeHistogram() { 300 void RecordMainEntryTimeHistogram() {
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 699
704 base::TimeTicks MainEntryPointTicks() { 700 base::TimeTicks MainEntryPointTicks() {
705 return g_browser_main_entry_point_ticks.Get(); 701 return g_browser_main_entry_point_ticks.Get();
706 } 702 }
707 703
708 StartupTemperature GetStartupTemperature() { 704 StartupTemperature GetStartupTemperature() {
709 return g_startup_temperature; 705 return g_startup_temperature;
710 } 706 }
711 707
712 } // namespace startup_metric_utils 708 } // namespace startup_metric_utils
OLDNEW
« base/threading/platform_thread_mac.mm ('K') | « base/threading/platform_thread_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698