OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/browser/safe_browsing/safe_browsing_util.h" | 5 #include "chrome/browser/safe_browsing/safe_browsing_util.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/hmac.h" | 8 #include "base/hmac.h" |
9 #include "base/sha2.h" | 9 #include "base/sha2.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 | 104 |
105 int SBEntry::Size() const { | 105 int SBEntry::Size() const { |
106 return Size(type(), prefix_count()); | 106 return Size(type(), prefix_count()); |
107 } | 107 } |
108 | 108 |
109 // static | 109 // static |
110 int SBEntry::Size(Type type, int prefix_count) { | 110 int SBEntry::Size(Type type, int prefix_count) { |
111 return sizeof(Data) + prefix_count * PrefixSize(type); | 111 return sizeof(Data) + prefix_count * PrefixSize(type); |
112 } | 112 } |
113 | 113 |
114 SBEntry* SBEntry::Enlarge(int extra_prefixes) { | |
115 int new_prefix_count = prefix_count() + extra_prefixes; | |
116 SBEntry* rv = SBEntry::Create(type(), new_prefix_count); | |
117 memcpy(rv, this, Size()); // NOTE: Blows away rv.data_! | |
118 // We have to re-set |rv|'s prefix count since we just copied our own over it. | |
119 rv->set_prefix_count(new_prefix_count); | |
120 Destroy(); | |
121 return rv; | |
122 } | |
123 | |
124 int SBEntry::ChunkIdAtPrefix(int index) const { | 114 int SBEntry::ChunkIdAtPrefix(int index) const { |
125 if (type() == SUB_PREFIX) | 115 if (type() == SUB_PREFIX) |
126 return sub_prefixes_[index].add_chunk; | 116 return sub_prefixes_[index].add_chunk; |
127 return (type() == SUB_FULL_HASH) ? | 117 return (type() == SUB_FULL_HASH) ? |
128 sub_full_hashes_[index].add_chunk : chunk_id(); | 118 sub_full_hashes_[index].add_chunk : chunk_id(); |
129 } | 119 } |
130 | 120 |
131 void SBEntry::SetChunkIdAtPrefix(int index, int chunk_id) { | 121 void SBEntry::SetChunkIdAtPrefix(int index, int chunk_id) { |
132 DCHECK(IsSub()); | 122 DCHECK(IsSub()); |
133 | 123 |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 std::string client_name("googlechrome"); | 497 std::string client_name("googlechrome"); |
508 #endif | 498 #endif |
509 | 499 |
510 GURL report_url(report_page + | 500 GURL report_url(report_page + |
511 StringPrintf(kReportParams, client_name.c_str(), continue_esc.c_str(), | 501 StringPrintf(kReportParams, client_name.c_str(), continue_esc.c_str(), |
512 current_esc.c_str())); | 502 current_esc.c_str())); |
513 return google_util::AppendGoogleLocaleParam(report_url); | 503 return google_util::AppendGoogleLocaleParam(report_url); |
514 } | 504 } |
515 | 505 |
516 } // namespace safe_browsing_util | 506 } // namespace safe_browsing_util |
OLD | NEW |