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

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

Issue 16950028: Move file_util::Delete to the base namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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 | « base/win/event_trace_controller_unittest.cc ('k') | chrome/browser/browser_shutdown.cc » ('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/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"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 void CrashDumpManager::ProcessMinidump(const base::FilePath& minidump_path, 84 void CrashDumpManager::ProcessMinidump(const base::FilePath& minidump_path,
85 base::ProcessHandle pid) { 85 base::ProcessHandle pid) {
86 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 86 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
87 int64 file_size = 0; 87 int64 file_size = 0;
88 int r = file_util::GetFileSize(minidump_path, &file_size); 88 int r = file_util::GetFileSize(minidump_path, &file_size);
89 DCHECK(r) << "Failed to retrieve size for minidump " 89 DCHECK(r) << "Failed to retrieve size for minidump "
90 << minidump_path.value(); 90 << minidump_path.value();
91 91
92 if (file_size == 0) { 92 if (file_size == 0) {
93 // Empty minidump, this process did not crash. Just remove the file. 93 // Empty minidump, this process did not crash. Just remove the file.
94 r = file_util::Delete(minidump_path, false); 94 r = base::Delete(minidump_path, false);
95 DCHECK(r) << "Failed to delete temporary minidump file " 95 DCHECK(r) << "Failed to delete temporary minidump file "
96 << minidump_path.value(); 96 << minidump_path.value();
97 return; 97 return;
98 } 98 }
99 99
100 // We are dealing with a valid minidump. Copy it to the crash report 100 // We are dealing with a valid minidump. Copy it to the crash report
101 // directory from where Java code will upload it later on. 101 // directory from where Java code will upload it later on.
102 base::FilePath crash_dump_dir; 102 base::FilePath crash_dump_dir;
103 r = PathService::Get(chrome::DIR_CRASH_DUMPS, &crash_dump_dir); 103 r = PathService::Get(chrome::DIR_CRASH_DUMPS, &crash_dump_dir);
104 if (!r) { 104 if (!r) {
105 NOTREACHED() << "Failed to retrieve the crash dump directory."; 105 NOTREACHED() << "Failed to retrieve the crash dump directory.";
106 return; 106 return;
107 } 107 }
108 108
109 const uint64 rand = base::RandUint64(); 109 const uint64 rand = base::RandUint64();
110 const std::string filename = 110 const std::string filename =
111 base::StringPrintf("chromium-renderer-minidump-%016" PRIx64 ".dmp%d", 111 base::StringPrintf("chromium-renderer-minidump-%016" PRIx64 ".dmp%d",
112 rand, pid); 112 rand, pid);
113 base::FilePath dest_path = crash_dump_dir.Append(filename); 113 base::FilePath dest_path = crash_dump_dir.Append(filename);
114 r = file_util::Move(minidump_path, dest_path); 114 r = file_util::Move(minidump_path, dest_path);
115 if (!r) { 115 if (!r) {
116 LOG(ERROR) << "Failed to move crash dump from " << minidump_path.value() 116 LOG(ERROR) << "Failed to move crash dump from " << minidump_path.value()
117 << " to " << dest_path.value(); 117 << " to " << dest_path.value();
118 file_util::Delete(minidump_path, false); 118 base::Delete(minidump_path, false);
119 return; 119 return;
120 } 120 }
121 LOG(INFO) << "Crash minidump successfully generated: " << 121 LOG(INFO) << "Crash minidump successfully generated: " <<
122 crash_dump_dir.Append(filename).value(); 122 crash_dump_dir.Append(filename).value();
123 } 123 }
124 124
125 void CrashDumpManager::BrowserChildProcessHostDisconnected( 125 void CrashDumpManager::BrowserChildProcessHostDisconnected(
126 const content::ChildProcessData& data) { 126 const content::ChildProcessData& data) {
127 OnChildExit(data.id, data.handle); 127 OnChildExit(data.id, data.handle);
128 } 128 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 // NOTIFICATION_RENDERER_PROCESS_CLOSED. 164 // NOTIFICATION_RENDERER_PROCESS_CLOSED.
165 return; 165 return;
166 } 166 }
167 minidump_path = iter->second; 167 minidump_path = iter->second;
168 child_process_id_to_minidump_path_.erase(iter); 168 child_process_id_to_minidump_path_.erase(iter);
169 } 169 }
170 BrowserThread::PostTask( 170 BrowserThread::PostTask(
171 BrowserThread::FILE, FROM_HERE, 171 BrowserThread::FILE, FROM_HERE,
172 base::Bind(&CrashDumpManager::ProcessMinidump, minidump_path, pid)); 172 base::Bind(&CrashDumpManager::ProcessMinidump, minidump_path, pid));
173 } 173 }
OLDNEW
« no previous file with comments | « base/win/event_trace_controller_unittest.cc ('k') | chrome/browser/browser_shutdown.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698