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/visitedlink/visitedlink_master.h" | 5 #include "chrome/browser/visitedlink/visitedlink_master.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <io.h> | 9 #include <io.h> |
10 #include <shlobj.h> | 10 #include <shlobj.h> |
11 #endif // defined(OS_WIN) | 11 #endif // defined(OS_WIN) |
12 #include <stdio.h> | 12 #include <stdio.h> |
13 | 13 |
14 #include <algorithm> | 14 #include <algorithm> |
15 | 15 |
16 #include "base/bind.h" | 16 #include "base/bind.h" |
17 #include "base/bind_helpers.h" | 17 #include "base/bind_helpers.h" |
| 18 #include "base/containers/stack_container.h" |
18 #include "base/file_util.h" | 19 #include "base/file_util.h" |
19 #include "base/logging.h" | 20 #include "base/logging.h" |
20 #include "base/message_loop.h" | 21 #include "base/message_loop.h" |
21 #include "base/path_service.h" | 22 #include "base/path_service.h" |
22 #include "base/process_util.h" | 23 #include "base/process_util.h" |
23 #include "base/rand_util.h" | 24 #include "base/rand_util.h" |
24 #include "base/stack_container.h" | |
25 #include "base/string_util.h" | 25 #include "base/string_util.h" |
26 #include "base/threading/thread_restrictions.h" | 26 #include "base/threading/thread_restrictions.h" |
27 #include "chrome/browser/history/history.h" | 27 #include "chrome/browser/history/history.h" |
28 #include "chrome/browser/history/history_service_factory.h" | 28 #include "chrome/browser/history/history_service_factory.h" |
29 #include "chrome/browser/profiles/profile.h" | 29 #include "chrome/browser/profiles/profile.h" |
30 #include "chrome/browser/visitedlink/visitedlink_event_listener.h" | 30 #include "chrome/browser/visitedlink/visitedlink_event_listener.h" |
31 #include "content/public/browser/browser_thread.h" | 31 #include "content/public/browser/browser_thread.h" |
32 | 32 |
33 using content::BrowserThread; | 33 using content::BrowserThread; |
34 using file_util::ScopedFILE; | 34 using file_util::ScopedFILE; |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 break; // We wrapped around and the whole table is full. | 451 break; // We wrapped around and the whole table is full. |
452 if (!hash_table_[next_hash]) | 452 if (!hash_table_[next_hash]) |
453 break; // Found the last spot. | 453 break; // Found the last spot. |
454 end_range = next_hash; | 454 end_range = next_hash; |
455 } | 455 } |
456 | 456 |
457 // We could get all fancy and move the affected fingerprints around, but | 457 // We could get all fancy and move the affected fingerprints around, but |
458 // instead we just remove them all and re-add them (minus our deleted one). | 458 // instead we just remove them all and re-add them (minus our deleted one). |
459 // This will mean there's a small window of time where the affected links | 459 // This will mean there's a small window of time where the affected links |
460 // won't be marked visited. | 460 // won't be marked visited. |
461 StackVector<Fingerprint, 32> shuffled_fingerprints; | 461 base::StackVector<Fingerprint, 32> shuffled_fingerprints; |
462 Hash stop_loop = IncrementHash(end_range); // The end range is inclusive. | 462 Hash stop_loop = IncrementHash(end_range); // The end range is inclusive. |
463 for (Hash i = deleted_hash; i != stop_loop; i = IncrementHash(i)) { | 463 for (Hash i = deleted_hash; i != stop_loop; i = IncrementHash(i)) { |
464 if (hash_table_[i] != fingerprint) { | 464 if (hash_table_[i] != fingerprint) { |
465 // Don't save the one we're deleting! | 465 // Don't save the one we're deleting! |
466 shuffled_fingerprints->push_back(hash_table_[i]); | 466 shuffled_fingerprints->push_back(hash_table_[i]); |
467 | 467 |
468 // This will balance the increment of this value in AddFingerprint below | 468 // This will balance the increment of this value in AddFingerprint below |
469 // so there is no net change. | 469 // so there is no net change. |
470 used_items_--; | 470 used_items_--; |
471 } | 471 } |
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
978 } | 978 } |
979 | 979 |
980 void VisitedLinkMaster::TableBuilder::OnCompleteMainThread() { | 980 void VisitedLinkMaster::TableBuilder::OnCompleteMainThread() { |
981 if (master_) | 981 if (master_) |
982 master_->OnTableRebuildComplete(success_, fingerprints_); | 982 master_->OnTableRebuildComplete(success_, fingerprints_); |
983 | 983 |
984 // WILL (generally) DELETE THIS! This balances the AddRef in | 984 // WILL (generally) DELETE THIS! This balances the AddRef in |
985 // VisitedLinkMaster::RebuildTableFromHistory. | 985 // VisitedLinkMaster::RebuildTableFromHistory. |
986 Release(); | 986 Release(); |
987 } | 987 } |
OLD | NEW |