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

Side by Side Diff: chrome/browser/android/crash_dump_manager.cc

Issue 11884042: Fix for a crasher when starting a renderer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed unneeded header. Created 7 years, 11 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
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/browser/android/crash_dump_manager.h" 5 #include "chrome/browser/android/crash_dump_manager.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/path_service.h" 11 #include "base/path_service.h"
12 #include "base/posix/global_descriptors.h" 12 #include "base/posix/global_descriptors.h"
13 #include "base/process.h" 13 #include "base/process.h"
14 #include "base/rand_util.h" 14 #include "base/rand_util.h"
15 #include "base/stl_util.h" 15 #include "base/stl_util.h"
16 #include "base/stringprintf.h" 16 #include "base/stringprintf.h"
17 #include "chrome/common/chrome_paths.h" 17 #include "chrome/common/chrome_paths.h"
18 #include "chrome/common/descriptors_android.h" 18 #include "chrome/common/descriptors_android.h"
19 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
20 #include "content/public/browser/child_process_data.h" 20 #include "content/public/browser/child_process_data.h"
21 #include "content/public/browser/file_descriptor_info.h" 21 #include "content/public/browser/file_descriptor_info.h"
22 #include "content/public/browser/notification_service.h" 22 #include "content/public/browser/notification_service.h"
23 #include "content/public/browser/notification_types.h" 23 #include "content/public/browser/notification_types.h"
24 #include "content/public/browser/render_process_host.h" 24 #include "content/public/browser/render_process_host.h"
25 25
26 using content::BrowserThread; 26 using content::BrowserThread;
27 27
28 // static
29 CrashDumpManager* CrashDumpManager::instance_ = NULL;
30
31 // static
32 CrashDumpManager* CrashDumpManager::GetInstance() {
33 return instance_;
34 }
35
28 CrashDumpManager::CrashDumpManager() { 36 CrashDumpManager::CrashDumpManager() {
29 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 37 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
38 DCHECK(!instance_);
39
40 instance_ = this;
41
30 notification_registrar_.Add(this, 42 notification_registrar_.Add(this,
31 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, 43 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED,
32 content::NotificationService::AllSources()); 44 content::NotificationService::AllSources());
33 notification_registrar_.Add(this, 45 notification_registrar_.Add(this,
34 content::NOTIFICATION_RENDERER_PROCESS_CLOSED, 46 content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
35 content::NotificationService::AllSources()); 47 content::NotificationService::AllSources());
36 notification_registrar_.Add(this, 48 notification_registrar_.Add(this,
37 content::NOTIFICATION_CHILD_PROCESS_HOST_DISCONNECTED, 49 content::NOTIFICATION_CHILD_PROCESS_HOST_DISCONNECTED,
38 content::NotificationService::AllSources()); 50 content::NotificationService::AllSources());
39 notification_registrar_.Add(this, 51 notification_registrar_.Add(this,
40 content::NOTIFICATION_CHILD_PROCESS_CRASHED, 52 content::NOTIFICATION_CHILD_PROCESS_CRASHED,
41 content::NotificationService::AllSources()); 53 content::NotificationService::AllSources());
42 } 54 }
43 55
44 CrashDumpManager::~CrashDumpManager() { 56 CrashDumpManager::~CrashDumpManager() {
jam 2013/01/15 20:36:26 nit: reset here?
45 } 57 }
46 58
47 int CrashDumpManager::CreateMinidumpFile(int child_process_id) { 59 int CrashDumpManager::CreateMinidumpFile(int child_process_id) {
48 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::PROCESS_LAUNCHER)); 60 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::PROCESS_LAUNCHER));
49 FilePath minidump_path; 61 FilePath minidump_path;
50 if (!file_util::CreateTemporaryFile(&minidump_path)) 62 if (!file_util::CreateTemporaryFile(&minidump_path))
51 return base::kInvalidPlatformFileValue; 63 return base::kInvalidPlatformFileValue;
52 64
53 base::PlatformFileError error; 65 base::PlatformFileError error;
54 // We need read permission as the minidump is generated in several phases 66 // We need read permission as the minidump is generated in several phases
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 // NOTIFICATION_RENDERER_PROCESS_CLOSED. 162 // NOTIFICATION_RENDERER_PROCESS_CLOSED.
151 return; 163 return;
152 } 164 }
153 minidump_path = iter->second; 165 minidump_path = iter->second;
154 child_process_id_to_minidump_path_.erase(iter); 166 child_process_id_to_minidump_path_.erase(iter);
155 } 167 }
156 BrowserThread::PostTask( 168 BrowserThread::PostTask(
157 BrowserThread::FILE, FROM_HERE, 169 BrowserThread::FILE, FROM_HERE,
158 base::Bind(&CrashDumpManager::ProcessMinidump, minidump_path, pid)); 170 base::Bind(&CrashDumpManager::ProcessMinidump, minidump_path, pid));
159 } 171 }
OLDNEW
« no previous file with comments | « chrome/browser/android/crash_dump_manager.h ('k') | chrome/browser/chrome_browser_main_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698