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

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

Issue 1921923002: Convert //components/[o-t]* from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 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
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 <memory>
10
9 #include "base/containers/hash_tables.h" 11 #include "base/containers/hash_tables.h"
10 #include "base/environment.h" 12 #include "base/environment.h"
11 #include "base/lazy_instance.h" 13 #include "base/lazy_instance.h"
12 #include "base/logging.h" 14 #include "base/logging.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/metrics/histogram.h" 15 #include "base/metrics/histogram.h"
15 #include "base/metrics/histogram_macros.h" 16 #include "base/metrics/histogram_macros.h"
16 #include "base/process/process_info.h" 17 #include "base/process/process_info.h"
17 #include "base/strings/string_number_conversions.h" 18 #include "base/strings/string_number_conversions.h"
18 #include "base/sys_info.h" 19 #include "base/sys_info.h"
19 #include "base/threading/platform_thread.h" 20 #include "base/threading/platform_thread.h"
20 #include "base/trace_event/trace_event.h" 21 #include "base/trace_event/trace_event.h"
21 #include "build/build_config.h" 22 #include "build/build_config.h"
22 #include "components/prefs/pref_registry_simple.h" 23 #include "components/prefs/pref_registry_simple.h"
23 #include "components/prefs/pref_service.h" 24 #include "components/prefs/pref_service.h"
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 } 344 }
344 } 345 }
345 346
346 // Environment variable that stores the timestamp when the executable's main() 347 // Environment variable that stores the timestamp when the executable's main()
347 // function was entered in TimeTicks. This is required because chrome.exe and 348 // function was entered in TimeTicks. This is required because chrome.exe and
348 // chrome.dll don't share the same static storage. 349 // chrome.dll don't share the same static storage.
349 const char kChromeMainTicksEnvVar[] = "CHROME_MAIN_TICKS"; 350 const char kChromeMainTicksEnvVar[] = "CHROME_MAIN_TICKS";
350 351
351 // Returns the time of main entry recorded from RecordExeMainEntryTime. 352 // Returns the time of main entry recorded from RecordExeMainEntryTime.
352 base::TimeTicks ExeMainEntryPointTicks() { 353 base::TimeTicks ExeMainEntryPointTicks() {
353 scoped_ptr<base::Environment> env(base::Environment::Create()); 354 std::unique_ptr<base::Environment> env(base::Environment::Create());
354 std::string ticks_string; 355 std::string ticks_string;
355 int64_t time_int = 0; 356 int64_t time_int = 0;
356 if (env->GetVar(kChromeMainTicksEnvVar, &ticks_string) && 357 if (env->GetVar(kChromeMainTicksEnvVar, &ticks_string) &&
357 base::StringToInt64(ticks_string, &time_int)) { 358 base::StringToInt64(ticks_string, &time_int)) {
358 return base::TimeTicks::FromInternalValue(time_int); 359 return base::TimeTicks::FromInternalValue(time_int);
359 } 360 }
360 return base::TimeTicks(); 361 return base::TimeTicks();
361 } 362 }
362 363
363 void AddStartupEventsForTelemetry() 364 void AddStartupEventsForTelemetry()
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 // TODO(jeremy): Remove this with RecordMainEntryTimeHistogram() when 531 // TODO(jeremy): Remove this with RecordMainEntryTimeHistogram() when
531 // resolving crbug.com/317481. 532 // resolving crbug.com/317481.
532 DCHECK(g_browser_main_entry_point_time.Get().is_null()); 533 DCHECK(g_browser_main_entry_point_time.Get().is_null());
533 g_browser_main_entry_point_time.Get() = time; 534 g_browser_main_entry_point_time.Get() = time;
534 DCHECK(!g_browser_main_entry_point_time.Get().is_null()); 535 DCHECK(!g_browser_main_entry_point_time.Get().is_null());
535 } 536 }
536 537
537 void RecordExeMainEntryPointTime(const base::Time& time) { 538 void RecordExeMainEntryPointTime(const base::Time& time) {
538 const std::string exe_load_ticks = 539 const std::string exe_load_ticks =
539 base::Int64ToString(StartupTimeToTimeTicks(time).ToInternalValue()); 540 base::Int64ToString(StartupTimeToTimeTicks(time).ToInternalValue());
540 scoped_ptr<base::Environment> env(base::Environment::Create()); 541 std::unique_ptr<base::Environment> env(base::Environment::Create());
541 env->SetVar(kChromeMainTicksEnvVar, exe_load_ticks); 542 env->SetVar(kChromeMainTicksEnvVar, exe_load_ticks);
542 } 543 }
543 544
544 void RecordBrowserMainMessageLoopStart(const base::TimeTicks& ticks, 545 void RecordBrowserMainMessageLoopStart(const base::TimeTicks& ticks,
545 bool is_first_run, 546 bool is_first_run,
546 PrefService* pref_service) { 547 PrefService* pref_service) {
547 int same_version_startup_count = 0; 548 int same_version_startup_count = 0;
548 if (pref_service) 549 if (pref_service)
549 same_version_startup_count = RecordSameVersionStartupCount(pref_service); 550 same_version_startup_count = RecordSameVersionStartupCount(pref_service);
550 // Keep RecordHardFaultHistogram() first as much as possible as many other 551 // Keep RecordHardFaultHistogram() first as much as possible as many other
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 704
704 base::TimeTicks MainEntryPointTicks() { 705 base::TimeTicks MainEntryPointTicks() {
705 return g_browser_main_entry_point_ticks.Get(); 706 return g_browser_main_entry_point_ticks.Get();
706 } 707 }
707 708
708 StartupTemperature GetStartupTemperature() { 709 StartupTemperature GetStartupTemperature() {
709 return g_startup_temperature; 710 return g_startup_temperature;
710 } 711 }
711 712
712 } // namespace startup_metric_utils 713 } // namespace startup_metric_utils
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698