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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 backend_destroy_message_loop_->PostTask(FROM_HERE, backend_destroy_task_); | 231 backend_destroy_message_loop_->PostTask(FROM_HERE, backend_destroy_task_); |
232 } | 232 } |
233 | 233 |
234 #if defined(OS_ANDROID) | 234 #if defined(OS_ANDROID) |
235 if (backend_client_ && !history_dir_.empty()) | 235 if (backend_client_ && !history_dir_.empty()) |
236 backend_client_->OnHistoryBackendDestroyed(this, history_dir_); | 236 backend_client_->OnHistoryBackendDestroyed(this, history_dir_); |
237 #endif | 237 #endif |
238 } | 238 } |
239 | 239 |
240 void HistoryBackend::Init( | 240 void HistoryBackend::Init( |
241 const std::string& languages, | |
242 bool force_fail, | 241 bool force_fail, |
243 const HistoryDatabaseParams& history_database_params) { | 242 const HistoryDatabaseParams& history_database_params) { |
244 // HistoryBackend is created on the UI thread by HistoryService, then the | 243 // HistoryBackend is created on the UI thread by HistoryService, then the |
245 // HistoryBackend::Init() method is called on the DB thread. Create the | 244 // HistoryBackend::Init() method is called on the DB thread. Create the |
246 // base::SupportsUserData on the DB thread since it is not thread-safe. | 245 // base::SupportsUserData on the DB thread since it is not thread-safe. |
247 supports_user_data_helper_.reset(new HistoryBackendHelper); | 246 supports_user_data_helper_.reset(new HistoryBackendHelper); |
248 | 247 |
249 if (!force_fail) | 248 if (!force_fail) |
250 InitImpl(languages, history_database_params); | 249 InitImpl(history_database_params); |
251 delegate_->DBLoaded(); | 250 delegate_->DBLoaded(); |
252 typed_url_syncable_service_.reset(new TypedUrlSyncableService(this)); | 251 typed_url_syncable_service_.reset(new TypedUrlSyncableService(this)); |
253 memory_pressure_listener_.reset(new base::MemoryPressureListener( | 252 memory_pressure_listener_.reset(new base::MemoryPressureListener( |
254 base::Bind(&HistoryBackend::OnMemoryPressure, base::Unretained(this)))); | 253 base::Bind(&HistoryBackend::OnMemoryPressure, base::Unretained(this)))); |
255 } | 254 } |
256 | 255 |
257 void HistoryBackend::SetOnBackendDestroyTask(base::MessageLoop* message_loop, | 256 void HistoryBackend::SetOnBackendDestroyTask(base::MessageLoop* message_loop, |
258 const base::Closure& task) { | 257 const base::Closure& task) { |
259 if (!backend_destroy_task_.is_null()) | 258 if (!backend_destroy_task_.is_null()) |
260 DLOG(WARNING) << "Setting more than one destroy task, overriding"; | 259 DLOG(WARNING) << "Setting more than one destroy task, overriding"; |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 stripped_transition != ui::PAGE_TRANSITION_MANUAL_SUBFRAME && | 616 stripped_transition != ui::PAGE_TRANSITION_MANUAL_SUBFRAME && |
618 !is_keyword_generated) { | 617 !is_keyword_generated) { |
619 tracker_.AddVisit(request.context_id, request.nav_entry_id, request.url, | 618 tracker_.AddVisit(request.context_id, request.nav_entry_id, request.url, |
620 last_ids.second); | 619 last_ids.second); |
621 } | 620 } |
622 | 621 |
623 ScheduleCommit(); | 622 ScheduleCommit(); |
624 } | 623 } |
625 | 624 |
626 void HistoryBackend::InitImpl( | 625 void HistoryBackend::InitImpl( |
627 const std::string& languages, | |
628 const HistoryDatabaseParams& history_database_params) { | 626 const HistoryDatabaseParams& history_database_params) { |
629 DCHECK(!db_) << "Initializing HistoryBackend twice"; | 627 DCHECK(!db_) << "Initializing HistoryBackend twice"; |
630 // In the rare case where the db fails to initialize a dialog may get shown | 628 // In the rare case where the db fails to initialize a dialog may get shown |
631 // the blocks the caller, yet allows other messages through. For this reason | 629 // the blocks the caller, yet allows other messages through. For this reason |
632 // we only set db_ to the created database if creation is successful. That | 630 // we only set db_ to the created database if creation is successful. That |
633 // way other methods won't do anything as db_ is still null. | 631 // way other methods won't do anything as db_ is still null. |
634 | 632 |
635 TimeTicks beginning_time = TimeTicks::Now(); | 633 TimeTicks beginning_time = TimeTicks::Now(); |
636 | 634 |
637 // Compute the file names. | 635 // Compute the file names. |
(...skipping 1986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2624 // transaction is currently open. | 2622 // transaction is currently open. |
2625 db_->CommitTransaction(); | 2623 db_->CommitTransaction(); |
2626 db_->Vacuum(); | 2624 db_->Vacuum(); |
2627 db_->BeginTransaction(); | 2625 db_->BeginTransaction(); |
2628 db_->GetStartDate(&first_recorded_time_); | 2626 db_->GetStartDate(&first_recorded_time_); |
2629 | 2627 |
2630 return true; | 2628 return true; |
2631 } | 2629 } |
2632 | 2630 |
2633 } // namespace history | 2631 } // namespace history |
OLD | NEW |