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

Side by Side Diff: components/metrics/serialization/serialization_utils.cc

Issue 1159883003: Substituting pattern ScopedVector push_back(ptr.release()) with push_back(ptr.Pass()) in components… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « components/metrics/metrics_service.cc ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/metrics/serialization/serialization_utils.h" 5 #include "components/metrics/serialization/serialization_utils.h"
6 6
7 #include <sys/file.h> 7 #include <sys/file.h>
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 // This processes all messages in the log. When all messages are 145 // This processes all messages in the log. When all messages are
146 // read and processed, or an error occurs, truncate the file to zero size. 146 // read and processed, or an error occurs, truncate the file to zero size.
147 for (;;) { 147 for (;;) {
148 std::string message; 148 std::string message;
149 149
150 if (!ReadMessage(fd.get(), &message)) 150 if (!ReadMessage(fd.get(), &message))
151 break; 151 break;
152 152
153 scoped_ptr<MetricSample> sample = ParseSample(message); 153 scoped_ptr<MetricSample> sample = ParseSample(message);
154 if (sample) 154 if (sample)
155 metrics->push_back(sample.release()); 155 metrics->push_back(sample.Pass());
156 } 156 }
157 157
158 result = ftruncate(fd.get(), 0); 158 result = ftruncate(fd.get(), 0);
159 if (result < 0) 159 if (result < 0)
160 DPLOG(ERROR) << "truncate metrics log: " << filename; 160 DPLOG(ERROR) << "truncate metrics log: " << filename;
161 161
162 result = flock(fd.get(), LOCK_UN); 162 result = flock(fd.get(), LOCK_UN);
163 if (result < 0) 163 if (result < 0)
164 DPLOG(ERROR) << "unlock metrics log: " << filename; 164 DPLOG(ERROR) << "unlock metrics log: " << filename;
165 } 165 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 if (!base::WriteFileDescriptor( 206 if (!base::WriteFileDescriptor(
207 file_descriptor.get(), msg.c_str(), msg.size())) { 207 file_descriptor.get(), msg.c_str(), msg.size())) {
208 DPLOG(ERROR) << "error writing message: " << filename; 208 DPLOG(ERROR) << "error writing message: " << filename;
209 return false; 209 return false;
210 } 210 }
211 211
212 return true; 212 return true;
213 } 213 }
214 214
215 } // namespace metrics 215 } // namespace metrics
OLDNEW
« no previous file with comments | « components/metrics/metrics_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698