summaryrefslogtreecommitdiffstats
path: root/o3d
diff options
context:
space:
mode:
authorrlp@google.com <rlp@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-09 23:13:54 +0000
committerrlp@google.com <rlp@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-09 23:13:54 +0000
commita656dfedee36ea7fdff377604d665d484a549243 (patch)
tree50e79ec9fdbdf38ae535984cfab845e7271cfd4f /o3d
parentba625918f43f292ef3fbc5563770be7bbfd1f233 (diff)
downloadchromium_src-a656dfedee36ea7fdff377604d665d484a549243.zip
chromium_src-a656dfedee36ea7fdff377604d665d484a549243.tar.gz
chromium_src-a656dfedee36ea7fdff377604d665d484a549243.tar.bz2
Updating the installer to check for OpenGL stats. Requires saving those stats and uploading with others which required a modification of the stats uploading code to actually save old stats--which it should do anyways.
Review URL: http://codereview.chromium.org/295043 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31502 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d')
-rw-r--r--o3d/breakpad/win/bluescreen_detector.cc2
-rw-r--r--o3d/installer/win/custom_actions.cc139
-rw-r--r--o3d/installer/win/installer.gyp13
-rw-r--r--o3d/installer/win/o3d.wxs11
-rw-r--r--o3d/plugin/cross/plugin_logging.h10
-rw-r--r--o3d/plugin/mac/main_mac.mm2
-rw-r--r--o3d/plugin/mac/plugin_logging-mac.mm14
-rw-r--r--o3d/plugin/win/logger_main.cc2
-rw-r--r--o3d/plugin/win/main_win.cc2
-rw-r--r--o3d/plugin/win/plugin_logging-win32.cc14
-rw-r--r--o3d/plugin/win/plugin_metrics-win32.cc6
-rw-r--r--o3d/statsreport/uploader.h4
-rw-r--r--o3d/statsreport/uploader_aggregation-mac.mm9
-rw-r--r--o3d/statsreport/uploader_aggregation-posix.cc9
-rw-r--r--o3d/statsreport/uploader_aggregation-win32.cc9
15 files changed, 218 insertions, 28 deletions
diff --git a/o3d/breakpad/win/bluescreen_detector.cc b/o3d/breakpad/win/bluescreen_detector.cc
index 0d68fb5..9143fdc 100644
--- a/o3d/breakpad/win/bluescreen_detector.cc
+++ b/o3d/breakpad/win/bluescreen_detector.cc
@@ -325,7 +325,7 @@ void BluescreenLogger::LogBluescreen(int num_bluescreens) {
metric_bluescreens_total += num_bluescreens;
// Make sure we write this out to the registry immediately in case we're
// about to bluescreen again before the metrics timer fires!
- if (g_logger) g_logger->ProcessMetrics(false, true);
+ if (g_logger) g_logger->ProcessMetrics(false, true, false);
}
#endif // OS_WIN
diff --git a/o3d/installer/win/custom_actions.cc b/o3d/installer/win/custom_actions.cc
index 0f57d95..8b716e2 100644
--- a/o3d/installer/win/custom_actions.cc
+++ b/o3d/installer/win/custom_actions.cc
@@ -40,13 +40,22 @@
#include <strsafe.h> // Must be after tchar.h.
#include <windows.h>
#include <atlstr.h>
+#include <Cg/cg.h>
+#include <Cg/cgGL.h>
+#include <GL/glext.h>
+#include <GL/wglew.h>
#include "plugin/win/update_lock.h"
+#include "plugin/cross/plugin_logging.h"
+#include "plugin/cross/plugin_metrics.h"
#pragma comment(linker, "/EXPORT:CheckDirectX=_CheckDirectX@4")
+#pragma comment(linker, "/EXPORT:CheckOpenGL=_CheckOpenGL@4")
#pragma comment(linker, "/EXPORT:IsSoftwareRunning=_IsSoftwareRunning@4")
#pragma comment(linker, "/EXPORT:InstallD3DXIfNeeded=_InstallD3DXIfNeeded@4")
+
+
#if 0
// NOTE: Useful for debugging, but not currently in use. Left here so
// that I don't have to figure out how to write it again.
@@ -104,6 +113,128 @@ HRESULT SetRegKeyValueDWord(HKEY hkey_parent, const TCHAR *key_name,
return hr;
}
+void ErrorAndSetUnknownGLDrivers(MSIHANDLE installer_handle, TCHAR *message) {
+ WriteToMsiLog(installer_handle, message);
+ const int gl_not_found = 99999999;
+ o3d::metric_gl_major_version = gl_not_found;
+ o3d::metric_gl_minor_version = gl_not_found;
+}
+
+// Returns true on success.
+bool GetOpenGLMetrics(MSIHANDLE installer_handle) {
+ WNDCLASS wc;
+ if (!GetClassInfo(GetModuleHandle(NULL), L"TEMPGL", &wc)) {
+ ZeroMemory(&wc, sizeof(WNDCLASS));
+ wc.hInstance = GetModuleHandle(NULL);
+ wc.lpfnWndProc = DefWindowProc;
+ wc.lpszClassName = L"TEMPGL";
+
+ if (!RegisterClass(&wc)) {
+ WriteToMsiLog(installer_handle, _T("Failed to register window class."));
+ return false;
+ }
+ }
+
+ HWND temp_hwnd = CreateWindow(L"TEMPGL", L"TEMPGL", 0, CW_USEDEFAULT,
+ CW_USEDEFAULT, 0, 0, // size 0 by 0
+ NULL, NULL, GetModuleHandle(NULL), NULL);
+ if (!temp_hwnd) {
+ ErrorAndSetUnknownGLDrivers(installer_handle, _T("CreateWindow failed."));
+ return false;
+ }
+
+ // get the device context
+ HDC temp_dc = GetDC(temp_hwnd);
+ if (!temp_dc) {
+ ErrorAndSetUnknownGLDrivers(installer_handle, _T("GetDC failed."));
+ return false;
+ }
+
+ // find default pixel format
+ PIXELFORMATDESCRIPTOR pfd;
+ ZeroMemory(&pfd, sizeof(PIXELFORMATDESCRIPTOR));
+ pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
+ pfd.nVersion = 1;
+ pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
+ int pixelformat = ChoosePixelFormat(temp_dc, &pfd);
+
+ // set the pixel format for the dc
+ if (!SetPixelFormat(temp_dc, pixelformat, &pfd)) {
+ ErrorAndSetUnknownGLDrivers(installer_handle, _T("SetPixelFormat failed."));
+ return false;
+ }
+
+ // create rendering context
+ HGLRC gl_context = wglCreateContext(temp_dc);
+ if (!gl_context) {
+ ErrorAndSetUnknownGLDrivers(installer_handle,
+ _T("wglCreateContext failed."));
+ return false;
+ }
+
+ if (!wglMakeCurrent(temp_dc, gl_context)) {
+ ErrorAndSetUnknownGLDrivers(installer_handle, _T("wglMakeCurrent failed."));
+ return false;
+ }
+
+ const char *gl_version_string =
+ reinterpret_cast<const char*>(glGetString(GL_VERSION));
+ const char *gl_extensions_string =
+ reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS));
+ if ((gl_version_string == NULL) || (gl_extensions_string == NULL)) {
+ ErrorAndSetUnknownGLDrivers(installer_handle, _T("No GL found."));
+ return true;
+ }
+
+ // Get the OpenGL version from the start of the string.
+ int gl_major = 0, gl_minor = 0;
+ sscanf(gl_version_string, "%u.%u", &gl_major, &gl_minor);
+ o3d::metric_gl_major_version = gl_major;
+ o3d::metric_gl_minor_version = gl_minor;
+
+ // Get the HLSL version.
+ // On OpenGL 1.x it's 1.0 if the GL_ARB_shading_language_100 extension is
+ // present.
+ // On OpenGL 2.x it's a matter of getting the GL_SHADING_LANGUAGE_VERSION
+ // string.
+ int gl_hlsl_major = 0, gl_hlsl_minor = 0;
+ if ((gl_major == 1) &&
+ strstr(gl_extensions_string, "GL_ARB_shading_language_100")) {
+ gl_hlsl_major = 1;
+ gl_hlsl_minor = 0;
+ } else if (gl_major >= 2) {
+ const char* glsl_version_string =
+ reinterpret_cast<const char*>(glGetString(GL_SHADING_LANGUAGE_VERSION));
+ if (glsl_version_string) {
+ sscanf(glsl_version_string, "%u.%u", &gl_hlsl_major, &gl_hlsl_minor);
+ }
+ }
+ o3d::metric_gl_hlsl_major_version = gl_hlsl_major;
+ o3d::metric_gl_hlsl_minor_version = gl_hlsl_minor;
+
+ // Clean up
+ wglDeleteContext(gl_context);
+ ReleaseDC(temp_hwnd, temp_dc);
+ DestroyWindow(temp_hwnd);
+ UnregisterClass(L"TEMPGL", wc.hInstance);
+ return true;
+}
+
+bool GetOpenGLVersion(MSIHANDLE installer_handle) {
+ HRESULT hr = CoInitialize(NULL);
+ o3d::PluginLogging g_logger;
+ stats_report::g_global_metrics.Initialize();
+ // Get OpenGL stats logged
+ if (!GetOpenGLMetrics(installer_handle)) {
+ return false;
+ }
+ if (!g_logger.ProcessMetrics(true, false, false)) {
+ return false;
+ }
+ stats_report::g_global_metrics.Uninitialize();
+ return true;
+}
+
// Retrieve the currently installed version of DirectX using a COM
// DxDiagProvider. Returns 0 on error.
DWORD GetDirectXVersion() {
@@ -276,6 +407,14 @@ extern "C" UINT __stdcall CheckDirectX(MSIHANDLE installer_handle) {
return ERROR_SUCCESS;
}
+// Check the version of OpenGL installed and save a registry key
+extern "C" UINT __stdcall CheckOpenGL(MSIHANDLE installer_handle) {
+ if (!GetOpenGLVersion(installer_handle)) {
+ WriteToMsiLog(installer_handle, _T("GetOpenGLVersion failed!"));
+ }
+ return ERROR_SUCCESS;
+}
+
// Check to see whether the plugin is currently running. If it is, we can't
// update the plugin. The installer will check for the SOFTWARE_RUNNING flag
// and exit if it's trying to do a silent update. Knowing that it's failed this
diff --git a/o3d/installer/win/installer.gyp b/o3d/installer/win/installer.gyp
index ac6f183..d13232f 100644
--- a/o3d/installer/win/installer.gyp
+++ b/o3d/installer/win/installer.gyp
@@ -44,11 +44,20 @@
'sources': [
'custom_actions.cc',
],
+ 'dependencies': [
+ '../../../base/base.gyp:base',
+ '../../build/libs.gyp:cg_libs',
+ '../../build/libs.gyp:gl_libs',
+ '../../plugin/plugin.gyp:o3dPluginLogging',
+ '../../statsreport/statsreport.gyp:o3dStatsReport',
+ ],
'include_dirs': [
- '$(DXSDK_DIR)/Include',
'../..',
'../../..',
+ '../../<(glewdir)/include',
+ '../../<(cgdir)/include',
'<(INTERMEDIATE_DIR)',
+ '$(DXSDK_DIR)/Include',
],
'defines': [
'NOMINMAX',
@@ -127,6 +136,8 @@
'../../plugin/plugin.gyp:npo3dautoplugin',
'../../plugin/plugin.gyp:o3d_host',
'../../samples/samples.gyp:samples',
+ '../../build/libs.gyp:cg_libs',
+ '../../build/libs.gyp:gl_libs',
'cactions',
],
'rules': [
diff --git a/o3d/installer/win/o3d.wxs b/o3d/installer/win/o3d.wxs
index efca8d9..9fe28e9 100644
--- a/o3d/installer/win/o3d.wxs
+++ b/o3d/installer/win/o3d.wxs
@@ -313,6 +313,11 @@ Wix script for building o3d installer.
Id='CheckDirectX'
BinaryKey='CustomActions'
DllEntry='CheckDirectX' />
+ <!-- Custom action for detecting OpenGL Version. -->
+ <CustomAction
+ Id='CheckOpenGL'
+ BinaryKey='CustomActions'
+ DllEntry='CheckOpenGL' />
<!-- Custom action for checking that we're not already running. -->
<CustomAction
@@ -343,6 +348,9 @@ Wix script for building o3d installer.
<Custom
Action='CheckDirectX'
Before='LaunchConditions' />
+ <Custom
+ Action='CheckOpenGL'
+ Before='CheckDirectX' />
</InstallUISequence>
<InstallExecuteSequence>
@@ -356,6 +364,9 @@ Wix script for building o3d installer.
Action='CheckDirectX'
Before='LaunchConditions' />
<Custom
+ Action='CheckOpenGL'
+ Before='CheckDirectX' />
+ <Custom
Action='InstallD3DXIfNeeded'
After='InstallFiles'>
NOT Installed
diff --git a/o3d/plugin/cross/plugin_logging.h b/o3d/plugin/cross/plugin_logging.h
index f69c0a7..dcdff44 100644
--- a/o3d/plugin/cross/plugin_logging.h
+++ b/o3d/plugin/cross/plugin_logging.h
@@ -63,10 +63,13 @@ class PluginLogging {
//
// Parameters:
// exiting - whether the program is exiting
+ // force_report - whether to force the metrics to upload to the server
+ // save_old_metrics - whether to clear the metrics before aggregating
//
// Returns true if metrics were uploaded and/or aggregated successfully.
virtual bool ProcessMetrics(const bool exiting,
- const bool force_report);
+ const bool force_report,
+ const bool save_old_metrics);
// A helper function to call AggregateMetrics used for testing. Calls
// AggregateMetrics which gathers up the current metrics, puts them in
@@ -86,7 +89,8 @@ class PluginLogging {
// not necessarily mean an error; just that no metrics were uploaded.
virtual bool DoAggregateAndReportMetrics(const char* extra_url_arguments,
const char* user_agent,
- const bool force_report);
+ const bool force_report,
+ const bool save_old_metrics);
// PluginLogging assumes ownership of the timer.
void SetTimer(HighresTimer* timer);
@@ -127,7 +131,7 @@ class PluginLogging {
// Do an initial grab of the metrics. Don't pass true for force_report.
// This will force an upload of the metrics the first time o3d is run
// since the lastTransmission metric will not exist.
- logger->ProcessMetrics(false, false);
+ logger->ProcessMetrics(false, false, true);
return logger;
}
// Otherwise, they opted out so we make sure the registry is clear
diff --git a/o3d/plugin/mac/main_mac.mm b/o3d/plugin/mac/main_mac.mm
index 769d027..3f09e698 100644
--- a/o3d/plugin/mac/main_mac.mm
+++ b/o3d/plugin/mac/main_mac.mm
@@ -680,7 +680,7 @@ NPError OSCALL NP_Shutdown(void) {
if (g_logger) {
// Do a last sweep to aggregate metrics before we shut down
- g_logger->ProcessMetrics(true, false);
+ g_logger->ProcessMetrics(true, false, false);
delete g_logger;
g_logger = NULL;
g_logging_initialized = false;
diff --git a/o3d/plugin/mac/plugin_logging-mac.mm b/o3d/plugin/mac/plugin_logging-mac.mm
index ab3ad5c..674f0ca 100644
--- a/o3d/plugin/mac/plugin_logging-mac.mm
+++ b/o3d/plugin/mac/plugin_logging-mac.mm
@@ -72,7 +72,7 @@ bool PluginLogging::UpdateLogging() {
timer_->Start();
// We are not exiting just yet so pass false for that argument
// And we don't have to force it, so pass false for forcing
- return ProcessMetrics(false, false);
+ return ProcessMetrics(false, false, false);
}
@@ -156,7 +156,8 @@ static const char *GetUserID(void) {
bool PluginLogging::ProcessMetrics(const bool exiting,
- const bool force_report) {
+ const bool force_report,
+ const bool save_old_metrics) {
DLOG(INFO) << "ProcessMetrics()";
// Grab incremental process times, has to be done each time
// around the loop, because - well - time passes between
@@ -186,7 +187,8 @@ bool PluginLogging::ProcessMetrics(const bool exiting,
std::string user_agent8 = std::string(kUserAgent) +
PRODUCT_VERSION_STRING;
DoAggregateAndReportMetrics(client_id_argument.c_str(),
- user_agent8.c_str(), force_report);
+ user_agent8.c_str(), force_report,
+ save_old_metrics);
}
@@ -203,12 +205,14 @@ void PluginLogging::DoAggregateMetrics() {
bool PluginLogging::DoAggregateAndReportMetrics(
const char* extra_url_arguments,
const char* user_agent,
- const bool force_report) {
+ const bool force_report,
+ const bool save_old_metrics) {
DLOG(INFO) << "DoAggregateAndReportMetrics()";
// AggregateAndReportMetrics returns true if metrics were uploaded
return stats_report::AggregateAndReportMetrics(extra_url_arguments,
user_agent,
- force_report);
+ force_report,
+ save_old_metrics);
}
void PluginLogging::SetTimer(HighresTimer* timer) {
diff --git a/o3d/plugin/win/logger_main.cc b/o3d/plugin/win/logger_main.cc
index 4ff94a9..d41ca09 100644
--- a/o3d/plugin/win/logger_main.cc
+++ b/o3d/plugin/win/logger_main.cc
@@ -48,7 +48,7 @@ int main(int argc, wchar_t **argv) {
HRESULT hr = CoInitialize(NULL);
o3d::PluginLogging g_logger;
stats_report::g_global_metrics.Initialize();
- if (!g_logger.ProcessMetrics(false, true)) {
+ if (!g_logger.ProcessMetrics(false, true, false)) {
printf("Error with stats logging.'n");
exit(1);
}
diff --git a/o3d/plugin/win/main_win.cc b/o3d/plugin/win/main_win.cc
index 30f461a..785e771 100644
--- a/o3d/plugin/win/main_win.cc
+++ b/o3d/plugin/win/main_win.cc
@@ -756,7 +756,7 @@ NPError OSCALL NP_Shutdown(void) {
if (g_logger) {
// Do a last sweep to aggregate metrics before we shut down
- g_logger->ProcessMetrics(true, false);
+ g_logger->ProcessMetrics(true, false, false);
delete g_logger;
g_logger = NULL;
g_logging_initialized = false;
diff --git a/o3d/plugin/win/plugin_logging-win32.cc b/o3d/plugin/win/plugin_logging-win32.cc
index 64cf314..c27e2dc 100644
--- a/o3d/plugin/win/plugin_logging-win32.cc
+++ b/o3d/plugin/win/plugin_logging-win32.cc
@@ -75,7 +75,7 @@ bool PluginLogging::UpdateLogging() {
timer_->Start();
// We are not exiting just yet so pass false for that argument.
// We don't have to force stats reporting, so pass false for forcing, too.
- return ProcessMetrics(false, false);
+ return ProcessMetrics(false, false, false);
}
static uint64 ToSeconds(FILETIME time) {
@@ -106,7 +106,8 @@ void PluginLogging::RecordProcessTimes() {
}
bool PluginLogging::ProcessMetrics(const bool exiting,
- const bool force_report) {
+ const bool force_report,
+ const bool save_old_metrics) {
DLOG(INFO) << "ProcessMetrics()";
// Grab incremental process times. This has to be done each time
// around the loop since time passes between iterations.
@@ -152,7 +153,8 @@ bool PluginLogging::ProcessMetrics(const bool exiting,
std::string user_agent8 = std::string(kUserAgent) +
PRODUCT_VERSION_STRING;
DoAggregateAndReportMetrics(client_id_argument,
- user_agent8.c_str(), force_report);
+ user_agent8.c_str(), force_report,
+ save_old_metrics);
}
::ReleaseMutex(mutex);
@@ -168,12 +170,14 @@ void PluginLogging::DoAggregateMetrics() {
bool PluginLogging::DoAggregateAndReportMetrics(
const char* extra_url_arguments,
const char* user_agent,
- const bool force_report) {
+ const bool force_report,
+ const bool save_old_metrics) {
DLOG(INFO) << "DoAggregateAndReportMetrics()";
// This eturns true if metrics were uploaded.
return stats_report::AggregateAndReportMetrics(extra_url_arguments,
user_agent,
- force_report);
+ force_report,
+ save_old_metrics);
}
// This method is used for testing.
diff --git a/o3d/plugin/win/plugin_metrics-win32.cc b/o3d/plugin/win/plugin_metrics-win32.cc
index f183595..4e3b05a 100644
--- a/o3d/plugin/win/plugin_metrics-win32.cc
+++ b/o3d/plugin/win/plugin_metrics-win32.cc
@@ -75,6 +75,12 @@ DEFINE_METRIC_count(out_of_memory_total);
DEFINE_METRIC_count(bluescreens_total);
+// OpenGL Caps - insert more here
+DEFINE_METRIC_integer(gl_major_version);
+DEFINE_METRIC_integer(gl_minor_version);
+DEFINE_METRIC_integer(gl_hlsl_major_version);
+DEFINE_METRIC_integer(gl_hlsl_minor_version);
+
// D3D Caps
DEFINE_METRIC_integer(d3d_devcaps);
DEFINE_METRIC_integer(d3d_misccaps);
diff --git a/o3d/statsreport/uploader.h b/o3d/statsreport/uploader.h
index f514171..39b2b7c 100644
--- a/o3d/statsreport/uploader.h
+++ b/o3d/statsreport/uploader.h
@@ -56,10 +56,12 @@ class StatsUploader {
bool AggregateMetrics();
bool AggregateAndReportMetrics(const char* extra_url_arguments,
const char* user_agent,
- bool force_report);
+ bool force_report,
+ bool save_old_metrics);
bool TestableAggregateAndReportMetrics(const char* extra_url_arguments,
const char* user_agent,
bool force_report,
+ bool save_old_metrics,
StatsUploader* stats_uploader);
bool UploadMetrics(const char* extra_url_data, const char* user_agent,
const char *content);
diff --git a/o3d/statsreport/uploader_aggregation-mac.mm b/o3d/statsreport/uploader_aggregation-mac.mm
index c742490..ef564a0 100644
--- a/o3d/statsreport/uploader_aggregation-mac.mm
+++ b/o3d/statsreport/uploader_aggregation-mac.mm
@@ -128,10 +128,12 @@ void ResetPersistentMetrics() {
// were uploaded
bool AggregateAndReportMetrics(const char* extra_url_arguments,
const char* user_agent,
- bool force_report) {
+ bool force_report,
+ bool save_old_metrics) {
StatsUploader stats_uploader;
return TestableAggregateAndReportMetrics(extra_url_arguments, user_agent,
- force_report, &stats_uploader);
+ force_report, save_old_metrics,
+ &stats_uploader);
}
static int GetLastTransmissionTime() {
@@ -171,6 +173,7 @@ static void SetLastTransmissionTime(int when) {
bool TestableAggregateAndReportMetrics(const char* extra_url_arguments,
const char* user_agent,
bool force_report,
+ bool save_old_metrics,
StatsUploader* stats_uploader) {
// Open the store
MetricsAggregatorMac aggregator(g_global_metrics);
@@ -185,7 +188,7 @@ bool TestableAggregateAndReportMetrics(const char* extra_url_arguments,
if (last_transmission_time == 0 || last_transmission_time > now) {
LOG(WARNING) << "dodgy or missing last transmission time, wiping stats";
- ResetPersistentMetrics();
+ if (!save_old_metrics) ResetPersistentMetrics();
SetLastTransmissionTime(now);
diff --git a/o3d/statsreport/uploader_aggregation-posix.cc b/o3d/statsreport/uploader_aggregation-posix.cc
index 91f807b..4163326 100644
--- a/o3d/statsreport/uploader_aggregation-posix.cc
+++ b/o3d/statsreport/uploader_aggregation-posix.cc
@@ -86,10 +86,12 @@ bool AggregateMetrics() {
// were uploaded
bool AggregateAndReportMetrics(const char* extra_url_arguments,
const char* user_agent,
- bool force_report) {
+ bool force_report,
+ bool save_old_metrics) {
StatsUploader stats_uploader;
return TestableAggregateAndReportMetrics(extra_url_arguments, user_agent,
- force_report, &stats_uploader);
+ force_report, save_old_metrics,
+ &stats_uploader);
}
// Returns:
// true if metrics were uploaded successfully, false otherwise
@@ -98,6 +100,7 @@ bool AggregateAndReportMetrics(const char* extra_url_arguments,
bool TestableAggregateAndReportMetrics(const char* extra_url_arguments,
const char* user_agent,
bool force_report,
+ bool save_old_metrics,
StatsUploader* stats_uploader) {
// Open the store
MetricsAggregatorPosix aggregator(g_global_metrics);
@@ -114,7 +117,7 @@ bool TestableAggregateAndReportMetrics(const char* extra_url_arguments,
if (!success || last_transmission_time > now) {
LOG(WARNING) << "Hinky or missing last transmission time, wiping stats";
- aggregator.ResetMetrics();
+ if (!save_old_metrics) aggregator.ResetMetrics();
success = aggregator.SetValue(kLastTransmissionTimeValueName, now);
if (!success)
diff --git a/o3d/statsreport/uploader_aggregation-win32.cc b/o3d/statsreport/uploader_aggregation-win32.cc
index d2f438e..d128c77 100644
--- a/o3d/statsreport/uploader_aggregation-win32.cc
+++ b/o3d/statsreport/uploader_aggregation-win32.cc
@@ -88,10 +88,12 @@ void ResetPersistentMetrics(CRegKey *key) {
// were uploaded
bool AggregateAndReportMetrics(const char* extra_url_arguments,
const char* user_agent,
- bool force_report) {
+ bool force_report,
+ bool save_old_metrics) {
StatsUploader stats_uploader;
return TestableAggregateAndReportMetrics(extra_url_arguments, user_agent,
- force_report, &stats_uploader);
+ force_report, save_old_metrics,
+ &stats_uploader);
}
// Returns:
// true if metrics were uploaded successfully, false otherwise
@@ -100,6 +102,7 @@ bool AggregateAndReportMetrics(const char* extra_url_arguments,
bool TestableAggregateAndReportMetrics(const char* extra_url_arguments,
const char* user_agent,
bool force_report,
+ bool save_old_metrics,
StatsUploader* stats_uploader) {
CString key_name;
key_name.Format(kStatsKeyFormatString, PRODUCT_NAME_STRING_WIDE);
@@ -127,7 +130,7 @@ bool TestableAggregateAndReportMetrics(const char* extra_url_arguments,
last_transmission_time > now) {
DLOG(WARNING) << "Hinky or missing last transmission time, wiping stats";
- ResetPersistentMetrics(&key);
+ if (!save_old_metrics) ResetPersistentMetrics(&key);
err = key.SetValue(kLastTransmissionTimeValueName, REG_DWORD,
&now, sizeof(now));