OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef UI_APP_LIST_SEARCH_HISTORY_DATA_STORE_H_ | 5 #ifndef UI_APP_LIST_SEARCH_HISTORY_DATA_STORE_H_ |
6 #define UI_APP_LIST_SEARCH_HISTORY_DATA_STORE_H_ | 6 #define UI_APP_LIST_SEARCH_HISTORY_DATA_STORE_H_ |
7 | 7 |
| 8 #include <memory> |
8 #include <string> | 9 #include <string> |
9 #include <vector> | 10 #include <vector> |
10 | 11 |
11 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
12 #include "base/macros.h" | 13 #include "base/macros.h" |
13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | |
15 #include "ui/app_list/app_list_export.h" | 15 #include "ui/app_list/app_list_export.h" |
16 #include "ui/app_list/search/dictionary_data_store.h" | 16 #include "ui/app_list/search/dictionary_data_store.h" |
17 #include "ui/app_list/search/history_data.h" | 17 #include "ui/app_list/search/history_data.h" |
18 | 18 |
19 namespace base { | 19 namespace base { |
20 class DictionaryValue; | 20 class DictionaryValue; |
21 class SequencedTaskRunner; | 21 class SequencedTaskRunner; |
22 } | 22 } |
23 | 23 |
24 namespace app_list { | 24 namespace app_list { |
25 | 25 |
26 namespace test { | 26 namespace test { |
27 class HistoryDataStoreTest; | 27 class HistoryDataStoreTest; |
28 } | 28 } |
29 | 29 |
30 // A simple json store to persist HistoryData. | 30 // A simple json store to persist HistoryData. |
31 class APP_LIST_EXPORT HistoryDataStore | 31 class APP_LIST_EXPORT HistoryDataStore |
32 : public base::RefCountedThreadSafe<HistoryDataStore> { | 32 : public base::RefCountedThreadSafe<HistoryDataStore> { |
33 public: | 33 public: |
34 typedef base::Callback<void(scoped_ptr<HistoryData::Associations>)> | 34 typedef base::Callback<void(std::unique_ptr<HistoryData::Associations>)> |
35 OnLoadedCallback; | 35 OnLoadedCallback; |
36 | 36 |
37 // A data store with no storage backend. | 37 // A data store with no storage backend. |
38 HistoryDataStore(); | 38 HistoryDataStore(); |
39 | 39 |
40 // |data_store| stores the history into the file. | 40 // |data_store| stores the history into the file. |
41 explicit HistoryDataStore(scoped_refptr<DictionaryDataStore> data_store); | 41 explicit HistoryDataStore(scoped_refptr<DictionaryDataStore> data_store); |
42 | 42 |
43 // Flushes pending writes. |on_flushed| is invoked when disk write is | 43 // Flushes pending writes. |on_flushed| is invoked when disk write is |
44 // finished. | 44 // finished. |
(...skipping 19 matching lines...) Expand all Loading... |
64 | 64 |
65 void Init(base::DictionaryValue* cached_dict); | 65 void Init(base::DictionaryValue* cached_dict); |
66 | 66 |
67 // Gets the dictionary for "associations" key. | 67 // Gets the dictionary for "associations" key. |
68 base::DictionaryValue* GetAssociationDict(); | 68 base::DictionaryValue* GetAssociationDict(); |
69 | 69 |
70 // Gets entry dictionary for given |query|. Creates one if necessary. | 70 // Gets entry dictionary for given |query|. Creates one if necessary. |
71 base::DictionaryValue* GetEntryDict(const std::string& query); | 71 base::DictionaryValue* GetEntryDict(const std::string& query); |
72 | 72 |
73 void OnDictionaryLoadedCallback(OnLoadedCallback callback, | 73 void OnDictionaryLoadedCallback(OnLoadedCallback callback, |
74 scoped_ptr<base::DictionaryValue> dict); | 74 std::unique_ptr<base::DictionaryValue> dict); |
75 | 75 |
76 // |cached_dict_| and |data_store_| is mutually exclusive. |data_store_| is | 76 // |cached_dict_| and |data_store_| is mutually exclusive. |data_store_| is |
77 // used if it's backed by a file storage, otherwise |cache_dict_| keeps | 77 // used if it's backed by a file storage, otherwise |cache_dict_| keeps |
78 // on-memory data. | 78 // on-memory data. |
79 scoped_ptr<base::DictionaryValue> cached_dict_; | 79 std::unique_ptr<base::DictionaryValue> cached_dict_; |
80 scoped_refptr<DictionaryDataStore> data_store_; | 80 scoped_refptr<DictionaryDataStore> data_store_; |
81 | 81 |
82 DISALLOW_COPY_AND_ASSIGN(HistoryDataStore); | 82 DISALLOW_COPY_AND_ASSIGN(HistoryDataStore); |
83 }; | 83 }; |
84 | 84 |
85 } // namespace app_list | 85 } // namespace app_list |
86 | 86 |
87 #endif // UI_APP_LIST_SEARCH_HISTORY_DATA_STORE_H_ | 87 #endif // UI_APP_LIST_SEARCH_HISTORY_DATA_STORE_H_ |
OLD | NEW |