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

Side by Side Diff: content/browser/browser_shutdown_profile_dumper.h

Issue 24047007: Fix --trace-shutdown with thread-local tracing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #ifndef CONTENT_BROWSER_BROWSER_SHUTDOWN_PROFILE_DUMPER_H_ 5 #ifndef CONTENT_BROWSER_BROWSER_SHUTDOWN_PROFILE_DUMPER_H_
6 #define CONTENT_BROWSER_BROWSER_SHUTDOWN_PROFILE_DUMPER_H_ 6 #define CONTENT_BROWSER_BROWSER_SHUTDOWN_PROFILE_DUMPER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/ref_counted_memory.h" 12 #include "base/memory/ref_counted_memory.h"
13 #include "content/common/content_export.h" 13 #include "content/common/content_export.h"
14 14
15 namespace base { 15 namespace base {
16 class FilePath; 16 class FilePath;
17 class WaitableEvent;
17 } 18 }
18 19
19 namespace content { 20 namespace content {
20 21
21 // This class is intended to dump the tracing results of the shutdown process 22 // This class is intended to dump the tracing results of the shutdown process
22 // to a file before the browser process exits. 23 // to a file before the browser process exits.
23 // It will save the file either into the command line passed 24 // It will save the file either into the command line passed
24 // "--trace-shutdown-file=<name>" parameter - or - to "chrometrace.log" in the 25 // "--trace-shutdown-file=<name>" parameter - or - to "chrometrace.log" in the
25 // current directory. 26 // current directory.
26 // Use the class with a scoped_ptr to get files written in the destructor. 27 // Use the class with a scoped_ptr to get files written in the destructor.
27 // Note that we cannot use the asynchronous file writer since the 28 // Note that we cannot use the asynchronous file writer since the
28 // |SequencedWorkerPool| will get killed in the shutdown process. 29 // |SequencedWorkerPool| will get killed in the shutdown process.
29 class BrowserShutdownProfileDumper { 30 class BrowserShutdownProfileDumper {
30 public: 31 public:
31 BrowserShutdownProfileDumper(); 32 BrowserShutdownProfileDumper();
32 33
33 ~BrowserShutdownProfileDumper(); 34 ~BrowserShutdownProfileDumper();
34 35
35 private: 36 private:
36 // Writes all traces which happened to disk. 37 // Writes all traces which happened to disk.
37 void WriteTracesToDisc(const base::FilePath& file_name); 38 void WriteTracesToDisc(const base::FilePath& file_name);
38 39
40 void EndTraceAndFlush(base::WaitableEvent* flush_complete_event);
41
39 // Returns the file name where we should save the trace dump to. 42 // Returns the file name where we should save the trace dump to.
40 base::FilePath GetFileName(); 43 base::FilePath GetFileName();
41 44
42 // The callback for the |TraceLog::Flush| function. It saves all traces to 45 // The callback for the |TraceLog::Flush| function. It saves all traces to
43 // disc. 46 // disc.
44 void WriteTraceDataCollected( 47 void WriteTraceDataCollected(
48 base::WaitableEvent* flush_complete_event,
45 const scoped_refptr<base::RefCountedString>& events_str, 49 const scoped_refptr<base::RefCountedString>& events_str,
46 bool has_more_events); 50 bool has_more_events);
47 51
48 // Returns true if the dump file is valid. 52 // Returns true if the dump file is valid.
49 bool IsFileValid(); 53 bool IsFileValid();
50 54
51 // Writes a string to the dump file. 55 // Writes a string to the dump file.
52 void WriteString(const std::string& string); 56 void WriteString(const std::string& string);
53 57
54 // Write a buffer to the dump file. 58 // Write a buffer to the dump file.
55 void WriteChars(const char* chars, size_t size); 59 void WriteChars(const char* chars, size_t size);
56 60
57 // Closes the dump file. 61 // Closes the dump file.
58 void CloseFile(); 62 void CloseFile();
59 63
60 // The number of blocks we have already written. 64 // The number of blocks we have already written.
61 int blocks_; 65 int blocks_;
62 // For dumping the content to disc. 66 // For dumping the content to disc.
63 FILE* dump_file_; 67 FILE* dump_file_;
64 68
65 DISALLOW_COPY_AND_ASSIGN(BrowserShutdownProfileDumper); 69 DISALLOW_COPY_AND_ASSIGN(BrowserShutdownProfileDumper);
66 }; 70 };
67 71
68 } // namespace content 72 } // namespace content
69 73
70 #endif // CONTENT_BROWSER_BROWSER_SHUTDOWN_PROFILE_DUMPER_H_ 74 #endif // CONTENT_BROWSER_BROWSER_SHUTDOWN_PROFILE_DUMPER_H_
OLDNEW
« no previous file with comments | « base/threading/thread_restrictions.h ('k') | content/browser/browser_shutdown_profile_dumper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698