Fix HistogramTester::GetAllSamples when empty.

Fix GetAllSamples to return an empty vector when the histogram has no
samples, instead of crashing.

BUG=

Review URL: https://codereview.chromium.org/1265403003

Cr-Commit-Position: refs/heads/master@{#342634}


CrOS-Libchrome-Original-Commit: 36a9d6f54d27a5a093b8520a4015e8ec1a7c06bd
diff --git a/base/test/histogram_tester.cc b/base/test/histogram_tester.cc
index 051f599..09b4ef3 100644
--- a/base/test/histogram_tester.cc
+++ b/base/test/histogram_tester.cc
@@ -79,11 +79,13 @@
   std::vector<Bucket> samples;
   scoped_ptr<HistogramSamples> snapshot =
       GetHistogramSamplesSinceCreation(name);
-  for (auto it = snapshot->Iterator(); !it->Done(); it->Next()) {
-    HistogramBase::Sample sample;
-    HistogramBase::Count count;
-    it->Get(&sample, nullptr, &count);
-    samples.push_back(Bucket(sample, count));
+  if (snapshot) {
+    for (auto it = snapshot->Iterator(); !it->Done(); it->Next()) {
+      HistogramBase::Sample sample;
+      HistogramBase::Count count;
+      it->Get(&sample, nullptr, &count);
+      samples.push_back(Bucket(sample, count));
+    }
   }
   return samples;
 }