Add a minor text member to ui::MenuModel.
[chromium-blink-merge.git] / chrome / browser / ui / app_list / search / webstore_cache.h
blob4890c3368f35247597c71e5d35f6ef077cc19aa5
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_APP_LIST_SEARCH_WEBSTORE_CACHE_H_
6 #define CHROME_BROWSER_UI_APP_LIST_SEARCH_WEBSTORE_CACHE_H_
8 #include <utility>
10 #include "base/basictypes.h"
11 #include "base/containers/mru_cache.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/time/time.h"
15 namespace base {
16 class DictionaryValue;
19 namespace app_list {
21 // WebstoreCache manages the cache of webstore search results which should
22 // be valid during an input session. This will reduce unnecessary queries
23 // for typing backspace or so on.
24 class WebstoreCache {
25 public:
26 WebstoreCache();
27 ~WebstoreCache();
29 // Checks the current cache and returns the value for the |query| if it's
30 // valid. Otherwise returns NULL.
31 const base::DictionaryValue* Get(const std::string& query);
33 // Puts the new result to the query.
34 void Put(const std::string& query, scoped_ptr<base::DictionaryValue> result);
36 private:
37 typedef std::pair<base::Time, base::DictionaryValue*> Payload;
38 class CacheDeletor {
39 public:
40 void operator()(Payload& payload);
42 typedef base::MRUCacheBase<std::string, Payload, CacheDeletor> Cache;
44 Cache cache_;
46 DISALLOW_COPY_AND_ASSIGN(WebstoreCache);
49 } // namespace app_list
51 #endif // CHROME_BROWSER_UI_APP_LIST_SEARCH_WEBSTORE_CACHE_H_