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 CHROME_BROWSER_UI_APP_LIST_SEARCH_COMMON_WEBSERVICE_CACHE_H_ | 5 #ifndef CHROME_BROWSER_UI_APP_LIST_SEARCH_COMMON_WEBSERVICE_CACHE_H_ |
6 #define CHROME_BROWSER_UI_APP_LIST_SEARCH_COMMON_WEBSERVICE_CACHE_H_ | 6 #define CHROME_BROWSER_UI_APP_LIST_SEARCH_COMMON_WEBSERVICE_CACHE_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 void OnCacheLoaded(std::unique_ptr<base::DictionaryValue>); | 81 void OnCacheLoaded(std::unique_ptr<base::DictionaryValue>); |
82 | 82 |
83 // Populates the payload parameter with the corresponding payload stored | 83 // Populates the payload parameter with the corresponding payload stored |
84 // in the given dictionary. If the dictionary is invalid for any reason, | 84 // in the given dictionary. If the dictionary is invalid for any reason, |
85 // this method will return false. | 85 // this method will return false. |
86 bool PayloadFromDict(const base::DictionaryValue* dict, Payload* payload); | 86 bool PayloadFromDict(const base::DictionaryValue* dict, Payload* payload); |
87 | 87 |
88 // Returns a dictionary value for a given payload. The returned dictionary | 88 // Returns a dictionary value for a given payload. The returned dictionary |
89 // will be owned by the data_store_ cached_dict, and freed on the destruction | 89 // will be owned by the data_store_ cached_dict, and freed on the destruction |
90 // of our dictionary datastore. | 90 // of our dictionary datastore. |
91 base::DictionaryValue* DictFromPayload(const Payload& payload); | 91 std::unique_ptr<base::DictionaryValue> DictFromPayload( |
| 92 const Payload& payload); |
92 | 93 |
93 // Trims our MRU cache, making sure that any element that is removed is also | 94 // Trims our MRU cache, making sure that any element that is removed is also |
94 // removed from the dictionary data store. | 95 // removed from the dictionary data store. |
95 void TrimCache(); | 96 void TrimCache(); |
96 | 97 |
97 // Prepends a type string to the given query and returns a new query string. | 98 // Prepends a type string to the given query and returns a new query string. |
98 std::string PrependType(QueryType type, const std::string& query); | 99 std::string PrependType(QueryType type, const std::string& query); |
99 | 100 |
100 Cache cache_; | 101 Cache cache_; |
101 scoped_refptr<DictionaryDataStore> data_store_; | 102 scoped_refptr<DictionaryDataStore> data_store_; |
102 | 103 |
103 bool cache_loaded_; | 104 bool cache_loaded_; |
104 | 105 |
105 DISALLOW_COPY_AND_ASSIGN(WebserviceCache); | 106 DISALLOW_COPY_AND_ASSIGN(WebserviceCache); |
106 }; | 107 }; |
107 | 108 |
108 } // namespace app_list | 109 } // namespace app_list |
109 | 110 |
110 #endif // CHROME_BROWSER_UI_APP_LIST_SEARCH_COMMON_WEBSERVICE_CACHE_H_ | 111 #endif // CHROME_BROWSER_UI_APP_LIST_SEARCH_COMMON_WEBSERVICE_CACHE_H_ |
OLD | NEW |