OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/histogram_synchronizer.h" | 5 #include "content/browser/histogram_synchronizer.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
11 #include "base/pickle.h" | |
11 #include "base/threading/thread.h" | 12 #include "base/threading/thread.h" |
12 #include "base/threading/thread_restrictions.h" | 13 #include "base/threading/thread_restrictions.h" |
13 #include "content/browser/histogram_controller.h" | 14 #include "content/browser/histogram_controller.h" |
14 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
15 #include "content/public/browser/histogram_fetcher.h" | 16 #include "content/public/browser/histogram_fetcher.h" |
16 #include "content/public/common/content_constants.h" | 17 #include "content/public/common/content_constants.h" |
17 | 18 |
18 using base::Time; | 19 using base::Time; |
19 using base::TimeDelta; | 20 using base::TimeDelta; |
20 using base::TimeTicks; | 21 using base::TimeTicks; |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
265 void HistogramSynchronizer::OnHistogramDataCollected( | 266 void HistogramSynchronizer::OnHistogramDataCollected( |
266 int sequence_number, | 267 int sequence_number, |
267 const std::vector<std::string>& pickled_histograms) { | 268 const std::vector<std::string>& pickled_histograms) { |
268 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 269 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
269 | 270 |
270 RequestContext* request = RequestContext::GetRequestContext(sequence_number); | 271 RequestContext* request = RequestContext::GetRequestContext(sequence_number); |
271 | 272 |
272 for (std::vector<std::string>::const_iterator it = pickled_histograms.begin(); | 273 for (std::vector<std::string>::const_iterator it = pickled_histograms.begin(); |
273 it < pickled_histograms.end(); | 274 it < pickled_histograms.end(); |
274 ++it) { | 275 ++it) { |
275 base::Histogram::DeserializeHistogramInfo(*it); | 276 Pickle pickle(it->data(), it->size()); |
277 PickleIterator iter(pickle); | |
278 base::HistogramBase* histogram = | |
279 base::HistogramBase::DeserializeHistogramInfo(&iter); | |
280 if (histogram) { | |
Ilya Sherman
2012/12/29 00:17:30
Optional nit: IMO it's tidier to write "if (!histo
kaiwang
2013/01/08 00:51:40
Done.
| |
281 if (histogram->flags() & | |
282 base::HistogramBase::kIPCSerializationSourceFlag) { | |
283 DVLOG(1) << "Single process mode, histogram observed and not copied: " | |
284 << histogram->histogram_name(); | |
285 } else { | |
286 histogram->AddSamplesFromPickle(&iter); | |
Ilya Sherman
2012/12/29 00:17:30
Why isn't this done as part of DeserializeHistogra
kaiwang
2013/01/08 00:51:40
IMO
1. histogram is in base/, so it should know no
Ilya Sherman
2013/01/08 22:31:53
But it already does know about inter-process commu
| |
287 } | |
288 } | |
276 } | 289 } |
277 | 290 |
278 if (!request) | 291 if (!request) |
279 return; | 292 return; |
280 | 293 |
281 // Delete request if we have heard back from all child processes. | 294 // Delete request if we have heard back from all child processes. |
282 request->DecrementProcessesPending(); | 295 request->DecrementProcessesPending(); |
283 request->DeleteIfAllDone(); | 296 request->DeleteIfAllDone(); |
284 } | 297 } |
285 | 298 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
336 kHistogramSynchronizerReservedSequenceNumber + 1; | 349 kHistogramSynchronizerReservedSequenceNumber + 1; |
337 } | 350 } |
338 DCHECK_NE(last_used_sequence_number_, | 351 DCHECK_NE(last_used_sequence_number_, |
339 kHistogramSynchronizerReservedSequenceNumber); | 352 kHistogramSynchronizerReservedSequenceNumber); |
340 if (requester == ASYNC_HISTOGRAMS) | 353 if (requester == ASYNC_HISTOGRAMS) |
341 async_sequence_number_ = last_used_sequence_number_; | 354 async_sequence_number_ = last_used_sequence_number_; |
342 return last_used_sequence_number_; | 355 return last_used_sequence_number_; |
343 } | 356 } |
344 | 357 |
345 } // namespace content | 358 } // namespace content |
OLD | NEW |