diff options
author | lambroslambrou@chromium.org <lambroslambrou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-30 02:46:13 +0000 |
---|---|---|
committer | lambroslambrou@chromium.org <lambroslambrou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-30 02:46:13 +0000 |
commit | 831d8d69b132e8e0f1b065ddc574c58a0815b9de (patch) | |
tree | 41610ee42378975015c55042b74b5924082fa9da /remoting | |
parent | b2136f12808223e1fd3bc07606b131daed359ba0 (diff) | |
download | chromium_src-831d8d69b132e8e0f1b065ddc574c58a0815b9de.zip chromium_src-831d8d69b132e8e0f1b065ddc574c58a0815b9de.tar.gz chromium_src-831d8d69b132e8e0f1b065ddc574c58a0815b9de.tar.bz2 |
Mac Breakpad integration for Chromoting Host (disabled for now)
This adds Breakpad initialization, and the necessary Breakpad
components to the Me2Me host bundle.
Tested by tweaking the code to enable Breakpad, and to upload to
a test server instead of the production URL.
BUG=136579
Review URL: https://chromiumcodereview.appspot.com/11308267
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@170369 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r-- | remoting/base/breakpad_mac.mm | 59 | ||||
-rw-r--r-- | remoting/host/remoting_me2me_host-Info.plist | 4 | ||||
-rw-r--r-- | remoting/host/remoting_me2me_host.cc | 12 | ||||
-rw-r--r-- | remoting/host/usage_stats_consent_mac.cc | 33 | ||||
-rw-r--r-- | remoting/remoting.gyp | 20 |
5 files changed, 123 insertions, 5 deletions
diff --git a/remoting/base/breakpad_mac.mm b/remoting/base/breakpad_mac.mm index 84cba44..abc2159 100644 --- a/remoting/base/breakpad_mac.mm +++ b/remoting/base/breakpad_mac.mm @@ -4,11 +4,66 @@ #include "remoting/base/breakpad.h" +#include <Foundation/Foundation.h> + +#include "base/logging.h" +#import "base/mac/scoped_nsautorelease_pool.h" +#import "breakpad/src/client/mac/Framework/Breakpad.h" + namespace remoting { void InitializeCrashReporting() { - // TODO(alexeypa) Implement crash dump collection on Mac; see - // http://crbug.com/130678. + base::mac::ScopedNSAutoreleasePool autorelease_pool; + + NSBundle* main_bundle = [NSBundle mainBundle]; + + // Tell Breakpad where crash_inspector and crash_report_sender are. + NSString* resource_path = [main_bundle resourcePath]; + NSString* inspector_location = + [resource_path stringByAppendingPathComponent:@"crash_inspector"]; + NSString* reporter_bundle_location = + [resource_path stringByAppendingPathComponent:@"crash_report_sender.app"]; + NSString* reporter_location = + [[NSBundle bundleWithPath:reporter_bundle_location] executablePath]; + + NSDictionary* info_dictionary = [main_bundle infoDictionary]; + NSMutableDictionary* breakpad_config = + [[info_dictionary mutableCopy] autorelease]; + [breakpad_config setObject:inspector_location + forKey:@BREAKPAD_INSPECTOR_LOCATION]; + [breakpad_config setObject:reporter_location + forKey:@BREAKPAD_REPORTER_EXE_LOCATION]; + + // Configure Breakpad settings here, if they are not already customized in + // the Info.plist. These settings should be added to the plist, but the + // problem is that the Breakpad URL contains a double-slash, which is broken + // by the INFOPLIST_PREPROCESS step. + // TODO(lambroslambrou): Add these to the Info.plist, similarly to what is + // done for Chrome Framework - see 'Tweak Info.plist' in + // chrome/chrome_dll_bundle.gypi. + if (![breakpad_config objectForKey:@BREAKPAD_SKIP_CONFIRM]) { + // Skip the upload confirmation dialog, since this is a remote-access + // service that shouldn't rely on a console user to dismiss any prompt. + // Also, this may be running in the LoginWindow context, where prompting + // might not be possible. + [breakpad_config setObject:@"YES" + forKey:@BREAKPAD_SKIP_CONFIRM]; + } + if (![breakpad_config objectForKey:@BREAKPAD_REPORT_INTERVAL]) { + // Set a minimum 6-hour interval between crash-reports, to match the + // throttling used on Windows. + [breakpad_config setObject:@"21600" + forKey:@BREAKPAD_REPORT_INTERVAL]; + } + if (![breakpad_config objectForKey:@BREAKPAD_URL]) { + // TODO(lambroslambrou): Use the production URL once permission is granted. + [breakpad_config setObject:@"https://clients2.google.com/cr/staging_report" + forKey:@BREAKPAD_URL]; + } + + if (!BreakpadCreate(breakpad_config)) { + LOG(ERROR) << "Breakpad initialization failed"; + } } } // namespace remoting diff --git a/remoting/host/remoting_me2me_host-Info.plist b/remoting/host/remoting_me2me_host-Info.plist index 3a294ea..3887f22 100644 --- a/remoting/host/remoting_me2me_host-Info.plist +++ b/remoting/host/remoting_me2me_host-Info.plist @@ -28,5 +28,9 @@ <string>COPYRIGHT_INFO</string> <key>LSUIElement</key> <string>1</string> + <key>BreakpadProduct</key> + <string>Chromoting_Mac</string> + <key>BreakpadVersion</key> + <string>VERSION_FULL</string> </dict> </plist> diff --git a/remoting/host/remoting_me2me_host.cc b/remoting/host/remoting_me2me_host.cc index 773f4bb..3b98715 100644 --- a/remoting/host/remoting_me2me_host.cc +++ b/remoting/host/remoting_me2me_host.cc @@ -1043,6 +1043,16 @@ int main(int argc, char** argv) { CommandLine::Init(argc, argv); + // Initialize Breakpad as early as possible. On Windows, this happens in + // WinMain(), so it shouldn't also be done here. The command-line needs to be + // initialized first, so that the preference for crash-reporting can be looked + // up in the config file. +#if defined(MAC_BREAKPAD) + if (remoting::IsUsageStatsAllowed()) { + remoting::InitializeCrashReporting(); + } +#endif // MAC_BREAKPAD + // This object instance is required by Chrome code (for example, // LazyInstance, MessageLoop). base::AtExitManager exit_manager; @@ -1094,7 +1104,7 @@ int CALLBACK WinMain(HINSTANCE instance, HINSTANCE previous_instance, LPSTR command_line, int show_command) { -#ifdef OFFICIAL_BUILD +#if defined(OFFICIAL_BUILD) if (remoting::IsUsageStatsAllowed()) { remoting::InitializeCrashReporting(); } diff --git a/remoting/host/usage_stats_consent_mac.cc b/remoting/host/usage_stats_consent_mac.cc new file mode 100644 index 0000000..f256415 --- /dev/null +++ b/remoting/host/usage_stats_consent_mac.cc @@ -0,0 +1,33 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "remoting/host/usage_stats_consent.h" + +#include <string> + +#include "base/logging.h" + +namespace remoting { + +bool GetUsageStatsConsent(bool* allowed, bool* set_by_policy) { + *set_by_policy = false; + + // For now, leave Breakpad disabled. + // TODO(lambroslambrou): Enable it for users who have given consent. + *allowed = false; + return true; +} + +bool IsUsageStatsAllowed() { + bool allowed; + bool set_by_policy; + return GetUsageStatsConsent(&allowed, &set_by_policy) && allowed; +} + +bool SetUsageStatsConsent(bool allowed) { + NOTIMPLEMENTED(); + return false; +} + +} // namespace remoting diff --git a/remoting/remoting.gyp b/remoting/remoting.gyp index 5b47447..eef4607 100644 --- a/remoting/remoting.gyp +++ b/remoting/remoting.gyp @@ -957,6 +957,11 @@ 'base/breakpad_win.cc', ], 'conditions': [ + ['OS=="mac"', { + 'dependencies': [ + '../breakpad/breakpad.gyp:breakpad', + ], + }], ['OS=="win"', { 'dependencies': [ '../breakpad/breakpad.gyp:breakpad_handler', @@ -1649,6 +1654,7 @@ 'host/url_request_context.cc', 'host/url_request_context.h', 'host/usage_stats_consent.h', + 'host/usage_stats_consent_mac.cc', 'host/usage_stats_consent_win.cc', 'host/video_frame.cc', 'host/video_frame.h', @@ -1843,9 +1849,19 @@ # A real .dSYM is needed for dump_syms to operate on. 'mac_real_dsym': 1, }, - }], + 'defines': ['MAC_BREAKPAD'], + 'copies': [ + { + 'destination': '<(PRODUCT_DIR)/$(CONTENTS_FOLDER_PATH)/Resources', + 'files': [ + '<(PRODUCT_DIR)/crash_inspector', + '<(PRODUCT_DIR)/crash_report_sender.app' + ], + }, + ], + }], # mac_breakpad==1 ], # conditions - }], + }], # OS=mac ['OS=="win"', { 'product_name': 'remoting_host', 'dependencies': [ |