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 std::unique_ptr<base::DictionaryValue> DictFromPayload( | 91 base::DictionaryValue* DictFromPayload(const Payload& payload); |
92 const Payload& payload); | |
93 | 92 |
94 // Trims our MRU cache, making sure that any element that is removed is also | 93 // Trims our MRU cache, making sure that any element that is removed is also |
95 // removed from the dictionary data store. | 94 // removed from the dictionary data store. |
96 void TrimCache(); | 95 void TrimCache(); |
97 | 96 |
98 // Prepends a type string to the given query and returns a new query string. | 97 // Prepends a type string to the given query and returns a new query string. |
99 std::string PrependType(QueryType type, const std::string& query); | 98 std::string PrependType(QueryType type, const std::string& query); |
100 | 99 |
101 Cache cache_; | 100 Cache cache_; |
102 scoped_refptr<DictionaryDataStore> data_store_; | 101 scoped_refptr<DictionaryDataStore> data_store_; |
103 | 102 |
104 bool cache_loaded_; | 103 bool cache_loaded_; |
105 | 104 |
106 DISALLOW_COPY_AND_ASSIGN(WebserviceCache); | 105 DISALLOW_COPY_AND_ASSIGN(WebserviceCache); |
107 }; | 106 }; |
108 | 107 |
109 } // namespace app_list | 108 } // namespace app_list |
110 | 109 |
111 #endif // CHROME_BROWSER_UI_APP_LIST_SEARCH_COMMON_WEBSERVICE_CACHE_H_ | 110 #endif // CHROME_BROWSER_UI_APP_LIST_SEARCH_COMMON_WEBSERVICE_CACHE_H_ |
OLD | NEW |