OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 <set> | 7 #include <set> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
11 #include "base/histogram.h" | 11 #include "base/histogram.h" |
12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
13 #include "base/scoped_ptr.h" | 13 #include "base/scoped_ptr.h" |
14 #include "base/scoped_vector.h" | 14 #include "base/scoped_vector.h" |
15 #include "base/string_util.h" | 15 #include "base/string_util.h" |
16 #include "base/time.h" | 16 #include "base/time.h" |
17 #include "chrome/browser/autocomplete/history_url_provider.h" | 17 #include "chrome/browser/autocomplete/history_url_provider.h" |
18 #include "chrome/browser/bookmarks/bookmark_service.h" | 18 #include "chrome/browser/bookmarks/bookmark_service.h" |
19 #include "chrome/browser/history/download_types.h" | 19 #include "chrome/browser/history/download_types.h" |
20 #include "chrome/browser/history/history_publisher.h" | 20 #include "chrome/browser/history/history_publisher.h" |
21 #include "chrome/browser/history/in_memory_history_backend.h" | 21 #include "chrome/browser/history/in_memory_history_backend.h" |
22 #include "chrome/browser/history/page_usage_data.h" | 22 #include "chrome/browser/history/page_usage_data.h" |
23 #include "chrome/common/chrome_constants.h" | 23 #include "chrome/common/chrome_constants.h" |
24 #include "chrome/common/notification_type.h" | 24 #include "chrome/common/notification_type.h" |
25 #include "chrome/common/sqlite_utils.h" | 25 #include "chrome/common/sqlite_utils.h" |
26 #include "chrome/common/url_constants.h" | 26 #include "chrome/common/url_constants.h" |
27 #include "googleurl/src/gurl.h" | 27 #include "googleurl/src/gurl.h" |
| 28 #include "grit/chromium_strings.h" |
| 29 #include "grit/generated_resources.h" |
28 #include "net/base/registry_controlled_domain.h" | 30 #include "net/base/registry_controlled_domain.h" |
29 | 31 |
30 using base::Time; | 32 using base::Time; |
31 using base::TimeDelta; | 33 using base::TimeDelta; |
32 using base::TimeTicks; | 34 using base::TimeTicks; |
33 | 35 |
34 /* The HistoryBackend consists of a number of components: | 36 /* The HistoryBackend consists of a number of components: |
35 | 37 |
36 HistoryDatabase (stores past 3 months of history) | 38 HistoryDatabase (stores past 3 months of history) |
37 URLDatabase (stores a list of URLs) | 39 URLDatabase (stores a list of URLs) |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 chrome::kHistoryBookmarksFileName); | 496 chrome::kHistoryBookmarksFileName); |
495 | 497 |
496 // History database. | 498 // History database. |
497 db_.reset(new HistoryDatabase()); | 499 db_.reset(new HistoryDatabase()); |
498 switch (db_->Init(history_name, tmp_bookmarks_file)) { | 500 switch (db_->Init(history_name, tmp_bookmarks_file)) { |
499 case INIT_OK: | 501 case INIT_OK: |
500 break; | 502 break; |
501 case INIT_FAILURE: | 503 case INIT_FAILURE: |
502 // A NULL db_ will cause all calls on this object to notice this error | 504 // A NULL db_ will cause all calls on this object to notice this error |
503 // and to not continue. | 505 // and to not continue. |
504 LOG(WARNING) << "Unable to initialize history DB."; | 506 delegate_->NotifyProfileError(IDS_COULDNT_OPEN_PROFILE_ERROR); |
505 db_.reset(); | 507 db_.reset(); |
506 return; | 508 return; |
507 case INIT_TOO_NEW: | 509 case INIT_TOO_NEW: |
508 delegate_->NotifyTooNew(); | 510 delegate_->NotifyProfileError(IDS_PROFILE_TOO_NEW_ERROR); |
509 db_.reset(); | 511 db_.reset(); |
510 return; | 512 return; |
511 default: | 513 default: |
512 NOTREACHED(); | 514 NOTREACHED(); |
513 } | 515 } |
514 | 516 |
515 // Fill the in-memory database and send it back to the history service on the | 517 // Fill the in-memory database and send it back to the history service on the |
516 // main thread. | 518 // main thread. |
517 InMemoryHistoryBackend* mem_backend = new InMemoryHistoryBackend; | 519 InMemoryHistoryBackend* mem_backend = new InMemoryHistoryBackend; |
518 if (mem_backend->Init(history_name)) | 520 if (mem_backend->Init(history_name)) |
(...skipping 1458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1977 return true; | 1979 return true; |
1978 } | 1980 } |
1979 | 1981 |
1980 BookmarkService* HistoryBackend::GetBookmarkService() { | 1982 BookmarkService* HistoryBackend::GetBookmarkService() { |
1981 if (bookmark_service_) | 1983 if (bookmark_service_) |
1982 bookmark_service_->BlockTillLoaded(); | 1984 bookmark_service_->BlockTillLoaded(); |
1983 return bookmark_service_; | 1985 return bookmark_service_; |
1984 } | 1986 } |
1985 | 1987 |
1986 } // namespace history | 1988 } // namespace history |
OLD | NEW |