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

Side by Side Diff: chrome/common/metrics_helpers.cc

Issue 6273006: Added CHECK for buffer_ and xml_wrapper_ to be not NULL ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 11 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 | « no previous file | 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) 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 #include "chrome/common/metrics_helpers.h" 5 #include "chrome/common/metrics_helpers.h"
6 6
7 #if defined(USE_SYSTEM_LIBBZ2) 7 #if defined(USE_SYSTEM_LIBBZ2)
8 #include <bzlib.h> 8 #include <bzlib.h>
9 #else 9 #else
10 #include "third_party/bzip2/bzlib.h" 10 #include "third_party/bzip2/bzlib.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 } // namespace 46 } // namespace
47 47
48 class MetricsLogBase::XmlWrapper { 48 class MetricsLogBase::XmlWrapper {
49 public: 49 public:
50 XmlWrapper() 50 XmlWrapper()
51 : doc_(NULL), 51 : doc_(NULL),
52 buffer_(NULL), 52 buffer_(NULL),
53 writer_(NULL) { 53 writer_(NULL) {
54 buffer_ = xmlBufferCreate(); 54 buffer_ = xmlBufferCreate();
55 DCHECK(buffer_); 55 CHECK(buffer_);
56 56
57 #if defined(OS_CHROMEOS) 57 #if defined(OS_CHROMEOS)
58 writer_ = xmlNewTextWriterDoc(&doc_, /* compression */ 0); 58 writer_ = xmlNewTextWriterDoc(&doc_, /* compression */ 0);
59 #else 59 #else
60 writer_ = xmlNewTextWriterMemory(buffer_, /* compression */ 0); 60 writer_ = xmlNewTextWriterMemory(buffer_, /* compression */ 0);
61 #endif // OS_CHROMEOS 61 #endif // OS_CHROMEOS
62 DCHECK(writer_); 62 DCHECK(writer_);
63 63
64 int result = xmlTextWriterSetIndent(writer_, 2); 64 int result = xmlTextWriterSetIndent(writer_, 2);
65 DCHECK_EQ(0, result); 65 DCHECK_EQ(0, result);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 UMA_HISTOGRAM_TIMES("UMA.XMLNodeDumpTime", dump_timer.Elapsed()); 144 UMA_HISTOGRAM_TIMES("UMA.XMLNodeDumpTime", dump_timer.Elapsed());
145 145
146 PerfTimer free_timer; 146 PerfTimer free_timer;
147 xml_wrapper_->FreeDocWriter(); 147 xml_wrapper_->FreeDocWriter();
148 UMA_HISTOGRAM_TIMES("UMA.XMLWriterDestructionTime", free_timer.Elapsed()); 148 UMA_HISTOGRAM_TIMES("UMA.XMLWriterDestructionTime", free_timer.Elapsed());
149 #endif // OS_CHROMEOS 149 #endif // OS_CHROMEOS
150 } 150 }
151 151
152 int MetricsLogBase::GetEncodedLogSize() { 152 int MetricsLogBase::GetEncodedLogSize() {
153 DCHECK(locked_); 153 DCHECK(locked_);
154 CHECK(xml_wrapper_);
155 CHECK(xml_wrapper_->buffer());
154 return xml_wrapper_->buffer()->use; 156 return xml_wrapper_->buffer()->use;
155 } 157 }
156 158
157 bool MetricsLogBase::GetEncodedLog(char* buffer, int buffer_size) { 159 bool MetricsLogBase::GetEncodedLog(char* buffer, int buffer_size) {
158 DCHECK(locked_); 160 DCHECK(locked_);
159 if (buffer_size < GetEncodedLogSize()) 161 if (buffer_size < GetEncodedLogSize())
160 return false; 162 return false;
161 163
162 memcpy(buffer, xml_wrapper_->buffer()->content, GetEncodedLogSize()); 164 memcpy(buffer, xml_wrapper_->buffer()->content, GetEncodedLogSize());
163 return true; 165 return true;
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 snapshot.Subtract(*already_logged); 572 snapshot.Subtract(*already_logged);
571 } 573 }
572 574
573 // Snapshot now contains only a delta to what we've already_logged. 575 // Snapshot now contains only a delta to what we've already_logged.
574 if (snapshot.redundant_count() > 0) { 576 if (snapshot.redundant_count() > 0) {
575 TransmitHistogramDelta(histogram, snapshot); 577 TransmitHistogramDelta(histogram, snapshot);
576 // Add new data into our running total. 578 // Add new data into our running total.
577 already_logged->Add(snapshot); 579 already_logged->Add(snapshot);
578 } 580 }
579 } 581 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698