| 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 "components/history/core/browser/history_backend.h" | 5 #include "components/history/core/browser/history_backend.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <functional> | 8 #include <functional> |
| 9 #include <list> | 9 #include <list> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 #include "components/history/core/browser/page_usage_data.h" | 37 #include "components/history/core/browser/page_usage_data.h" |
| 38 #include "components/history/core/browser/typed_url_syncable_service.h" | 38 #include "components/history/core/browser/typed_url_syncable_service.h" |
| 39 #include "components/history/core/browser/visit_filter.h" | 39 #include "components/history/core/browser/visit_filter.h" |
| 40 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 40 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| 41 #include "sql/error_delegate_util.h" | 41 #include "sql/error_delegate_util.h" |
| 42 #include "third_party/skia/include/core/SkBitmap.h" | 42 #include "third_party/skia/include/core/SkBitmap.h" |
| 43 #include "ui/gfx/codec/png_codec.h" | 43 #include "ui/gfx/codec/png_codec.h" |
| 44 #include "url/gurl.h" | 44 #include "url/gurl.h" |
| 45 #include "url/url_constants.h" | 45 #include "url/url_constants.h" |
| 46 | 46 |
| 47 #if defined(OS_IOS) |
| 48 #include "base/ios/scoped_critical_action.h" |
| 49 #endif |
| 50 |
| 47 using base::Time; | 51 using base::Time; |
| 48 using base::TimeDelta; | 52 using base::TimeDelta; |
| 49 using base::TimeTicks; | 53 using base::TimeTicks; |
| 50 | 54 |
| 51 /* The HistoryBackend consists of two components: | 55 /* The HistoryBackend consists of two components: |
| 52 | 56 |
| 53 HistoryDatabase (stores past 3 months of history) | 57 HistoryDatabase (stores past 3 months of history) |
| 54 URLDatabase (stores a list of URLs) | 58 URLDatabase (stores a list of URLs) |
| 55 DownloadDatabase (stores a list of downloads) | 59 DownloadDatabase (stores a list of downloads) |
| 56 VisitDatabase (stores a list of visits for the URLs) | 60 VisitDatabase (stores a list of visits for the URLs) |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 void HistoryBackend::Closing() { | 257 void HistoryBackend::Closing() { |
| 254 // Any scheduled commit will have a reference to us, we must make it | 258 // Any scheduled commit will have a reference to us, we must make it |
| 255 // release that reference before we can be destroyed. | 259 // release that reference before we can be destroyed. |
| 256 CancelScheduledCommit(); | 260 CancelScheduledCommit(); |
| 257 | 261 |
| 258 // Release our reference to the delegate, this reference will be keeping the | 262 // Release our reference to the delegate, this reference will be keeping the |
| 259 // history service alive. | 263 // history service alive. |
| 260 delegate_.reset(); | 264 delegate_.reset(); |
| 261 } | 265 } |
| 262 | 266 |
| 267 #if defined(OS_IOS) |
| 268 void HistoryBackend::PersistState() { |
| 269 Commit(); |
| 270 } |
| 271 #endif |
| 272 |
| 263 void HistoryBackend::ClearCachedDataForContextID(ContextID context_id) { | 273 void HistoryBackend::ClearCachedDataForContextID(ContextID context_id) { |
| 264 tracker_.ClearCachedDataForContextID(context_id); | 274 tracker_.ClearCachedDataForContextID(context_id); |
| 265 } | 275 } |
| 266 | 276 |
| 267 base::FilePath HistoryBackend::GetThumbnailFileName() const { | 277 base::FilePath HistoryBackend::GetThumbnailFileName() const { |
| 268 return history_dir_.Append(kThumbnailsFilename); | 278 return history_dir_.Append(kThumbnailsFilename); |
| 269 } | 279 } |
| 270 | 280 |
| 271 base::FilePath HistoryBackend::GetFaviconsFileName() const { | 281 base::FilePath HistoryBackend::GetFaviconsFileName() const { |
| 272 return history_dir_.Append(kFaviconsFilename); | 282 return history_dir_.Append(kFaviconsFilename); |
| (...skipping 1888 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2161 if (!redirect_list.empty()) { | 2171 if (!redirect_list.empty()) { |
| 2162 std::set<GURL> favicons_changed(redirect_list.begin(), redirect_list.end()); | 2172 std::set<GURL> favicons_changed(redirect_list.begin(), redirect_list.end()); |
| 2163 NotifyFaviconChanged(favicons_changed); | 2173 NotifyFaviconChanged(favicons_changed); |
| 2164 } | 2174 } |
| 2165 } | 2175 } |
| 2166 | 2176 |
| 2167 void HistoryBackend::Commit() { | 2177 void HistoryBackend::Commit() { |
| 2168 if (!db_) | 2178 if (!db_) |
| 2169 return; | 2179 return; |
| 2170 | 2180 |
| 2181 #if defined(OS_IOS) |
| 2182 // Attempts to get the application running long enough to commit the database |
| 2183 // transaction if it is currently being backgrounded. |
| 2184 base::ios::ScopedCriticalAction scoped_critical_action; |
| 2185 #endif |
| 2186 |
| 2171 // Note that a commit may not actually have been scheduled if a caller | 2187 // Note that a commit may not actually have been scheduled if a caller |
| 2172 // explicitly calls this instead of using ScheduleCommit. Likewise, we | 2188 // explicitly calls this instead of using ScheduleCommit. Likewise, we |
| 2173 // may reset the flag written by a pending commit. But this is OK! It | 2189 // may reset the flag written by a pending commit. But this is OK! It |
| 2174 // will merely cause extra commits (which is kind of the idea). We | 2190 // will merely cause extra commits (which is kind of the idea). We |
| 2175 // could optimize more for this case (we may get two extra commits in | 2191 // could optimize more for this case (we may get two extra commits in |
| 2176 // some cases) but it hasn't been important yet. | 2192 // some cases) but it hasn't been important yet. |
| 2177 CancelScheduledCommit(); | 2193 CancelScheduledCommit(); |
| 2178 | 2194 |
| 2179 db_->CommitTransaction(); | 2195 db_->CommitTransaction(); |
| 2180 DCHECK(db_->transaction_nesting() == 0) << "Somebody left a transaction open"; | 2196 DCHECK(db_->transaction_nesting() == 0) << "Somebody left a transaction open"; |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2645 info.url_id = visit.url_id; | 2661 info.url_id = visit.url_id; |
| 2646 info.time = visit.visit_time; | 2662 info.time = visit.visit_time; |
| 2647 info.transition = visit.transition; | 2663 info.transition = visit.transition; |
| 2648 // If we don't have a delegate yet during setup or shutdown, we will drop | 2664 // If we don't have a delegate yet during setup or shutdown, we will drop |
| 2649 // these notifications. | 2665 // these notifications. |
| 2650 if (delegate_) | 2666 if (delegate_) |
| 2651 delegate_->NotifyAddVisit(info); | 2667 delegate_->NotifyAddVisit(info); |
| 2652 } | 2668 } |
| 2653 | 2669 |
| 2654 } // namespace history | 2670 } // namespace history |
| OLD | NEW |