OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/precache/core/precache_fetcher.h" | 5 #include "components/precache/core/precache_fetcher.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 int Initialize(const net::CompletionCallback& callback) override { | 145 int Initialize(const net::CompletionCallback& callback) override { |
146 return net::OK; | 146 return net::OK; |
147 } | 147 } |
148 | 148 |
149 int Write(net::IOBuffer* buffer, | 149 int Write(net::IOBuffer* buffer, |
150 int num_bytes, | 150 int num_bytes, |
151 const net::CompletionCallback& callback) override { | 151 const net::CompletionCallback& callback) override { |
152 return num_bytes; | 152 return num_bytes; |
153 } | 153 } |
154 | 154 |
155 int Finish(const net::CompletionCallback& callback) override { | 155 int Finish(int net_error, const net::CompletionCallback& callback) override { |
156 return net::OK; | 156 return net::OK; |
157 } | 157 } |
158 }; | 158 }; |
159 | 159 |
160 // Returns the base64 encoded resource URL hashes. The resource URLs are hashed | 160 // Returns the base64 encoded resource URL hashes. The resource URLs are hashed |
161 // individually, and 8 bytes of each hash is appended together, which is then | 161 // individually, and 8 bytes of each hash is appended together, which is then |
162 // encoded to base64. | 162 // encoded to base64. |
163 std::string GetResourceURLBase64Hash(const std::vector<GURL>& urls) { | 163 std::string GetResourceURLBase64Hash(const std::vector<GURL>& urls) { |
164 // Each resource hash uses 8 bytes, instead of the 20 bytes of sha1 hash, as a | 164 // Each resource hash uses 8 bytes, instead of the 20 bytes of sha1 hash, as a |
165 // tradeoff between sending more bytes and reducing hash collisions. | 165 // tradeoff between sending more bytes and reducing hash collisions. |
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 remaining = 0; | 764 remaining = 0; |
765 quota_.set_remaining( | 765 quota_.set_remaining( |
766 used_bytes > quota_.remaining() ? 0U : quota_.remaining() - used_bytes); | 766 used_bytes > quota_.remaining() ? 0U : quota_.remaining() - used_bytes); |
767 db_task_runner_->PostTask( | 767 db_task_runner_->PostTask( |
768 FROM_HERE, | 768 FROM_HERE, |
769 base::Bind(&PrecacheDatabase::SaveQuota, precache_database_, quota_)); | 769 base::Bind(&PrecacheDatabase::SaveQuota, precache_database_, quota_)); |
770 } | 770 } |
771 } | 771 } |
772 | 772 |
773 } // namespace precache | 773 } // namespace precache |
OLD | NEW |