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

Side by Side Diff: content/browser/trace_subscriber_stdio.cc

Issue 7207005: Style fix for member variable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 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 | « content/browser/trace_subscriber_stdio.h ('k') | no next file » | 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) 2011 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 #include "content/browser/trace_subscriber_stdio.h" 5 #include "content/browser/trace_subscriber_stdio.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 8
9 TraceSubscriberStdio::TraceSubscriberStdio(const FilePath& path) { 9 TraceSubscriberStdio::TraceSubscriberStdio(const FilePath& path) {
10 LOG(INFO) << "Logging performance trace to file: " << path.value(); 10 LOG(INFO) << "Logging performance trace to file: " << path.value();
11 m_file = file_util::OpenFile(path, "w+"); 11 file_ = file_util::OpenFile(path, "w+");
12 if (IsValid()) { 12 if (IsValid()) {
13 // FIXME: the file format expects it to start with "[". 13 // FIXME: the file format expects it to start with "[".
14 fputc('[', m_file); 14 fputc('[', file_);
15 } else { 15 } else {
16 LOG(ERROR) << "Failed to open performance trace file: " << path.value(); 16 LOG(ERROR) << "Failed to open performance trace file: " << path.value();
17 } 17 }
18 } 18 }
19 19
20 TraceSubscriberStdio::~TraceSubscriberStdio() { 20 TraceSubscriberStdio::~TraceSubscriberStdio() {
21 OnEndTracingComplete(); 21 OnEndTracingComplete();
22 } 22 }
23 23
24 bool TraceSubscriberStdio::IsValid() { 24 bool TraceSubscriberStdio::IsValid() {
25 return m_file && (0 == ferror(m_file)); 25 return file_ && (0 == ferror(file_));
26 } 26 }
27 27
28 void TraceSubscriberStdio::OnEndTracingComplete() { 28 void TraceSubscriberStdio::OnEndTracingComplete() {
29 if (m_file) { 29 if (file_) {
30 // FIXME: the file format expects it to end with "]". 30 // FIXME: the file format expects it to end with "]".
31 fputc(']', m_file); 31 fputc(']', file_);
32 fclose(m_file); 32 fclose(file_);
33 m_file = 0; 33 file_ = 0;
34 } 34 }
35 } 35 }
36 36
37 void TraceSubscriberStdio::OnTraceDataCollected( 37 void TraceSubscriberStdio::OnTraceDataCollected(
38 const std::string& json_events) { 38 const std::string& json_events) {
39 if (!IsValid()) { 39 if (!IsValid()) {
40 return; 40 return;
41 } 41 }
42 42
43 // FIXME: "json_events" currently comes with "[" and "]". But the file doesn't 43 // FIXME: "json_events" currently comes with "[" and "]". But the file doesn't
44 // expect them. So remove them when writing to the file. 44 // expect them. So remove them when writing to the file.
45 CHECK_GE(json_events.size(), 2u); 45 CHECK_GE(json_events.size(), 2u);
46 const char* data = json_events.data() + 1; 46 const char* data = json_events.data() + 1;
47 size_t size = json_events.size() - 2; 47 size_t size = json_events.size() - 2;
48 48
49 size_t written = fwrite(data, 1, size, m_file); 49 size_t written = fwrite(data, 1, size, file_);
50 if (written != size) { 50 if (written != size) {
51 LOG(ERROR) << "Error " << ferror(m_file) << " when writing to trace file"; 51 LOG(ERROR) << "Error " << ferror(file_) << " when writing to trace file";
52 fclose(m_file); 52 fclose(file_);
53 m_file = 0; 53 file_ = 0;
54 } else { 54 } else {
55 fputc(',', m_file); 55 fputc(',', file_);
56 } 56 }
57 } 57 }
OLDNEW
« no previous file with comments | « content/browser/trace_subscriber_stdio.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698