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 "chrome/browser/history/in_memory_url_index.h" | 5 #include "chrome/browser/history/in_memory_url_index.h" |
6 | 6 |
7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/bookmarks/bookmark_model.h" | 10 #include "chrome/browser/bookmarks/bookmark_model.h" |
11 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 11 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
12 #include "chrome/browser/chrome_notification_types.h" | 12 #include "chrome/browser/chrome_notification_types.h" |
13 #include "chrome/browser/history/history_notifications.h" | 13 #include "chrome/browser/history/history_notifications.h" |
14 #include "chrome/browser/history/history_service.h" | 14 #include "chrome/browser/history/history_service.h" |
15 #include "chrome/browser/history/history_service_factory.h" | 15 #include "chrome/browser/history/history_service_factory.h" |
16 #include "chrome/browser/history/url_database.h" | 16 #include "chrome/browser/history/url_database.h" |
17 #include "chrome/browser/history/url_index_private_data.h" | 17 #include "chrome/browser/history/url_index_private_data.h" |
18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/common/url_constants.h" | 19 #include "chrome/common/url_constants.h" |
20 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
21 #include "content/public/browser/notification_details.h" | 21 #include "content/public/browser/notification_details.h" |
22 #include "content/public/browser/notification_service.h" | 22 #include "content/public/browser/notification_service.h" |
23 #include "content/public/browser/notification_source.h" | 23 #include "content/public/browser/notification_source.h" |
| 24 #include "net/base/url_constants.h" |
24 | 25 |
25 using in_memory_url_index::InMemoryURLIndexCacheItem; | 26 using in_memory_url_index::InMemoryURLIndexCacheItem; |
26 | 27 |
27 namespace history { | 28 namespace history { |
28 | 29 |
29 // Called by DoSaveToCacheFile to delete any old cache file at |path| when | 30 // Called by DoSaveToCacheFile to delete any old cache file at |path| when |
30 // there is no private data to save. Runs on the FILE thread. | 31 // there is no private data to save. Runs on the FILE thread. |
31 void DeleteCacheFile(const base::FilePath& path) { | 32 void DeleteCacheFile(const base::FilePath& path) { |
32 DCHECK(!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 33 DCHECK(!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
33 base::DeleteFile(path, false); | 34 base::DeleteFile(path, false); |
34 } | 35 } |
35 | 36 |
36 // Initializes a whitelist of URL schemes. | 37 // Initializes a whitelist of URL schemes. |
37 void InitializeSchemeWhitelist(std::set<std::string>* whitelist) { | 38 void InitializeSchemeWhitelist(std::set<std::string>* whitelist) { |
38 DCHECK(whitelist); | 39 DCHECK(whitelist); |
39 if (!whitelist->empty()) | 40 if (!whitelist->empty()) |
40 return; // Nothing to do, already initialized. | 41 return; // Nothing to do, already initialized. |
41 whitelist->insert(std::string(content::kAboutScheme)); | 42 whitelist->insert(std::string(content::kAboutScheme)); |
42 whitelist->insert(std::string(content::kChromeUIScheme)); | 43 whitelist->insert(std::string(content::kChromeUIScheme)); |
43 whitelist->insert(std::string(content::kFileScheme)); | 44 whitelist->insert(std::string(content::kFileScheme)); |
44 whitelist->insert(std::string(content::kFtpScheme)); | 45 whitelist->insert(std::string(content::kFtpScheme)); |
45 whitelist->insert(std::string(content::kHttpScheme)); | 46 whitelist->insert(std::string(net::kHttpScheme)); |
46 whitelist->insert(std::string(content::kHttpsScheme)); | 47 whitelist->insert(std::string(net::kHttpsScheme)); |
47 whitelist->insert(std::string(content::kMailToScheme)); | 48 whitelist->insert(std::string(content::kMailToScheme)); |
48 } | 49 } |
49 | 50 |
50 // Restore/SaveCacheObserver --------------------------------------------------- | 51 // Restore/SaveCacheObserver --------------------------------------------------- |
51 | 52 |
52 InMemoryURLIndex::RestoreCacheObserver::~RestoreCacheObserver() {} | 53 InMemoryURLIndex::RestoreCacheObserver::~RestoreCacheObserver() {} |
53 | 54 |
54 InMemoryURLIndex::SaveCacheObserver::~SaveCacheObserver() {} | 55 InMemoryURLIndex::SaveCacheObserver::~SaveCacheObserver() {} |
55 | 56 |
56 // RebuildPrivateDataFromHistoryDBTask ----------------------------------------- | 57 // RebuildPrivateDataFromHistoryDBTask ----------------------------------------- |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 base::Bind(DeleteCacheFile, path)); | 339 base::Bind(DeleteCacheFile, path)); |
339 } | 340 } |
340 } | 341 } |
341 | 342 |
342 void InMemoryURLIndex::OnCacheSaveDone(bool succeeded) { | 343 void InMemoryURLIndex::OnCacheSaveDone(bool succeeded) { |
343 if (save_cache_observer_) | 344 if (save_cache_observer_) |
344 save_cache_observer_->OnCacheSaveFinished(succeeded); | 345 save_cache_observer_->OnCacheSaveFinished(succeeded); |
345 } | 346 } |
346 | 347 |
347 } // namespace history | 348 } // namespace history |
OLD | NEW |