OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/history/history_backend.h" | 5 #include "chrome/browser/history/history_backend.h" |
6 | 6 |
7 #include <list> | 7 #include <list> |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
| 12 #include "base/command_line.h" |
12 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
13 #include "base/file_util.h" | 14 #include "base/file_util.h" |
14 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
15 #include "base/memory/scoped_vector.h" | 16 #include "base/memory/scoped_vector.h" |
16 #include "base/message_loop.h" | 17 #include "base/message_loop.h" |
17 #include "base/metrics/histogram.h" | 18 #include "base/metrics/histogram.h" |
18 #include "base/string_util.h" | 19 #include "base/string_util.h" |
19 #include "base/time.h" | 20 #include "base/time.h" |
20 #include "chrome/browser/autocomplete/history_url_provider.h" | 21 #include "chrome/browser/autocomplete/history_url_provider.h" |
21 #include "chrome/browser/bookmarks/bookmark_service.h" | 22 #include "chrome/browser/bookmarks/bookmark_service.h" |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 backend_destroy_message_loop_(NULL), | 211 backend_destroy_message_loop_(NULL), |
211 backend_destroy_task_(NULL), | 212 backend_destroy_task_(NULL), |
212 segment_queried_(false), | 213 segment_queried_(false), |
213 bookmark_service_(bookmark_service) { | 214 bookmark_service_(bookmark_service) { |
214 } | 215 } |
215 | 216 |
216 HistoryBackend::~HistoryBackend() { | 217 HistoryBackend::~HistoryBackend() { |
217 DCHECK(!scheduled_commit_) << "Deleting without cleanup"; | 218 DCHECK(!scheduled_commit_) << "Deleting without cleanup"; |
218 ReleaseDBTasks(); | 219 ReleaseDBTasks(); |
219 | 220 |
220 // Close the databases before optionally running the "destroy" task. | 221 // First close the databases before optionally running the "destroy" task. |
221 if (db_.get()) { | 222 if (db_.get()) { |
222 // Commit the long-running transaction. | 223 // Commit the long-running transaction. |
223 db_->CommitTransaction(); | 224 db_->CommitTransaction(); |
224 db_.reset(); | 225 db_.reset(); |
225 } | 226 } |
226 if (thumbnail_db_.get()) { | 227 if (thumbnail_db_.get()) { |
227 thumbnail_db_->CommitTransaction(); | 228 thumbnail_db_->CommitTransaction(); |
228 thumbnail_db_.reset(); | 229 thumbnail_db_.reset(); |
229 } | 230 } |
230 if (archived_db_.get()) { | 231 if (archived_db_.get()) { |
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
877 } | 878 } |
878 | 879 |
879 bool typed_url_changed = false; | 880 bool typed_url_changed = false; |
880 std::vector<URLRow> changed_urls; | 881 std::vector<URLRow> changed_urls; |
881 for (size_t i = 0; i < redirects->size(); i++) { | 882 for (size_t i = 0; i < redirects->size(); i++) { |
882 URLRow row; | 883 URLRow row; |
883 URLID row_id = db_->GetRowForURL(redirects->at(i), &row); | 884 URLID row_id = db_->GetRowForURL(redirects->at(i), &row); |
884 if (row_id && row.title() != title) { | 885 if (row_id && row.title() != title) { |
885 row.set_title(title); | 886 row.set_title(title); |
886 db_->UpdateURLRow(row_id, row); | 887 db_->UpdateURLRow(row_id, row); |
887 row.id_ = row_id; | |
888 changed_urls.push_back(row); | 888 changed_urls.push_back(row); |
889 if (row.typed_count() > 0) | 889 if (row.typed_count() > 0) |
890 typed_url_changed = true; | 890 typed_url_changed = true; |
891 } | 891 } |
892 } | 892 } |
893 | 893 |
894 // Broadcast notifications for typed URLs that have changed. This will | 894 // Broadcast notifications for typed URLs that have changed. This will |
895 // update the in-memory database. | 895 // update the in-memory database. |
896 // | 896 // |
897 // TODO(brettw) bug 1140020: Broadcast for all changes (not just typed), | 897 // TODO(brettw) bug 1140020: Broadcast for all changes (not just typed), |
(...skipping 1418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2316 break; | 2316 break; |
2317 } | 2317 } |
2318 } | 2318 } |
2319 } | 2319 } |
2320 UMA_HISTOGRAM_TIMES("History.GetFavIconFromDB", // historical name | 2320 UMA_HISTOGRAM_TIMES("History.GetFavIconFromDB", // historical name |
2321 TimeTicks::Now() - beginning_time); | 2321 TimeTicks::Now() - beginning_time); |
2322 return success; | 2322 return success; |
2323 } | 2323 } |
2324 | 2324 |
2325 } // namespace history | 2325 } // namespace history |
OLD | NEW |