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" | |
13 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
14 #include "base/file_util.h" | 13 #include "base/file_util.h" |
15 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
16 #include "base/memory/scoped_vector.h" | 15 #include "base/memory/scoped_vector.h" |
17 #include "base/message_loop.h" | 16 #include "base/message_loop.h" |
18 #include "base/metrics/histogram.h" | 17 #include "base/metrics/histogram.h" |
19 #include "base/string_util.h" | 18 #include "base/string_util.h" |
20 #include "base/time.h" | 19 #include "base/time.h" |
21 #include "chrome/browser/autocomplete/history_url_provider.h" | 20 #include "chrome/browser/autocomplete/history_url_provider.h" |
22 #include "chrome/browser/bookmarks/bookmark_service.h" | 21 #include "chrome/browser/bookmarks/bookmark_service.h" |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
204 Delegate* delegate, | 203 Delegate* delegate, |
205 BookmarkService* bookmark_service) | 204 BookmarkService* bookmark_service) |
206 : delegate_(delegate), | 205 : delegate_(delegate), |
207 id_(id), | 206 id_(id), |
208 history_dir_(history_dir), | 207 history_dir_(history_dir), |
209 ALLOW_THIS_IN_INITIALIZER_LIST(expirer_(this, bookmark_service)), | 208 ALLOW_THIS_IN_INITIALIZER_LIST(expirer_(this, bookmark_service)), |
210 recent_redirects_(kMaxRedirectCount), | 209 recent_redirects_(kMaxRedirectCount), |
211 backend_destroy_message_loop_(NULL), | 210 backend_destroy_message_loop_(NULL), |
212 backend_destroy_task_(NULL), | 211 backend_destroy_task_(NULL), |
213 segment_queried_(false), | 212 segment_queried_(false), |
214 bookmark_service_(bookmark_service) { | 213 bookmark_service_(bookmark_service) {} |
Peter Kasting
2011/11/21 19:07:50
Nit: I normally prefer the braces on separate line
mrossetti
2011/11/21 21:53:25
Done.
| |
215 } | |
216 | 214 |
217 HistoryBackend::~HistoryBackend() { | 215 HistoryBackend::~HistoryBackend() { |
218 DCHECK(!scheduled_commit_) << "Deleting without cleanup"; | 216 DCHECK(!scheduled_commit_) << "Deleting without cleanup"; |
219 ReleaseDBTasks(); | 217 ReleaseDBTasks(); |
220 | 218 |
221 // First close the databases before optionally running the "destroy" task. | 219 // Close the databases before optionally running the "destroy" task. |
222 if (db_.get()) { | 220 if (db_.get()) { |
223 // Commit the long-running transaction. | 221 // Commit the long-running transaction. |
224 db_->CommitTransaction(); | 222 db_->CommitTransaction(); |
225 db_.reset(); | 223 db_.reset(); |
226 } | 224 } |
227 if (thumbnail_db_.get()) { | 225 if (thumbnail_db_.get()) { |
228 thumbnail_db_->CommitTransaction(); | 226 thumbnail_db_->CommitTransaction(); |
229 thumbnail_db_.reset(); | 227 thumbnail_db_.reset(); |
230 } | 228 } |
231 if (archived_db_.get()) { | 229 if (archived_db_.get()) { |
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
878 } | 876 } |
879 | 877 |
880 bool typed_url_changed = false; | 878 bool typed_url_changed = false; |
881 std::vector<URLRow> changed_urls; | 879 std::vector<URLRow> changed_urls; |
882 for (size_t i = 0; i < redirects->size(); i++) { | 880 for (size_t i = 0; i < redirects->size(); i++) { |
883 URLRow row; | 881 URLRow row; |
884 URLID row_id = db_->GetRowForURL(redirects->at(i), &row); | 882 URLID row_id = db_->GetRowForURL(redirects->at(i), &row); |
885 if (row_id && row.title() != title) { | 883 if (row_id && row.title() != title) { |
886 row.set_title(title); | 884 row.set_title(title); |
887 db_->UpdateURLRow(row_id, row); | 885 db_->UpdateURLRow(row_id, row); |
886 row.id_ = row_id; | |
888 changed_urls.push_back(row); | 887 changed_urls.push_back(row); |
889 if (row.typed_count() > 0) | 888 if (row.typed_count() > 0) |
890 typed_url_changed = true; | 889 typed_url_changed = true; |
891 } | 890 } |
892 } | 891 } |
893 | 892 |
894 // Broadcast notifications for typed URLs that have changed. This will | 893 // Broadcast notifications for typed URLs that have changed. This will |
895 // update the in-memory database. | 894 // update the in-memory database. |
896 // | 895 // |
897 // TODO(brettw) bug 1140020: Broadcast for all changes (not just typed), | 896 // TODO(brettw) bug 1140020: Broadcast for all changes (not just typed), |
(...skipping 1403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2301 break; | 2300 break; |
2302 } | 2301 } |
2303 } | 2302 } |
2304 } | 2303 } |
2305 UMA_HISTOGRAM_TIMES("History.GetFavIconFromDB", // historical name | 2304 UMA_HISTOGRAM_TIMES("History.GetFavIconFromDB", // historical name |
2306 TimeTicks::Now() - beginning_time); | 2305 TimeTicks::Now() - beginning_time); |
2307 return success; | 2306 return success; |
2308 } | 2307 } |
2309 | 2308 |
2310 } // namespace history | 2309 } // namespace history |
OLD | NEW |