summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--remoting/base/breakpad.h6
-rw-r--r--remoting/base/breakpad_linux.cc2
-rw-r--r--remoting/base/breakpad_mac.mm4
-rw-r--r--remoting/base/breakpad_win.cc53
-rw-r--r--remoting/base/breakpad_win_unittest.cc143
-rw-r--r--remoting/host/constants.h6
-rw-r--r--remoting/host/constants_win.cc9
-rw-r--r--remoting/host/elevated_controller_module_win.cc3
-rw-r--r--remoting/host/host_service_win.cc3
-rw-r--r--remoting/host/plugin/daemon_installer_win.cc44
-rw-r--r--remoting/host/remoting_me2me_host.cc3
-rw-r--r--remoting/host/usage_stats_consent.h (renamed from remoting/host/breakpad.h)6
-rw-r--r--remoting/host/usage_stats_consent_win.cc (renamed from remoting/host/breakpad_win.cc)49
-rw-r--r--remoting/remoting.gyp12
14 files changed, 177 insertions, 166 deletions
diff --git a/remoting/base/breakpad.h b/remoting/base/breakpad.h
index 7e1f0a4..5d81eb5 100644
--- a/remoting/base/breakpad.h
+++ b/remoting/base/breakpad.h
@@ -11,9 +11,9 @@ namespace remoting {
// that the user has agreed to crash dump reporting.
//
// Crash reporting has to be initialized as early as possible (e.g. the first
-// thing in main()) to catch crashes occured during the process startup.
-// The crashes occurred while invoking the static objects' constructors will not
-// be caught and reported. This should not be a problem as the static non POD
+// thing in main()) to catch crashes occuring during process startup.
+// Crashes which occur during the global static construction phase will not
+// be caught and reported. This should not be a problem as static non-POD
// objects are not allowed by the style guide and exceptions to this rule are
// rare.
void InitializeCrashReporting();
diff --git a/remoting/base/breakpad_linux.cc b/remoting/base/breakpad_linux.cc
index a9f8c89..415f42a 100644
--- a/remoting/base/breakpad_linux.cc
+++ b/remoting/base/breakpad_linux.cc
@@ -7,7 +7,7 @@
namespace remoting {
void InitializeCrashReporting() {
- // Crash dump collection is not implemented on Linux yet.
+ // TODO(alexeypa) Implement crash dump collection on Linux; see
// http://crbug.com/130678.
}
diff --git a/remoting/base/breakpad_mac.mm b/remoting/base/breakpad_mac.mm
index 7cfbec2..84cba44 100644
--- a/remoting/base/breakpad_mac.mm
+++ b/remoting/base/breakpad_mac.mm
@@ -7,8 +7,8 @@
namespace remoting {
void InitializeCrashReporting() {
- // Do nothing because crash dump reporting on Mac is initialized from
- // awakeFromNib method.
+ // TODO(alexeypa) Implement crash dump collection on Mac; see
+ // http://crbug.com/130678.
}
} // namespace remoting
diff --git a/remoting/base/breakpad_win.cc b/remoting/base/breakpad_win.cc
index 732c186..b622668 100644
--- a/remoting/base/breakpad_win.cc
+++ b/remoting/base/breakpad_win.cc
@@ -3,7 +3,7 @@
// found in the LICENSE file.
// This module contains the necessary code to register the Breakpad exception
-// handler. This implementation is based on Chrome/Crome Frame crash reporitng
+// handler. This implementation is based on Chrome/Chrome Frame crash reporting
// code. See:
// - src/chrome/app/breakpad_win.cc
// - src/chrome_frame/crash_server_init.cc
@@ -13,6 +13,7 @@
#include "remoting/base/breakpad.h"
#include <windows.h>
+#include <string>
#include "base/atomicops.h"
#include "base/logging.h"
@@ -20,12 +21,12 @@
#include "base/lazy_instance.h"
#include "base/memory/scoped_ptr.h"
#include "base/process_util.h"
-#include "base/string16.h"
+#include "base/utf_string_conversions.h"
#include "base/win/wrapped_window_proc.h"
#include "breakpad/src/client/windows/handler/exception_handler.h"
namespace remoting {
-void InitializeCrashReportingForTest(const wchar_t*);
+void InitializeCrashReportingForTest(const wchar_t* pipe_name);
} // namespace remoting
namespace {
@@ -58,7 +59,7 @@ class BreakpadWin {
BreakpadWin();
~BreakpadWin();
- static BreakpadWin& GetInstance();
+ static BreakpadWin* GetInstance();
private:
// Returns the Custom information to be used for crash reporting.
@@ -71,13 +72,14 @@ class BreakpadWin {
// the crash dump is created. To prevent duplicate crash reports we
// make every thread calling this method, except the very first one,
// go to sleep.
- static bool OnExceptionCallback(void*, EXCEPTION_POINTERS*,
- MDRawAssertionInfo*);
+ static bool OnExceptionCallback(void* context,
+ EXCEPTION_POINTERS* exinfo,
+ MDRawAssertionInfo* assertion);
// Crashes the process after generating a dump for the provided exception.
// Note that the crash reporter should be initialized before calling this
// function for it to do anything.
- static int OnWindowProcedureException(EXCEPTION_POINTERS* info);
+ static int OnWindowProcedureException(EXCEPTION_POINTERS* exinfo);
// Breakpad's exception handler.
scoped_ptr<google_breakpad::ExceptionHandler> breakpad_;
@@ -106,8 +108,10 @@ BreakpadWin::BreakpadWin() : handling_exception_(0) {
_CrtSetReportMode(_CRT_ASSERT, 0);
// Get the alternate dump directory. We use the temp path.
+ // N.B. We don't use base::GetTempDir() here to avoid running more code then
+ // necessary before crashes can be properly reported.
wchar_t temp_directory[MAX_PATH + 1] = { 0 };
- DWORD length = ::GetTempPath(MAX_PATH, temp_directory);
+ DWORD length = GetTempPath(MAX_PATH, temp_directory);
if (length == 0)
return;
@@ -141,8 +145,8 @@ BreakpadWin::~BreakpadWin() {
}
// static
-BreakpadWin& BreakpadWin::GetInstance() {
- return g_instance.Get();
+BreakpadWin* BreakpadWin::GetInstance() {
+ return &g_instance.Get();
}
// Returns the Custom information to be used for crash reporting.
@@ -152,9 +156,9 @@ google_breakpad::CustomClientInfo* BreakpadWin::GetCustomInfo() {
scoped_ptr<FileVersionInfo> version_info(
FileVersionInfo::CreateFileVersionInfoForModule(binary));
- string16 version;
+ std::wstring version;
if (version_info.get())
- version = version_info->product_version();
+ version = UTF16ToWide(version_info->product_version());
if (version.empty())
version = kBreakpadVersionDefault;
@@ -172,10 +176,11 @@ google_breakpad::CustomClientInfo* BreakpadWin::GetCustomInfo() {
}
// static
-bool BreakpadWin::OnExceptionCallback(
- void*, EXCEPTION_POINTERS*, MDRawAssertionInfo*) {
- BreakpadWin& self = BreakpadWin::GetInstance();
- if (NoBarrier_CompareAndSwap(&self.handling_exception_, 0, 1) != 0) {
+bool BreakpadWin::OnExceptionCallback(void* /* context */,
+ EXCEPTION_POINTERS* /* exinfo */,
+ MDRawAssertionInfo* /* assertion */) {
+ BreakpadWin* self = BreakpadWin::GetInstance();
+ if (NoBarrier_CompareAndSwap(&self->handling_exception_, 0, 1) != 0) {
// Capture every thread except the first one in the sleep. We don't
// want multiple threads to concurrently report exceptions.
::Sleep(INFINITE);
@@ -184,12 +189,12 @@ bool BreakpadWin::OnExceptionCallback(
}
// static
-int BreakpadWin::OnWindowProcedureException(EXCEPTION_POINTERS* info) {
- BreakpadWin& self = BreakpadWin::GetInstance();
- if (self.breakpad_.get() != NULL) {
- self.breakpad_->WriteMinidumpForException(info);
- ::TerminateProcess(::GetCurrentProcess(),
- info->ExceptionRecord->ExceptionCode);
+int BreakpadWin::OnWindowProcedureException(EXCEPTION_POINTERS* exinfo) {
+ BreakpadWin* self = BreakpadWin::GetInstance();
+ if (self->breakpad_.get() != NULL) {
+ self->breakpad_->WriteMinidumpForException(exinfo);
+ TerminateProcess(GetCurrentProcess(),
+ exinfo->ExceptionRecord->ExceptionCode);
}
return EXCEPTION_CONTINUE_SEARCH;
}
@@ -205,9 +210,7 @@ void InitializeCrashReporting() {
void InitializeCrashReportingForTest(const wchar_t* pipe_name) {
BreakpadWin::pipe_name_ = pipe_name;
-
- // Touch the object to make sure it is initialized.
- BreakpadWin::GetInstance();
+ InitializeCrashReporting();
}
} // namespace remoting
diff --git a/remoting/base/breakpad_win_unittest.cc b/remoting/base/breakpad_win_unittest.cc
index 859dba9..ea85280 100644
--- a/remoting/base/breakpad_win_unittest.cc
+++ b/remoting/base/breakpad_win_unittest.cc
@@ -3,12 +3,12 @@
// found in the LICENSE file.
#include <stdio.h>
+#include <string>
#include "base/compiler_specific.h"
#include "base/environment.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
-#include "base/string16.h"
#include "base/stringprintf.h"
#include "base/utf_string_conversions.h"
#include "breakpad/src/client/windows/crash_generation/client_info.h"
@@ -16,8 +16,6 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
-namespace remoting {
-
namespace {
// The name of the environment variable used to pass the crash server pipe name
@@ -31,8 +29,8 @@ const wchar_t kPipeNamePrefix[] = L"\\\\.\\pipe\\";
class MockCrashServerCallbacks {
public:
- MockCrashServerCallbacks() {}
- virtual ~MockCrashServerCallbacks() {}
+ MockCrashServerCallbacks();
+ virtual ~MockCrashServerCallbacks();
// |google_breakpad::CrashGenerationServer| invokes callbacks from artitrary
// thread pool threads. |OnClientDumpRequested| is the only one that happened
@@ -45,75 +43,108 @@ class MockCrashServerCallbacks {
static void OnClientDumpRequestCallback(
void* context,
const google_breakpad::ClientInfo* client_info,
- const string16* file_path) {
- reinterpret_cast<MockCrashServerCallbacks*>(context)->
- OnClientDumpRequested();
- }
+ const std::wstring* file_path);
};
+MockCrashServerCallbacks::MockCrashServerCallbacks() {
+}
+
+MockCrashServerCallbacks::~MockCrashServerCallbacks() {
+}
+
+// static
+void MockCrashServerCallbacks::OnClientDumpRequestCallback(
+ void* context,
+ const google_breakpad::ClientInfo* /* client_info */,
+ const std::wstring* /* file_path */) {
+ reinterpret_cast<MockCrashServerCallbacks*>(context)->OnClientDumpRequested();
+}
+
} // namespace
-void InitializeCrashReportingForTest(const wchar_t*);
+namespace remoting {
+
+void InitializeCrashReportingForTest(const wchar_t* pipe_name);
class BreakpadWinDeathTest : public testing::Test {
public:
- BreakpadWinDeathTest() {}
- virtual void SetUp() OVERRIDE {
- scoped_ptr<base::Environment> environment(base::Environment::Create());
- std::string pipe_name;
- if (environment->GetVar(kPipeVariableName, &pipe_name)) {
- // This is a child process. Initialize crash dump reporting to the crash
- // dump server.
- pipe_name_ = UTF8ToUTF16(pipe_name);
- ::remoting::InitializeCrashReportingForTest(pipe_name_.c_str());
- } else {
- // This is the parent process. Generate a unique pipe name and setup
- // a dummy crash dump server.
- UUID guid = {0};
- RPC_STATUS status = ::UuidCreate(&guid);
- EXPECT_TRUE(status == RPC_S_OK || status == RPC_S_UUID_LOCAL_ONLY);
-
- pipe_name_ = kPipeNamePrefix +
- base::StringPrintf(
- L"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
- guid.Data1, guid.Data2, guid.Data3,
- guid.Data4[0], guid.Data4[1], guid.Data4[2],
- guid.Data4[3], guid.Data4[4], guid.Data4[5],
- guid.Data4[6], guid.Data4[7]);
- bool result = environment->SetVar(kPipeVariableName,
- UTF16ToUTF8(pipe_name_));
- EXPECT_TRUE(result);
-
- // Setup a dummy crash dump server.
- callbacks_.reset(new MockCrashServerCallbacks());
- crash_server_.reset(
- new google_breakpad::CrashGenerationServer(
- pipe_name_, NULL,
- NULL, NULL,
- MockCrashServerCallbacks::OnClientDumpRequestCallback,
- callbacks_.get(),
- NULL, NULL,
- NULL, NULL,
- false, NULL));
-
- result = crash_server_->Start();
- ASSERT_TRUE(result);
- }
- }
+ BreakpadWinDeathTest();
+ virtual ~BreakpadWinDeathTest();
+
+ virtual void SetUp() OVERRIDE;
protected:
scoped_ptr<google_breakpad::CrashGenerationServer> crash_server_;
scoped_ptr<MockCrashServerCallbacks> callbacks_;
- string16 pipe_name_;
+ std::wstring pipe_name_;
};
+BreakpadWinDeathTest::BreakpadWinDeathTest() {
+}
+
+BreakpadWinDeathTest::~BreakpadWinDeathTest() {
+}
+
+void BreakpadWinDeathTest::SetUp() {
+ scoped_ptr<base::Environment> environment(base::Environment::Create());
+ std::string pipe_name;
+ if (environment->GetVar(kPipeVariableName, &pipe_name)) {
+ // This is a child process. Initialize crash dump reporting to the crash
+ // dump server.
+ pipe_name_ = UTF8ToWide(pipe_name);
+ InitializeCrashReportingForTest(pipe_name_.c_str());
+ } else {
+ // This is the parent process. Generate a unique pipe name and setup
+ // a dummy crash dump server.
+ UUID guid = {0};
+ RPC_STATUS status = UuidCreate(&guid);
+ EXPECT_TRUE(status == RPC_S_OK || status == RPC_S_UUID_LOCAL_ONLY);
+
+ pipe_name_ =
+ base::StringPrintf(
+ L"%ls%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
+ kPipeNamePrefix,
+ guid.Data1,
+ guid.Data2,
+ guid.Data3,
+ guid.Data4[0],
+ guid.Data4[1],
+ guid.Data4[2],
+ guid.Data4[3],
+ guid.Data4[4],
+ guid.Data4[5],
+ guid.Data4[6],
+ guid.Data4[7]);
+ EXPECT_TRUE(environment->SetVar(kPipeVariableName,
+ WideToUTF8(pipe_name_)));
+
+ // Setup a dummy crash dump server.
+ callbacks_.reset(new MockCrashServerCallbacks());
+ crash_server_.reset(
+ new google_breakpad::CrashGenerationServer(
+ pipe_name_,
+ NULL,
+ NULL,
+ NULL,
+ MockCrashServerCallbacks::OnClientDumpRequestCallback,
+ callbacks_.get(),
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ false,
+ NULL));
+ ASSERT_TRUE(crash_server_->Start());
+ }
+}
+
TEST_F(BreakpadWinDeathTest, TestAccessViolation) {
if (callbacks_.get()) {
EXPECT_CALL(*callbacks_, OnClientDumpRequested());
}
// Generate access violation exception.
- ASSERT_DEATH(*reinterpret_cast<int*>(0) = 1, "");
+ ASSERT_DEATH(*reinterpret_cast<int*>(NULL) = 1, "");
}
TEST_F(BreakpadWinDeathTest, TestInvalidParameter) {
@@ -122,7 +153,7 @@ TEST_F(BreakpadWinDeathTest, TestInvalidParameter) {
}
// Cause the invalid parameter callback to be called.
- ASSERT_EXIT(printf(NULL), ::testing::ExitedWithCode(0), "");
+ ASSERT_EXIT(printf(NULL), testing::ExitedWithCode(0), "");
}
TEST_F(BreakpadWinDeathTest, TestDebugbreak) {
diff --git a/remoting/host/constants.h b/remoting/host/constants.h
index 9358583..1737b34 100644
--- a/remoting/host/constants.h
+++ b/remoting/host/constants.h
@@ -5,7 +5,7 @@
#ifndef REMOTING_HOST_CONSTANTS_H_
#define REMOTING_HOST_CONSTANTS_H_
-#include "base/string16.h"
+#include "base/compiler_specific.h"
namespace remoting {
@@ -27,10 +27,8 @@ enum HostExitCodes {
};
#if defined(OS_WIN)
-
// The Omaha Appid of the host.
-extern const char16 kHostOmahaAppid[];
-
+extern const wchar_t kHostOmahaAppid[];
#endif // defined(OS_WIN)
} // namespace remoting
diff --git a/remoting/host/constants_win.cc b/remoting/host/constants_win.cc
index e13ce81..2df3e63 100644
--- a/remoting/host/constants_win.cc
+++ b/remoting/host/constants_win.cc
@@ -4,18 +4,11 @@
#include "remoting/host/constants.h"
-#include "base/stringize_macros.h"
-
namespace remoting {
-#if defined(OS_WIN)
-
// The Omaha Appid of the host. It should be kept in sync with $(var.OmahaAppid)
// defined in remoting/host/installer/chromoting.wxs and the Omaha server
// configuration.
-const char16 kHostOmahaAppid[] =
- TO_L_STRING("{b210701e-ffc4-49e3-932b-370728c72662}");
-
-#endif // defined(OS_WIN)
+const wchar_t kHostOmahaAppid[] = L"{b210701e-ffc4-49e3-932b-370728c72662}";
} // namespace remoting
diff --git a/remoting/host/elevated_controller_module_win.cc b/remoting/host/elevated_controller_module_win.cc
index 80e9233..0bff8c6 100644
--- a/remoting/host/elevated_controller_module_win.cc
+++ b/remoting/host/elevated_controller_module_win.cc
@@ -12,7 +12,7 @@
#include "base/logging.h"
#include "remoting/base/breakpad.h"
#include "remoting/host/branding.h"
-#include "remoting/host/breakpad.h"
+#include "remoting/host/usage_stats_consent.h"
// MIDL-generated declarations.
#include "remoting/host/elevated_controller.h"
@@ -31,7 +31,6 @@ class ElevatedControllerModuleWin
remoting::ElevatedControllerModuleWin _AtlModule;
int WINAPI WinMain(HINSTANCE instance, HINSTANCE, LPSTR, int command) {
- // Initializes the crash dump reports.
if (remoting::IsCrashReportingEnabled()) {
remoting::InitializeCrashReporting();
}
diff --git a/remoting/host/host_service_win.cc b/remoting/host/host_service_win.cc
index e9614ba..0f347ec 100644
--- a/remoting/host/host_service_win.cc
+++ b/remoting/host/host_service_win.cc
@@ -26,8 +26,8 @@
#include "remoting/base/breakpad.h"
#include "remoting/base/scoped_sc_handle_win.h"
#include "remoting/host/branding.h"
-#include "remoting/host/breakpad.h"
#include "remoting/host/host_service_resource.h"
+#include "remoting/host/usage_stats_consent.h"
#include "remoting/host/wts_console_observer_win.h"
#include "remoting/host/wts_session_process_launcher_win.h"
@@ -411,7 +411,6 @@ LRESULT CALLBACK HostService::SessionChangeNotificationProc(HWND hwnd,
} // namespace remoting
int main(int argc, char** argv) {
- // Initializes the crash dump reports.
if (remoting::IsCrashReportingEnabled()) {
remoting::InitializeCrashReporting();
}
diff --git a/remoting/host/plugin/daemon_installer_win.cc b/remoting/host/plugin/daemon_installer_win.cc
index a78420b..3ebd2ca 100644
--- a/remoting/host/plugin/daemon_installer_win.cc
+++ b/remoting/host/plugin/daemon_installer_win.cc
@@ -20,12 +20,8 @@
#include "base/win/scoped_comptr.h"
#include "base/win/scoped_handle.h"
#include "base/win/scoped_variant.h"
-#include "remoting/base/dispatch_win.h"
-
-namespace omaha {
#include "google_update/google_update_idl.h"
-} // namespace omaha
-
+#include "remoting/base/dispatch_win.h"
#include "remoting/host/constants.h"
using base::win::ScopedBstr;
@@ -195,10 +191,6 @@ void DaemonComInstallerWin::PollInstallationStatus() {
ScopedVariant state;
hr = dispatch::Invoke(V_DISPATCH(&current_state), L"stateValue",
DISPATCH_PROPERTYGET, state.Receive());
- if (FAILED(hr)) {
- Done(hr);
- return;
- }
if (state.type() != VT_I4) {
Done(DISP_E_TYPEMISMATCH);
return;
@@ -206,18 +198,18 @@ void DaemonComInstallerWin::PollInstallationStatus() {
// Perform state-specific actions.
switch (V_I4(&state)) {
- case omaha::STATE_INIT:
- case omaha::STATE_WAITING_TO_CHECK_FOR_UPDATE:
- case omaha::STATE_CHECKING_FOR_UPDATE:
- case omaha::STATE_WAITING_TO_DOWNLOAD:
- case omaha::STATE_RETRYING_DOWNLOAD:
- case omaha::STATE_DOWNLOADING:
- case omaha::STATE_WAITING_TO_INSTALL:
- case omaha::STATE_INSTALLING:
- case omaha::STATE_PAUSED:
+ case STATE_INIT:
+ case STATE_WAITING_TO_CHECK_FOR_UPDATE:
+ case STATE_CHECKING_FOR_UPDATE:
+ case STATE_WAITING_TO_DOWNLOAD:
+ case STATE_RETRYING_DOWNLOAD:
+ case STATE_DOWNLOADING:
+ case STATE_WAITING_TO_INSTALL:
+ case STATE_INSTALLING:
+ case STATE_PAUSED:
break;
- case omaha::STATE_UPDATE_AVAILABLE:
+ case STATE_UPDATE_AVAILABLE:
hr = dispatch::Invoke(V_DISPATCH(&bundle_), L"download",
DISPATCH_METHOD, NULL);
if (FAILED(hr)) {
@@ -226,10 +218,10 @@ void DaemonComInstallerWin::PollInstallationStatus() {
}
break;
- case omaha::STATE_DOWNLOAD_COMPLETE:
- case omaha::STATE_EXTRACTING:
- case omaha::STATE_APPLYING_DIFFERENTIAL_PATCH:
- case omaha::STATE_READY_TO_INSTALL:
+ case STATE_DOWNLOAD_COMPLETE:
+ case STATE_EXTRACTING:
+ case STATE_APPLYING_DIFFERENTIAL_PATCH:
+ case STATE_READY_TO_INSTALL:
hr = dispatch::Invoke(V_DISPATCH(&bundle_), L"install",
DISPATCH_METHOD, NULL);
if (FAILED(hr)) {
@@ -238,13 +230,13 @@ void DaemonComInstallerWin::PollInstallationStatus() {
}
break;
- case omaha::STATE_INSTALL_COMPLETE:
- case omaha::STATE_NO_UPDATE:
+ case STATE_INSTALL_COMPLETE:
+ case STATE_NO_UPDATE:
// Installation complete or not required. Report success.
Done(S_OK);
return;
- case omaha::STATE_ERROR: {
+ case STATE_ERROR: {
ScopedVariant error_code;
hr = dispatch::Invoke(V_DISPATCH(&current_state), L"errorCode",
DISPATCH_PROPERTYGET, error_code.Receive());
diff --git a/remoting/host/remoting_me2me_host.cc b/remoting/host/remoting_me2me_host.cc
index 04087ab..db4dfc5 100644
--- a/remoting/host/remoting_me2me_host.cc
+++ b/remoting/host/remoting_me2me_host.cc
@@ -25,7 +25,6 @@
#include "remoting/base/breakpad.h"
#include "remoting/base/constants.h"
#include "remoting/host/branding.h"
-#include "remoting/host/breakpad.h"
#include "remoting/host/constants.h"
#include "remoting/host/capturer.h"
#include "remoting/host/chromoting_host.h"
@@ -42,6 +41,7 @@
#include "remoting/host/policy_hack/nat_policy.h"
#include "remoting/host/session_manager_factory.h"
#include "remoting/host/signaling_connector.h"
+#include "remoting/host/usage_stats_consent.h"
#include "remoting/jingle_glue/xmpp_signal_strategy.h"
#include "remoting/protocol/me2me_host_authenticator_factory.h"
@@ -567,7 +567,6 @@ int CALLBACK WinMain(HINSTANCE instance,
HINSTANCE previous_instance,
LPSTR command_line,
int show_command) {
- // Initializes the crash dump reports.
if (remoting::IsCrashReportingEnabled()) {
remoting::InitializeCrashReporting();
}
diff --git a/remoting/host/breakpad.h b/remoting/host/usage_stats_consent.h
index bd13b98..ee49029 100644
--- a/remoting/host/breakpad.h
+++ b/remoting/host/usage_stats_consent.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef REMOTING_HOST_BREAKPAD_H_
-#define REMOTING_HOST_BREAKPAD_H_
+#ifndef REMOTING_HOST_USAGE_STATS_CONSENT_H_
+#define REMOTING_HOST_USAGE_STATS_CONSENT_H_
namespace remoting {
@@ -12,4 +12,4 @@ bool IsCrashReportingEnabled();
} // remoting
-#endif // REMOTING_HOST_BREAKPAD_H_
+#endif // REMOTING_HOST_USAGE_STATS_CONSENT_H_
diff --git a/remoting/host/breakpad_win.cc b/remoting/host/usage_stats_consent_win.cc
index a2623eb..3b5b283 100644
--- a/remoting/host/breakpad_win.cc
+++ b/remoting/host/usage_stats_consent_win.cc
@@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "remoting/host/breakpad.h"
+#include "remoting/host/usage_stats_consent.h"
#include <windows.h>
+#include <string>
-#include "base/string16.h"
#include "base/stringprintf.h"
#include "base/win/registry.h"
#include "remoting/host/constants.h"
@@ -14,12 +14,26 @@
namespace {
// The following strings are used to construct the registry key names where
-// the user's consent to collect crash dumps is recorded.
-const wchar_t kOmahaClientStateKeyFormat[] = L"Google\\Update\\%ls\\%ls";
+// we record whether the user has consented to crash dump collection.
+const wchar_t kOmahaClientStateKeyFormat[] =
+ L"Software\\Google\\Update\\%ls\\%ls";
const wchar_t kOmahaClientState[] = L"ClientState";
const wchar_t kOmahaClientStateMedium[] = L"ClientStateMedium";
const wchar_t kOmahaUsagestatsValue[] = L"usagestats";
+LONG ReadUsageStatsValue(const wchar_t* state_key, DWORD* usagestats_out) {
+ std::wstring client_state = StringPrintf(kOmahaClientStateKeyFormat,
+ state_key,
+ remoting::kHostOmahaAppid);
+ base::win::RegKey key;
+ LONG result = key.Open(HKEY_LOCAL_MACHINE, client_state.c_str(), KEY_READ);
+ if (result != ERROR_SUCCESS) {
+ return result;
+ }
+
+ return key.ReadValueDW(kOmahaUsagestatsValue, usagestats_out);
+}
+
} // namespace
namespace remoting {
@@ -28,29 +42,12 @@ bool IsCrashReportingEnabled() {
// The user's consent to collect crash dumps is recored as the "usagestats"
// value in the ClientState or ClientStateMedium key. Probe
// the ClientStateMedium key first.
- string16 client_state = StringPrintf(kOmahaClientStateKeyFormat,
- kOmahaClientStateMedium,
- remoting::kHostOmahaAppid);
- base::win::RegKey key;
- LONG result = key.Open(HKEY_LOCAL_MACHINE, client_state.c_str(), KEY_READ);
- if (result == ERROR_SUCCESS) {
- DWORD value = 0;
- result = key.ReadValueDW(kOmahaUsagestatsValue, &value);
- if (result == ERROR_SUCCESS) {
- return value != 0;
- }
+ DWORD value = 0;
+ if (ReadUsageStatsValue(kOmahaClientStateMedium, &value) == ERROR_SUCCESS) {
+ return value != 0;
}
-
- client_state = StringPrintf(kOmahaClientStateKeyFormat,
- kOmahaClientState,
- remoting::kHostOmahaAppid);
- result = key.Open(HKEY_LOCAL_MACHINE, client_state.c_str(), KEY_READ);
- if (result == ERROR_SUCCESS) {
- DWORD value = 0;
- result = key.ReadValueDW(kOmahaUsagestatsValue, &value);
- if (result == ERROR_SUCCESS) {
- return value != 0;
- }
+ if (ReadUsageStatsValue(kOmahaClientState, &value) == ERROR_SUCCESS) {
+ return value != 0;
}
// Do not collect anything unless the user has explicitly allowed it.
diff --git a/remoting/remoting.gyp b/remoting/remoting.gyp
index 764b304..39c9f67 100644
--- a/remoting/remoting.gyp
+++ b/remoting/remoting.gyp
@@ -517,14 +517,14 @@
'sources': [
'host/branding.cc',
'host/branding.h',
- 'host/breakpad.h',
- 'host/breakpad_win.cc',
'host/elevated_controller.rc',
'host/elevated_controller_module_win.cc',
'host/elevated_controller_win.cc',
'host/elevated_controller_win.h',
'host/pin_hash.cc',
'host/pin_hash.h',
+ 'host/usage_stats_consent.h',
+ 'host/usage_stats_consent_win.cc',
'host/verify_config_window_win.cc',
'host/verify_config_window_win.h',
'<(SHARED_INTERMEDIATE_DIR)/remoting/elevated_controller_version.rc'
@@ -564,8 +564,6 @@
'base/scoped_sc_handle_win.h',
'host/branding.cc',
'host/branding.h',
- 'host/breakpad.h',
- 'host/breakpad_win.cc',
'host/chromoting_messages.cc',
'host/chromoting_messages.h',
'host/constants.h',
@@ -576,6 +574,8 @@
'host/host_service_win.h',
'host/sas_injector.h',
'host/sas_injector_win.cc',
+ 'host/usage_stats_consent.h',
+ 'host/usage_stats_consent_win.cc',
'host/wts_console_monitor_win.h',
'host/wts_console_observer_win.h',
'host/wts_session_process_launcher_win.cc',
@@ -1345,12 +1345,12 @@
'sources': [
'host/branding.cc',
'host/branding.h',
- 'host/breakpad.h',
- 'host/breakpad_win.cc',
'host/host_event_logger.h',
'host/sighup_listener_mac.cc',
'host/sighup_listener_mac.h',
'host/remoting_me2me_host.cc',
+ 'host/usage_stats_consent.h',
+ 'host/usage_stats_consent_win.cc',
],
'conditions': [
['os_posix==1', {