Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Side by Side Diff: chrome/browser/history/history_backend.cc

Issue 10217010: Completed the code path from AndroidProviderService to HistoryBackend. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/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>
(...skipping 18 matching lines...) Expand all
29 #include "chrome/browser/history/visit_filter.h" 29 #include "chrome/browser/history/visit_filter.h"
30 #include "chrome/common/chrome_constants.h" 30 #include "chrome/common/chrome_constants.h"
31 #include "chrome/common/chrome_notification_types.h" 31 #include "chrome/common/chrome_notification_types.h"
32 #include "chrome/common/url_constants.h" 32 #include "chrome/common/url_constants.h"
33 #include "content/public/browser/download_persistent_store_info.h" 33 #include "content/public/browser/download_persistent_store_info.h"
34 #include "googleurl/src/gurl.h" 34 #include "googleurl/src/gurl.h"
35 #include "grit/chromium_strings.h" 35 #include "grit/chromium_strings.h"
36 #include "grit/generated_resources.h" 36 #include "grit/generated_resources.h"
37 #include "net/base/registry_controlled_domain.h" 37 #include "net/base/registry_controlled_domain.h"
38 38
39 #if defined(OS_ANDROID)
40 #include "chrome/browser/history/android/android_provider_backend.h"
41 #endif
42
39 using base::Time; 43 using base::Time;
40 using base::TimeDelta; 44 using base::TimeDelta;
41 using base::TimeTicks; 45 using base::TimeTicks;
42 46
43 /* The HistoryBackend consists of a number of components: 47 /* The HistoryBackend consists of a number of components:
44 48
45 HistoryDatabase (stores past 3 months of history) 49 HistoryDatabase (stores past 3 months of history)
46 URLDatabase (stores a list of URLs) 50 URLDatabase (stores a list of URLs)
47 DownloadDatabase (stores a list of downloads) 51 DownloadDatabase (stores a list of downloads)
48 VisitDatabase (stores a list of visits for the URLs) 52 VisitDatabase (stores a list of visits for the URLs)
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 recent_redirects_(kMaxRedirectCount), 214 recent_redirects_(kMaxRedirectCount),
211 backend_destroy_message_loop_(NULL), 215 backend_destroy_message_loop_(NULL),
212 segment_queried_(false), 216 segment_queried_(false),
213 bookmark_service_(bookmark_service) { 217 bookmark_service_(bookmark_service) {
214 } 218 }
215 219
216 HistoryBackend::~HistoryBackend() { 220 HistoryBackend::~HistoryBackend() {
217 DCHECK(!scheduled_commit_) << "Deleting without cleanup"; 221 DCHECK(!scheduled_commit_) << "Deleting without cleanup";
218 ReleaseDBTasks(); 222 ReleaseDBTasks();
219 223
224 #if defined(OS_ANDROID)
225 // Release AndroidProviderBackend before other objects.
226 android_provider_backend_.reset();
227 #endif
228
220 // First close the databases before optionally running the "destroy" task. 229 // First close the databases before optionally running the "destroy" task.
221 if (db_.get()) { 230 if (db_.get()) {
222 // Commit the long-running transaction. 231 // Commit the long-running transaction.
223 db_->CommitTransaction(); 232 db_->CommitTransaction();
224 db_.reset(); 233 db_.reset();
225 } 234 }
226 if (thumbnail_db_.get()) { 235 if (thumbnail_db_.get()) {
227 thumbnail_db_->CommitTransaction(); 236 thumbnail_db_->CommitTransaction();
228 thumbnail_db_.reset(); 237 thumbnail_db_.reset();
229 } 238 }
230 if (archived_db_.get()) { 239 if (archived_db_.get()) {
231 archived_db_->CommitTransaction(); 240 archived_db_->CommitTransaction();
232 archived_db_.reset(); 241 archived_db_.reset();
233 } 242 }
234 if (text_database_.get()) { 243 if (text_database_.get()) {
235 text_database_->CommitTransaction(); 244 text_database_->CommitTransaction();
236 text_database_.reset(); 245 text_database_.reset();
237 } 246 }
238 247
239 if (!backend_destroy_task_.is_null()) { 248 if (!backend_destroy_task_.is_null()) {
240 // Notify an interested party (typically a unit test) that we're done. 249 // Notify an interested party (typically a unit test) that we're done.
241 DCHECK(backend_destroy_message_loop_); 250 DCHECK(backend_destroy_message_loop_);
242 backend_destroy_message_loop_->PostTask(FROM_HERE, backend_destroy_task_); 251 backend_destroy_message_loop_->PostTask(FROM_HERE, backend_destroy_task_);
243 } 252 }
253
254 #if defined(OS_ANDROID)
255 file_util::Delete(GetAndroidCacheFileName(), false);
256 #endif
244 } 257 }
245 258
246 void HistoryBackend::Init(const std::string& languages, bool force_fail) { 259 void HistoryBackend::Init(const std::string& languages, bool force_fail) {
247 if (!force_fail) 260 if (!force_fail)
248 InitImpl(languages); 261 InitImpl(languages);
249 delegate_->DBLoaded(id_); 262 delegate_->DBLoaded(id_);
250 } 263 }
251 264
252 void HistoryBackend::SetOnBackendDestroyTask(MessageLoop* message_loop, 265 void HistoryBackend::SetOnBackendDestroyTask(MessageLoop* message_loop,
253 const base::Closure& task) { 266 const base::Closure& task) {
(...skipping 22 matching lines...) Expand all
276 } 289 }
277 290
278 FilePath HistoryBackend::GetFaviconsFileName() const { 291 FilePath HistoryBackend::GetFaviconsFileName() const {
279 return history_dir_.Append(chrome::kFaviconsFilename); 292 return history_dir_.Append(chrome::kFaviconsFilename);
280 } 293 }
281 294
282 FilePath HistoryBackend::GetArchivedFileName() const { 295 FilePath HistoryBackend::GetArchivedFileName() const {
283 return history_dir_.Append(chrome::kArchivedHistoryFilename); 296 return history_dir_.Append(chrome::kArchivedHistoryFilename);
284 } 297 }
285 298
299 #if defined(OS_ANDROID)
300 FilePath HistoryBackend::GetAndroidCacheFileName() const {
301 return history_dir_.Append(chrome::kAndroidCacheFilename);
302 }
303 #endif
304
286 SegmentID HistoryBackend::GetLastSegmentID(VisitID from_visit) { 305 SegmentID HistoryBackend::GetLastSegmentID(VisitID from_visit) {
287 // Set is used to detect referrer loops. Should not happen, but can 306 // Set is used to detect referrer loops. Should not happen, but can
288 // if the database is corrupt. 307 // if the database is corrupt.
289 std::set<VisitID> visit_set; 308 std::set<VisitID> visit_set;
290 VisitID visit_id = from_visit; 309 VisitID visit_id = from_visit;
291 while (visit_id) { 310 while (visit_id) {
292 VisitRow row; 311 VisitRow row;
293 if (!db_->GetRowForVisit(visit_id, &row)) 312 if (!db_->GetRowForVisit(visit_id, &row))
294 return 0; 313 return 0;
295 if (row.segment_id) 314 if (row.segment_id)
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 archived_db_->BeginTransaction(); 714 archived_db_->BeginTransaction();
696 if (text_database_.get()) 715 if (text_database_.get())
697 text_database_->BeginTransaction(); 716 text_database_->BeginTransaction();
698 717
699 // Get the first item in our database. 718 // Get the first item in our database.
700 db_->GetStartDate(&first_recorded_time_); 719 db_->GetStartDate(&first_recorded_time_);
701 720
702 // Start expiring old stuff. 721 // Start expiring old stuff.
703 expirer_.StartArchivingOldStuff(TimeDelta::FromDays(kArchiveDaysThreshold)); 722 expirer_.StartArchivingOldStuff(TimeDelta::FromDays(kArchiveDaysThreshold));
704 723
724 #if defined(OS_ANDROID)
725 if (thumbnail_db_.get()) {
726 android_provider_backend_.reset(new AndroidProviderBackend(
727 GetAndroidCacheFileName(), db_.get(), thumbnail_db_.get(),
728 bookmark_service_, delegate_.get()));
729 }
730 #endif
731
705 HISTOGRAM_TIMES("History.InitTime", 732 HISTOGRAM_TIMES("History.InitTime",
706 TimeTicks::Now() - beginning_time); 733 TimeTicks::Now() - beginning_time);
707 } 734 }
708 735
709 std::pair<URLID, VisitID> HistoryBackend::AddPageVisit( 736 std::pair<URLID, VisitID> HistoryBackend::AddPageVisit(
710 const GURL& url, 737 const GURL& url,
711 Time time, 738 Time time,
712 VisitID referring_visit, 739 VisitID referring_visit,
713 content::PageTransition transition, 740 content::PageTransition transition,
714 VisitSource visit_source) { 741 VisitSource visit_source) {
(...skipping 1767 matching lines...) Expand 10 before | Expand all | Expand 10 after
2482 info.url_id = visit.url_id; 2509 info.url_id = visit.url_id;
2483 info.time = visit.visit_time; 2510 info.time = visit.visit_time;
2484 info.transition = visit.transition; 2511 info.transition = visit.transition;
2485 // If we don't have a delegate yet during setup or shutdown, we will drop 2512 // If we don't have a delegate yet during setup or shutdown, we will drop
2486 // these notifications. 2513 // these notifications.
2487 if (delegate_.get()) 2514 if (delegate_.get())
2488 delegate_->NotifyVisitDBObserversOnAddVisit(info); 2515 delegate_->NotifyVisitDBObserversOnAddVisit(info);
2489 } 2516 }
2490 2517
2491 } // namespace history 2518 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/history/history_backend.h ('k') | chrome/browser/history/history_backend_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698