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

Side by Side Diff: chrome/app/chrome_main_delegate.cc

Issue 10908130: Revert 155122 - Code to collect issue 97285 debugging info for crash reports. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | content/browser/plugin_process_host.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/app/chrome_main_delegate.h" 5 #include "chrome/app/chrome_main_delegate.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/metrics/field_trial.h" 10 #include "base/metrics/field_trial.h"
(...skipping 12 matching lines...) Expand all
23 #include "chrome/common/chrome_paths_internal.h" 23 #include "chrome/common/chrome_paths_internal.h"
24 #include "chrome/common/chrome_switches.h" 24 #include "chrome/common/chrome_switches.h"
25 #include "chrome/common/chrome_version_info.h" 25 #include "chrome/common/chrome_version_info.h"
26 #include "chrome/common/logging_chrome.h" 26 #include "chrome/common/logging_chrome.h"
27 #include "chrome/common/profiling.h" 27 #include "chrome/common/profiling.h"
28 #include "chrome/common/url_constants.h" 28 #include "chrome/common/url_constants.h"
29 #include "chrome/plugin/chrome_content_plugin_client.h" 29 #include "chrome/plugin/chrome_content_plugin_client.h"
30 #include "chrome/renderer/chrome_content_renderer_client.h" 30 #include "chrome/renderer/chrome_content_renderer_client.h"
31 #include "chrome/utility/chrome_content_utility_client.h" 31 #include "chrome/utility/chrome_content_utility_client.h"
32 #include "content/public/common/content_client.h" 32 #include "content/public/common/content_client.h"
33 #include "content/public/common/content_debug_logging.h"
34 #include "content/public/common/content_paths.h" 33 #include "content/public/common/content_paths.h"
35 #include "content/public/common/content_switches.h" 34 #include "content/public/common/content_switches.h"
36 #include "ui/base/ui_base_switches.h" 35 #include "ui/base/ui_base_switches.h"
37 36
38 #if defined(OS_WIN) 37 #if defined(OS_WIN)
39 #include <algorithm> 38 #include <algorithm>
40 #include <atlbase.h> 39 #include <atlbase.h>
41 #include <malloc.h> 40 #include <malloc.h>
42 #include "base/string_util.h" 41 #include "base/string_util.h"
43 #include "base/win/registry.h" 42 #include "base/win/registry.h"
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 } 362 }
364 #endif 363 #endif
365 364
366 #endif // OS_POSIX 365 #endif // OS_POSIX
367 366
368 struct MainFunction { 367 struct MainFunction {
369 const char* name; 368 const char* name;
370 int (*function)(const content::MainFunctionParams&); 369 int (*function)(const content::MainFunctionParams&);
371 }; 370 };
372 371
373 // Limit message count and size to prevent rogue processes from
374 // bloating memory use.
375 const size_t kMaxBugMessages = 20;
376 const size_t kMaxMessageSize = 64;
377
378 // Locks g_messages.
379 static base::LazyInstance<base::Lock>::Leaky
380 g_messages_lock = LAZY_INSTANCE_INITIALIZER;
381
382 // Map bug ids to messages for that bug.
383 // TODO(shess): Would multimap<> maintain the items in order added?
384 base::LazyInstance<std::map<int, std::vector<std::string> > >
385 g_messages = LAZY_INSTANCE_INITIALIZER;
386
387 void RecordMsg(int bug_id, const std::string& msg) {
388 // Only record information about specific bugs to prevent rogue
389 // processes from bloating memory usage.
390 CHECK(bug_id == 97285 || bug_id == 141055);
391
392 // Make sure legitimate clients know that things are getting too big
393 // to handle.
394 DCHECK_LE(msg.size(), kMaxMessageSize);
395
396 base::AutoLock pin(g_messages_lock.Get());
397 std::vector<std::string>& bug_messages = g_messages.Get()[bug_id];
398 bug_messages.push_back(msg.substr(0, kMaxMessageSize));
399
400 // Should only remove a single item.
401 while (bug_messages.size() > kMaxBugMessages)
402 bug_messages.erase(bug_messages.begin());
403 }
404
405 bool GetMessages(int bug_id, std::vector<std::string>* msgs) {
406 CHECK(bug_id == 97285 || bug_id == 141055);
407
408 base::AutoLock pin(g_messages_lock.Get());
409 *msgs = g_messages.Get()[bug_id];
410 return !msgs->empty();
411 }
412
413 } // namespace 372 } // namespace
414 373
415 ChromeMainDelegate::ChromeMainDelegate() { 374 ChromeMainDelegate::ChromeMainDelegate() {
416 } 375 }
417 376
418 ChromeMainDelegate::~ChromeMainDelegate() { 377 ChromeMainDelegate::~ChromeMainDelegate() {
419 } 378 }
420 379
421 bool ChromeMainDelegate::BasicStartupComplete(int* exit_code) { 380 bool ChromeMainDelegate::BasicStartupComplete(int* exit_code) {
422 #if defined(OS_CHROMEOS) 381 #if defined(OS_CHROMEOS)
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 if (IsCrashReporterEnabled()) 518 if (IsCrashReporterEnabled())
560 InitCrashProcessInfo(); 519 InitCrashProcessInfo();
561 } 520 }
562 #endif // defined(OS_MACOSX) 521 #endif // defined(OS_MACOSX)
563 522
564 void ChromeMainDelegate::PreSandboxStartup() { 523 void ChromeMainDelegate::PreSandboxStartup() {
565 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 524 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
566 std::string process_type = 525 std::string process_type =
567 command_line.GetSwitchValueASCII(switches::kProcessType); 526 command_line.GetSwitchValueASCII(switches::kProcessType);
568 527
569 // TODO(shess): Could this be registered earlier?
570 if (process_type.empty())
571 content::debug::RegisterMessageHandlers(RecordMsg, GetMessages);
572
573 chrome::RegisterPathProvider(); 528 chrome::RegisterPathProvider();
574 529
575 #if defined(OS_MACOSX) 530 #if defined(OS_MACOSX)
576 // On the Mac, the child executable lives at a predefined location within 531 // On the Mac, the child executable lives at a predefined location within
577 // the app bundle's versioned directory. 532 // the app bundle's versioned directory.
578 PathService::Override(content::CHILD_PROCESS_EXE, 533 PathService::Override(content::CHILD_PROCESS_EXE,
579 chrome::GetVersionedDirectory(). 534 chrome::GetVersionedDirectory().
580 Append(chrome::kHelperProcessExecutablePath)); 535 Append(chrome::kHelperProcessExecutablePath));
581 536
582 InitMacCrashReporter(command_line, process_type); 537 InitMacCrashReporter(command_line, process_type);
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 716
762 content::ContentRendererClient* 717 content::ContentRendererClient*
763 ChromeMainDelegate::CreateContentRendererClient() { 718 ChromeMainDelegate::CreateContentRendererClient() {
764 return &g_chrome_content_renderer_client.Get(); 719 return &g_chrome_content_renderer_client.Get();
765 } 720 }
766 721
767 content::ContentUtilityClient* 722 content::ContentUtilityClient*
768 ChromeMainDelegate::CreateContentUtilityClient() { 723 ChromeMainDelegate::CreateContentUtilityClient() {
769 return &g_chrome_content_utility_client.Get(); 724 return &g_chrome_content_utility_client.Get();
770 } 725 }
OLDNEW
« no previous file with comments | « no previous file | content/browser/plugin_process_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698