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

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

Issue 8418034: Make string_util::WriteInto() DCHECK() that the supplied |length_with_null| > 1, meaning that the... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years 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 | « chrome/browser/ui/views/omnibox/omnibox_view_win.cc ('k') | chrome/common/time_format.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) 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 "chrome/common/metrics_log_manager.h" 5 #include "chrome/common/metrics_log_manager.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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 DCHECK(log_serializer_.get()); 98 DCHECK(log_serializer_.get());
99 if (!log_serializer_.get()) 99 if (!log_serializer_.get())
100 return; 100 return;
101 log_serializer_->DeserializeLogs(INITIAL_LOG, &unsent_initial_logs_); 101 log_serializer_->DeserializeLogs(INITIAL_LOG, &unsent_initial_logs_);
102 log_serializer_->DeserializeLogs(ONGOING_LOG, &unsent_ongoing_logs_); 102 log_serializer_->DeserializeLogs(ONGOING_LOG, &unsent_ongoing_logs_);
103 } 103 }
104 104
105 void MetricsLogManager::CompressStagedLog() { 105 void MetricsLogManager::CompressStagedLog() {
106 int text_size = staged_log_->GetEncodedLogSize(); 106 int text_size = staged_log_->GetEncodedLogSize();
107 std::string staged_log_text; 107 std::string staged_log_text;
108 // Leave room for the NULL terminator. 108 DCHECK_GT(text_size, 0);
109 staged_log_->GetEncodedLog(WriteInto(&staged_log_text, text_size + 1), 109 staged_log_->GetEncodedLog(WriteInto(&staged_log_text, text_size + 1),
110 text_size); 110 text_size);
111 111
112 bool success = Bzip2Compress(staged_log_text, &compressed_staged_log_text_); 112 bool success = Bzip2Compress(staged_log_text, &compressed_staged_log_text_);
113 if (success) { 113 if (success) {
114 // Allow security-conscious users to see all metrics logs that we send. 114 // Allow security-conscious users to see all metrics logs that we send.
115 DVLOG(1) << "METRICS LOG: " << staged_log_text; 115 DVLOG(1) << "METRICS LOG: " << staged_log_text;
116 } else { 116 } else {
117 NOTREACHED() << "Failed to compress log for transmission."; 117 NOTREACHED() << "Failed to compress log for transmission.";
118 } 118 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 // TODO(jar): See if it would be better to do a CHECK() here. 153 // TODO(jar): See if it would be better to do a CHECK() here.
154 return false; 154 return false;
155 } 155 }
156 result = BZ2_bzCompressEnd(&stream); 156 result = BZ2_bzCompressEnd(&stream);
157 DCHECK(result == BZ_OK); 157 DCHECK(result == BZ_OK);
158 158
159 output->resize(stream.total_out_lo32); 159 output->resize(stream.total_out_lo32);
160 160
161 return true; 161 return true;
162 } 162 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/omnibox/omnibox_view_win.cc ('k') | chrome/common/time_format.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698