OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_TRACE_SUBSCRIBER_STDIO_H_ | 5 #ifndef CONTENT_BROWSER_TRACE_SUBSCRIBER_STDIO_H_ |
6 #define CONTENT_BROWSER_TRACE_SUBSCRIBER_STDIO_H_ | 6 #define CONTENT_BROWSER_TRACE_SUBSCRIBER_STDIO_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
12 #include "content/browser/trace_controller.h" | 12 #include "content/browser/trace_controller.h" |
13 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
14 | 14 |
15 namespace content { | |
16 | |
17 class TraceSubscriberStdioImpl; | |
18 | |
19 // Stdio implementation of TraceSubscriber. Use this to write traces to a file. | 15 // Stdio implementation of TraceSubscriber. Use this to write traces to a file. |
20 class CONTENT_EXPORT TraceSubscriberStdio : public TraceSubscriber { | 16 class CONTENT_EXPORT TraceSubscriberStdio : public TraceSubscriber { |
21 public: | 17 public: |
| 18 TraceSubscriberStdio(); |
22 // Creates or overwrites the specified file. Check IsValid() for success. | 19 // Creates or overwrites the specified file. Check IsValid() for success. |
23 explicit TraceSubscriberStdio(const FilePath& path); | 20 explicit TraceSubscriberStdio(const FilePath& path); |
24 virtual ~TraceSubscriberStdio(); | 21 |
| 22 // Creates or overwrites the specified file. Returns true on success. |
| 23 bool OpenFile(const FilePath& path); |
| 24 // Finishes json output and closes file. |
| 25 void CloseFile(); |
| 26 |
| 27 // Returns TRUE if we're currently writing data to a file. |
| 28 bool IsValid(); |
25 | 29 |
26 // Implementation of TraceSubscriber | 30 // Implementation of TraceSubscriber |
27 virtual void OnEndTracingComplete() OVERRIDE; | 31 virtual void OnEndTracingComplete() OVERRIDE; |
28 virtual void OnTraceDataCollected( | 32 virtual void OnTraceDataCollected(const std::string& trace_fragment) OVERRIDE; |
29 const scoped_refptr<base::RefCountedString>& data_ptr) OVERRIDE; | 33 |
| 34 virtual ~TraceSubscriberStdio(); |
30 | 35 |
31 private: | 36 private: |
32 scoped_refptr<TraceSubscriberStdioImpl> impl_; | 37 void Write(const std::string& output_str); |
| 38 |
| 39 FILE* file_; |
| 40 base::debug::TraceResultBuffer trace_buffer_; |
33 }; | 41 }; |
34 | 42 |
35 } // namespace content | |
36 | |
37 #endif // CONTENT_BROWSER_TRACE_SUBSCRIBER_STDIO_H_ | 43 #endif // CONTENT_BROWSER_TRACE_SUBSCRIBER_STDIO_H_ |
OLD | NEW |