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

Side by Side Diff: components/metrics/metrics_log.cc

Issue 1852143002: win: Remove GetModuleFromAddress, deduplicate __ImageBase code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 8 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/metrics/metrics_log.h" 5 #include "components/metrics/metrics_log.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <string> 10 #include <string>
(...skipping 22 matching lines...) Expand all
33 #include "components/metrics/proto/user_action_event.pb.h" 33 #include "components/metrics/proto/user_action_event.pb.h"
34 #include "components/prefs/pref_registry_simple.h" 34 #include "components/prefs/pref_registry_simple.h"
35 #include "components/prefs/pref_service.h" 35 #include "components/prefs/pref_service.h"
36 #include "components/variations/active_field_trials.h" 36 #include "components/variations/active_field_trials.h"
37 37
38 #if defined(OS_ANDROID) 38 #if defined(OS_ANDROID)
39 #include "base/android/build_info.h" 39 #include "base/android/build_info.h"
40 #endif 40 #endif
41 41
42 #if defined(OS_WIN) 42 #if defined(OS_WIN)
43 // http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx 43 #include "base/win/current_module.h"
44 extern "C" IMAGE_DOS_HEADER __ImageBase;
45 #endif 44 #endif
46 45
47 using base::SampleCountIterator; 46 using base::SampleCountIterator;
48 typedef variations::ActiveGroupId ActiveGroupId; 47 typedef variations::ActiveGroupId ActiveGroupId;
49 48
50 namespace metrics { 49 namespace metrics {
51 50
52 namespace { 51 namespace {
53 52
54 // Any id less than 16 bytes is considered to be a testing id. 53 // Any id less than 16 bytes is considered to be a testing id.
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 341
343 SystemProfileProto::Hardware* hardware = system_profile->mutable_hardware(); 342 SystemProfileProto::Hardware* hardware = system_profile->mutable_hardware();
344 343
345 // HardwareModelName() will return an empty string on platforms where it's 344 // HardwareModelName() will return an empty string on platforms where it's
346 // not implemented or if an error occured. 345 // not implemented or if an error occured.
347 hardware->set_hardware_class(base::SysInfo::HardwareModelName()); 346 hardware->set_hardware_class(base::SysInfo::HardwareModelName());
348 347
349 hardware->set_cpu_architecture(base::SysInfo::OperatingSystemArchitecture()); 348 hardware->set_cpu_architecture(base::SysInfo::OperatingSystemArchitecture());
350 hardware->set_system_ram_mb(base::SysInfo::AmountOfPhysicalMemoryMB()); 349 hardware->set_system_ram_mb(base::SysInfo::AmountOfPhysicalMemoryMB());
351 #if defined(OS_WIN) 350 #if defined(OS_WIN)
352 hardware->set_dll_base(reinterpret_cast<uint64_t>(&__ImageBase)); 351 hardware->set_dll_base(reinterpret_cast<uint64_t>(CURRENT_MODULE()));
353 #endif 352 #endif
354 353
355 #if defined(OVERRIDE_OS_NAME_TO_BLIMP) 354 #if defined(OVERRIDE_OS_NAME_TO_BLIMP)
356 os->set_name("Blimp"); 355 os->set_name("Blimp");
357 #else 356 #else
358 SystemProfileProto::OS* os = system_profile->mutable_os(); 357 SystemProfileProto::OS* os = system_profile->mutable_os();
359 std::string os_name = base::SysInfo::OperatingSystemName(); 358 std::string os_name = base::SysInfo::OperatingSystemName();
360 os->set_name(os_name); 359 os->set_name(os_name);
361 #endif 360 #endif
362 361
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 DCHECK(!closed_); 414 DCHECK(!closed_);
416 closed_ = true; 415 closed_ = true;
417 } 416 }
418 417
419 void MetricsLog::GetEncodedLog(std::string* encoded_log) { 418 void MetricsLog::GetEncodedLog(std::string* encoded_log) {
420 DCHECK(closed_); 419 DCHECK(closed_);
421 uma_proto_.SerializeToString(encoded_log); 420 uma_proto_.SerializeToString(encoded_log);
422 } 421 }
423 422
424 } // namespace metrics 423 } // namespace metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698