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/omnibox/browser/shortcuts_backend.h" | 5 #include "components/omnibox/browser/shortcuts_backend.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | |
9 #include <map> | 8 #include <map> |
10 #include <string> | 9 #include <string> |
| 10 #include <utility> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/bind.h" | 13 #include "base/bind.h" |
14 #include "base/bind_helpers.h" | 14 #include "base/bind_helpers.h" |
15 #include "base/guid.h" | 15 #include "base/guid.h" |
16 #include "base/i18n/case_conversion.h" | 16 #include "base/i18n/case_conversion.h" |
17 #include "base/metrics/histogram_macros.h" | 17 #include "base/metrics/histogram_macros.h" |
18 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
19 #include "base/thread_task_runner_handle.h" | 19 #include "base/thread_task_runner_handle.h" |
20 #include "components/history/core/browser/history_service.h" | 20 #include "components/history/core/browser/history_service.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 // ShortcutsBackend ----------------------------------------------------------- | 65 // ShortcutsBackend ----------------------------------------------------------- |
66 | 66 |
67 ShortcutsBackend::ShortcutsBackend( | 67 ShortcutsBackend::ShortcutsBackend( |
68 TemplateURLService* template_url_service, | 68 TemplateURLService* template_url_service, |
69 scoped_ptr<SearchTermsData> search_terms_data, | 69 scoped_ptr<SearchTermsData> search_terms_data, |
70 history::HistoryService* history_service, | 70 history::HistoryService* history_service, |
71 scoped_refptr<base::SequencedTaskRunner> db_runner, | 71 scoped_refptr<base::SequencedTaskRunner> db_runner, |
72 base::FilePath database_path, | 72 base::FilePath database_path, |
73 bool suppress_db) | 73 bool suppress_db) |
74 : template_url_service_(template_url_service), | 74 : template_url_service_(template_url_service), |
75 search_terms_data_(search_terms_data.Pass()), | 75 search_terms_data_(std::move(search_terms_data)), |
76 current_state_(NOT_INITIALIZED), | 76 current_state_(NOT_INITIALIZED), |
77 history_service_observer_(this), | 77 history_service_observer_(this), |
78 main_runner_(base::ThreadTaskRunnerHandle::Get()), | 78 main_runner_(base::ThreadTaskRunnerHandle::Get()), |
79 db_runner_(db_runner), | 79 db_runner_(db_runner), |
80 no_db_access_(suppress_db) { | 80 no_db_access_(suppress_db) { |
81 if (!suppress_db) | 81 if (!suppress_db) |
82 db_ = new ShortcutsDatabase(database_path); | 82 db_ = new ShortcutsDatabase(database_path); |
83 if (history_service) | 83 if (history_service) |
84 history_service_observer_.Add(history_service); | 84 history_service_observer_.Add(history_service); |
85 } | 85 } |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 shortcuts_map_.clear(); | 318 shortcuts_map_.clear(); |
319 guid_map_.clear(); | 319 guid_map_.clear(); |
320 FOR_EACH_OBSERVER(ShortcutsBackendObserver, observer_list_, | 320 FOR_EACH_OBSERVER(ShortcutsBackendObserver, observer_list_, |
321 OnShortcutsChanged()); | 321 OnShortcutsChanged()); |
322 return no_db_access_ || | 322 return no_db_access_ || |
323 db_runner_->PostTask( | 323 db_runner_->PostTask( |
324 FROM_HERE, base::Bind(base::IgnoreResult( | 324 FROM_HERE, base::Bind(base::IgnoreResult( |
325 &ShortcutsDatabase::DeleteAllShortcuts), | 325 &ShortcutsDatabase::DeleteAllShortcuts), |
326 db_.get())); | 326 db_.get())); |
327 } | 327 } |
OLD | NEW |