| 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 "components/safe_browsing_db/prefix_set.h" | 5 #include "components/safe_browsing_db/prefix_set.h" |
| 6 | 6 |
| 7 #include <limits.h> | 7 #include <limits.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
| 13 #include "base/files/scoped_file.h" | 13 #include "base/files/scoped_file.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/md5.h" | 15 #include "base/md5.h" |
| 16 #include "base/memory/ptr_util.h" | 16 #include "base/memory/ptr_util.h" |
| 17 #include "base/metrics/histogram.h" | 17 #include "base/metrics/histogram.h" |
| 18 #include "base/metrics/sparse_histogram.h" | 18 #include "base/metrics/histogram_macros.h" |
| 19 | 19 |
| 20 namespace safe_browsing { | 20 namespace safe_browsing { |
| 21 | 21 |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| 24 // |kMagic| should be reasonably unique, and not match itself across | 24 // |kMagic| should be reasonably unique, and not match itself across |
| 25 // endianness changes. I generated this value with: | 25 // endianness changes. I generated this value with: |
| 26 // md5 -qs chrome/browser/safe_browsing/prefix_set.cc | colrm 9 | 26 // md5 -qs chrome/browser/safe_browsing/prefix_set.cc | colrm 9 |
| 27 static uint32_t kMagic = 0x864088dd; | 27 static uint32_t kMagic = 0x864088dd; |
| 28 | 28 |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 } | 444 } |
| 445 buffer_.push_back(prefix); | 445 buffer_.push_back(prefix); |
| 446 | 446 |
| 447 // Flush buffer when a run can be constructed. +1 for the index item, and +1 | 447 // Flush buffer when a run can be constructed. +1 for the index item, and +1 |
| 448 // to leave at least one item in the buffer for dropping duplicates. | 448 // to leave at least one item in the buffer for dropping duplicates. |
| 449 if (buffer_.size() > PrefixSet::kMaxRun + 2) | 449 if (buffer_.size() > PrefixSet::kMaxRun + 2) |
| 450 EmitRun(); | 450 EmitRun(); |
| 451 } | 451 } |
| 452 | 452 |
| 453 } // namespace safe_browsing | 453 } // namespace safe_browsing |
| OLD | NEW |