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 "chrome/browser/favicon/favicon_service.h" | 5 #include "chrome/browser/favicon/favicon_service.h" |
6 | 6 |
7 #include "base/hash.h" | |
7 #include "base/message_loop_proxy.h" | 8 #include "base/message_loop_proxy.h" |
8 #include "chrome/browser/favicon/favicon_util.h" | 9 #include "chrome/browser/favicon/favicon_util.h" |
9 #include "chrome/browser/history/history_backend.h" | 10 #include "chrome/browser/history/history_backend.h" |
10 #include "chrome/browser/history/history_service.h" | 11 #include "chrome/browser/history/history_service.h" |
11 #include "chrome/browser/history/history_service_factory.h" | 12 #include "chrome/browser/history/history_service_factory.h" |
12 #include "chrome/browser/history/select_favicon_frames.h" | 13 #include "chrome/browser/history/select_favicon_frames.h" |
13 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" | 14 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" |
14 #include "chrome/common/url_constants.h" | 15 #include "chrome/common/url_constants.h" |
15 #include "extensions/common/constants.h" | 16 #include "extensions/common/constants.h" |
16 #include "third_party/skia/include/core/SkBitmap.h" | 17 #include "third_party/skia/include/core/SkBitmap.h" |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
346 if (!gfx::PNGCodec::EncodeBGRASkBitmap(resized_image.AsBitmap(), false, | 347 if (!gfx::PNGCodec::EncodeBGRASkBitmap(resized_image.AsBitmap(), false, |
347 &resized_bitmap_data)) { | 348 &resized_bitmap_data)) { |
348 callback.Run(history::FaviconBitmapResult()); | 349 callback.Run(history::FaviconBitmapResult()); |
349 return; | 350 return; |
350 } | 351 } |
351 | 352 |
352 bitmap_result.bitmap_data = base::RefCountedBytes::TakeVector( | 353 bitmap_result.bitmap_data = base::RefCountedBytes::TakeVector( |
353 &resized_bitmap_data); | 354 &resized_bitmap_data); |
354 callback.Run(bitmap_result); | 355 callback.Run(bitmap_result); |
355 } | 356 } |
357 | |
358 void FaviconService::AddMissingFavicon(const GURL& icon_url) { | |
sky
2013/05/03 20:24:54
Order should match header.
mef
2013/05/03 21:45:59
Done.
| |
359 MissingFaviconURLHash url_hash = base::Hash(icon_url.spec()); | |
sky
2013/05/03 20:24:54
How likely are we to get false collisions?
mef
2013/05/03 21:45:59
With ideal Hash it should be 1/2**32 ~ 25*(10**-11
| |
360 missing_favicon_urls_.insert(url_hash); | |
361 } | |
362 | |
363 bool FaviconService::IsMissingFavicon(const GURL& icon_url) const { | |
364 MissingFaviconURLHash url_hash = base::Hash(icon_url.spec()); | |
365 return missing_favicon_urls_.find(url_hash) != missing_favicon_urls_.end(); | |
366 } | |
367 | |
368 void FaviconService::ClearMissingFavicons() { | |
369 missing_favicon_urls_.clear(); | |
370 } | |
371 | |
sky
2013/05/03 20:24:54
nit: nuke newlines.
mef
2013/05/03 21:45:59
Done.
| |
372 | |
OLD | NEW |