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

Side by Side Diff: net/disk_cache/stress_cache.cc

Issue 3945002: Move debug-related stuff from base to the base/debug directory and use the... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 2 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 | « net/base/host_resolver_impl.cc ('k') | net/socket/socks5_client_socket.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 // This is a simple application that stress-tests the crash recovery of the disk 5 // This is a simple application that stress-tests the crash recovery of the disk
6 // cache. The main application starts a copy of itself on a loop, checking the 6 // cache. The main application starts a copy of itself on a loop, checking the
7 // exit code of the child process. When the child dies in an unexpected way, 7 // exit code of the child process. When the child dies in an unexpected way,
8 // the main application quits. 8 // the main application quits.
9 9
10 // The child application has two threads: one to exercise the cache in an 10 // The child application has two threads: one to exercise the cache in an
11 // infinite loop, and another one to asynchronously kill the process. 11 // infinite loop, and another one to asynchronously kill the process.
12 12
13 // A regular build should never crash. 13 // A regular build should never crash.
14 // To test that the disk cache doesn't generate critical errors with regular 14 // To test that the disk cache doesn't generate critical errors with regular
15 // application level crashes, add the following code and re-compile: 15 // application level crashes, add the following code and re-compile:
16 // 16 //
17 // void BackendImpl::CriticalError(int error) { 17 // void BackendImpl::CriticalError(int error) {
18 // NOTREACHED(); 18 // NOTREACHED();
19 // 19 //
20 // void BackendImpl::ReportError(int error) { 20 // void BackendImpl::ReportError(int error) {
21 // if (error && error != ERR_PREVIOUS_CRASH) { 21 // if (error && error != ERR_PREVIOUS_CRASH) {
22 // NOTREACHED(); 22 // NOTREACHED();
23 // } 23 // }
24 24
25 #include <string> 25 #include <string>
26 #include <vector> 26 #include <vector>
27 27
28 #include "base/at_exit.h" 28 #include "base/at_exit.h"
29 #include "base/command_line.h" 29 #include "base/command_line.h"
30 #include "base/debug_util.h" 30 #include "base/debug/debugger.h"
31 #include "base/file_path.h" 31 #include "base/file_path.h"
32 #include "base/logging.h" 32 #include "base/logging.h"
33 #include "base/message_loop.h" 33 #include "base/message_loop.h"
34 #include "base/path_service.h" 34 #include "base/path_service.h"
35 #include "base/platform_thread.h" 35 #include "base/platform_thread.h"
36 #include "base/process_util.h" 36 #include "base/process_util.h"
37 #include "base/string_number_conversions.h" 37 #include "base/string_number_conversions.h"
38 #include "base/string_util.h" 38 #include "base/string_util.h"
39 #include "base/thread.h" 39 #include "base/thread.h"
40 #include "base/utf_string_conversions.h" 40 #include "base/utf_string_conversions.h"
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 base::Thread* thread = new base::Thread("party_crasher"); 206 base::Thread* thread = new base::Thread("party_crasher");
207 if (!thread->Start()) 207 if (!thread->Start())
208 return false; 208 return false;
209 209
210 CrashTask::RunSoon(thread->message_loop()); 210 CrashTask::RunSoon(thread->message_loop());
211 return true; 211 return true;
212 } 212 }
213 213
214 void CrashHandler(const std::string& str) { 214 void CrashHandler(const std::string& str) {
215 g_crashing = true; 215 g_crashing = true;
216 DebugUtil::BreakDebugger(); 216 base::debug::BreakDebugger();
217 } 217 }
218 218
219 // ----------------------------------------------------------------------- 219 // -----------------------------------------------------------------------
220 220
221 int main(int argc, const char* argv[]) { 221 int main(int argc, const char* argv[]) {
222 // Setup an AtExitManager so Singleton objects will be destructed. 222 // Setup an AtExitManager so Singleton objects will be destructed.
223 base::AtExitManager at_exit_manager; 223 base::AtExitManager at_exit_manager;
224 224
225 if (argc < 2) 225 if (argc < 2)
226 return MasterCode(); 226 return MasterCode();
227 227
228 logging::SetLogAssertHandler(CrashHandler); 228 logging::SetLogAssertHandler(CrashHandler);
229 229
230 // Some time for the memory manager to flush stuff. 230 // Some time for the memory manager to flush stuff.
231 PlatformThread::Sleep(3000); 231 PlatformThread::Sleep(3000);
232 MessageLoop message_loop(MessageLoop::TYPE_IO); 232 MessageLoop message_loop(MessageLoop::TYPE_IO);
233 233
234 char* end; 234 char* end;
235 long int iteration = strtol(argv[1], &end, 0); 235 long int iteration = strtol(argv[1], &end, 0);
236 236
237 if (!StartCrashThread()) { 237 if (!StartCrashThread()) {
238 printf("failed to start thread\n"); 238 printf("failed to start thread\n");
239 return kError; 239 return kError;
240 } 240 }
241 241
242 StressTheCache(iteration); 242 StressTheCache(iteration);
243 return 0; 243 return 0;
244 } 244 }
OLDNEW
« no previous file with comments | « net/base/host_resolver_impl.cc ('k') | net/socket/socks5_client_socket.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698