| OLD | NEW | 
|---|
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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 <limits.h> | 5 #include <limits.h> | 
| 6 #include <stdint.h> | 6 #include <stdint.h> | 
| 7 | 7 | 
| 8 #include "base/timer/timer.h" | 8 #include "base/timer/timer.h" | 
| 9 #include "chrome/browser/browsing_data/history_counter.h" | 9 #include "chrome/browser/browsing_data/history_counter.h" | 
| 10 #include "chrome/browser/history/history_service_factory.h" | 10 #include "chrome/browser/history/history_service_factory.h" | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
| 21 HistoryCounter::HistoryCounter() : pref_name_(prefs::kDeleteBrowsingHistory), | 21 HistoryCounter::HistoryCounter() : pref_name_(prefs::kDeleteBrowsingHistory), | 
| 22                                    has_synced_visits_(false), | 22                                    has_synced_visits_(false), | 
| 23                                    local_counting_finished_(false), | 23                                    local_counting_finished_(false), | 
| 24                                    web_counting_finished_(false), | 24                                    web_counting_finished_(false), | 
| 25                                    testing_web_history_service_(nullptr) { | 25                                    testing_web_history_service_(nullptr) { | 
| 26 } | 26 } | 
| 27 | 27 | 
| 28 HistoryCounter::~HistoryCounter() { | 28 HistoryCounter::~HistoryCounter() { | 
| 29 } | 29 } | 
| 30 | 30 | 
| 31 // Note that the local counting done by |VisitDatabase::GetHistoryCount| |  | 
| 32 // returns an int, which is at most a signed 64-bit number. On the other hand, |  | 
| 33 // ResultInt is an unsigned 64-bit number, so the range 2^63..2^64-1 is unused |  | 
| 34 // and we can use it to encode special values. |  | 
| 35 // static |  | 
| 36 const BrowsingDataCounter::ResultInt HistoryCounter::kOnlySyncedHistory = |  | 
| 37     std::numeric_limits<BrowsingDataCounter::ResultInt>::max(); |  | 
| 38 COMPILE_ASSERT( |  | 
| 39     std::numeric_limits<int>::digits < |  | 
| 40         std::numeric_limits<BrowsingDataCounter::ResultInt>::digits, |  | 
| 41     "BrowsingDataCounter::ResultInt must be wider than int."); |  | 
| 42 |  | 
| 43 const std::string& HistoryCounter::GetPrefName() const { | 31 const std::string& HistoryCounter::GetPrefName() const { | 
| 44   return pref_name_; | 32   return pref_name_; | 
| 45 } | 33 } | 
| 46 | 34 | 
| 47 bool HistoryCounter::HasTrackedTasks() { | 35 bool HistoryCounter::HasTrackedTasks() { | 
| 48   return cancelable_task_tracker_.HasTrackedTasks(); | 36   return cancelable_task_tracker_.HasTrackedTasks(); | 
| 49 } | 37 } | 
| 50 | 38 | 
| 51 void HistoryCounter::SetWebHistoryServiceForTesting( | 39 void HistoryCounter::SetWebHistoryServiceForTesting( | 
| 52     history::WebHistoryService* service) { | 40     history::WebHistoryService* service) { | 
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 154   web_history_request_.reset(); | 142   web_history_request_.reset(); | 
| 155   has_synced_visits_ = true; | 143   has_synced_visits_ = true; | 
| 156   web_counting_finished_ = true; | 144   web_counting_finished_ = true; | 
| 157   MergeResults(); | 145   MergeResults(); | 
| 158 } | 146 } | 
| 159 | 147 | 
| 160 void HistoryCounter::MergeResults() { | 148 void HistoryCounter::MergeResults() { | 
| 161   if (!local_counting_finished_ || !web_counting_finished_) | 149   if (!local_counting_finished_ || !web_counting_finished_) | 
| 162     return; | 150     return; | 
| 163 | 151 | 
| 164   if (!local_result_ && has_synced_visits_) | 152   ReportResult(make_scoped_ptr(new HistoryResult( | 
| 165     ReportResult(kOnlySyncedHistory); | 153       this, local_result_, has_synced_visits_))); | 
| 166   else |  | 
| 167     ReportResult(local_result_); |  | 
| 168 } | 154 } | 
|  | 155 | 
|  | 156 HistoryCounter::HistoryResult::HistoryResult( | 
|  | 157     const HistoryCounter* source, | 
|  | 158     ResultInt value, | 
|  | 159     bool has_synced_visits) | 
|  | 160     : FinishedResult(source, value), | 
|  | 161       has_synced_visits_(has_synced_visits) { | 
|  | 162 } | 
|  | 163 | 
|  | 164 HistoryCounter::HistoryResult::~HistoryResult() { | 
|  | 165 } | 
| OLD | NEW | 
|---|